aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBryan Kadzban <bryan@kdzbn.homelinux.net>2007-10-16 04:28:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:13 -0400
commit06c65eb45578c52d1bc69d044239646d4c90e7ea (patch)
tree50d136607746d1a885ed8bb3757a3850faa28dd6 /drivers
parent05440dfcfcabde6fcf7297dfa5a29f0355b78ffb (diff)
rtc: add max_user_freq to sysfs
drivers/char/rtc.c exposed a sysctl to change the maximum frequency at which a non-root user could ask the RTC to generate interrupts (via the RTC_IRQP_SET ioctl). This value is no longer available under the new RTC subsystem, so add it to sysfs for each RTC device. Works for me on x86_64 (both reads and writes), using rtc-cmos. Signed-off-by: Bryan Kadzban <bryan@kdzbn.homelinux.net> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-sysfs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 69df94b44841..6cad0841f3c4 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -73,11 +73,35 @@ rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
73 return retval; 73 return retval;
74} 74}
75 75
76static ssize_t
77rtc_sysfs_show_max_user_freq(struct device *dev, struct device_attribute *attr,
78 char *buf)
79{
80 return sprintf(buf, "%d\n", to_rtc_device(dev)->max_user_freq);
81}
82
83static ssize_t
84rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr,
85 const char *buf, size_t n)
86{
87 struct rtc_device *rtc = to_rtc_device(dev);
88 unsigned long val = simple_strtoul(buf, NULL, 0);
89
90 if (val >= 4096 || val == 0)
91 return -EINVAL;
92
93 rtc->max_user_freq = (int)val;
94
95 return n;
96}
97
76static struct device_attribute rtc_attrs[] = { 98static struct device_attribute rtc_attrs[] = {
77 __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL), 99 __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
78 __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL), 100 __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
79 __ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL), 101 __ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL),
80 __ATTR(since_epoch, S_IRUGO, rtc_sysfs_show_since_epoch, NULL), 102 __ATTR(since_epoch, S_IRUGO, rtc_sysfs_show_since_epoch, NULL),
103 __ATTR(max_user_freq, S_IRUGO | S_IWUSR, rtc_sysfs_show_max_user_freq,
104 rtc_sysfs_set_max_user_freq),
81 { }, 105 { },
82}; 106};
83 107