Re: [rtc-linux] Re: rtc max frequency setting

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <rtc-linux@...>
Cc: <hpa@...>, Jan Engelhardt <jengelh@...>, Linux Kernel Mailing List <linux-kernel@...>, Eugene Teo <eugeneteo@...>
Date: Monday, August 6, 2007 - 3:01 pm

On Sat, 04 Aug 2007 17:06:38 -0700
"H. Peter Anvin" <hpa@zytor.com> wrote:


 quick hack to set the maximum freq. I haven't tested t, just compiled.
 I'm not sure about simple_strtoul.

 please provide feedback ;)

---
 drivers/rtc/rtc-sysfs.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

--- linux-2.6.orig/drivers/rtc/rtc-sysfs.c	2007-08-06 20:34:12.000000000 +0200
+++ linux-2.6/drivers/rtc/rtc-sysfs.c	2007-08-06 20:50:03.000000000 +0200
@@ -73,11 +73,37 @@ rtc_sysfs_show_since_epoch(struct device
 	return retval;
 }
 
+static ssize_t
+rtc_sysfs_show_max_user_freq(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	struct rtc_device *rtc = to_rtc_device(dev);
+	return sprintf(buf, "%d\n", rtc->max_user_freq);
+}
+
+static ssize_t
+rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t n)
+{
+	unsigned long w;
+	struct rtc_device *rtc = to_rtc_device(dev);
+
+	w = simple_strtoul(buf, NULL, 0);
+	if (is_power_of_2(w)) {
+		rtc->max_user_freq = w;
+		return n;
+	}
+
+	return -EINVAL;
+}
+
 static struct device_attribute rtc_attrs[] = {
 	__ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
 	__ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
 	__ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL),
 	__ATTR(since_epoch, S_IRUGO, rtc_sysfs_show_since_epoch, NULL),
+	__ATTR(max_user_freq, S_IRUGO | S_IWUSR, rtc_sysfs_show_max_user_freq,
+					rtc_sysfs_set_max_user_freq),
 	{ },
 };
 


-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
rtc max frequency setting, Jan Engelhardt, (Sat Aug 4, 6:44 pm)
Re: rtc max frequency setting, H. Peter Anvin, (Sat Aug 4, 8:06 pm)
Re: rtc max frequency setting, Bill Davidsen, (Fri Aug 10, 12:40 am)
Re: [rtc-linux] Re: rtc max frequency setting, Alessandro Zummo, (Mon Aug 6, 3:01 pm)
Re: rtc max frequency setting, Michael Chang, (Sun Aug 5, 7:40 pm)
Re: rtc max frequency setting, Jan Engelhardt, (Sun Aug 5, 4:05 am)
Re: [rtc-linux] Re: rtc max frequency setting, Alessandro Zummo, (Sat Aug 4, 8:41 pm)