aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-sysfs.c')
-rw-r--r--drivers/rtc/rtc-sysfs.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 1c2fa0cc9cbb..69df94b44841 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -17,12 +17,16 @@
17 17
18/* device attributes */ 18/* device attributes */
19 19
20static ssize_t rtc_sysfs_show_name(struct class_device *dev, char *buf) 20static ssize_t
21rtc_sysfs_show_name(struct device *dev, struct device_attribute *attr,
22 char *buf)
21{ 23{
22 return sprintf(buf, "%s\n", to_rtc_device(dev)->name); 24 return sprintf(buf, "%s\n", to_rtc_device(dev)->name);
23} 25}
24 26
25static ssize_t rtc_sysfs_show_date(struct class_device *dev, char *buf) 27static ssize_t
28rtc_sysfs_show_date(struct device *dev, struct device_attribute *attr,
29 char *buf)
26{ 30{
27 ssize_t retval; 31 ssize_t retval;
28 struct rtc_time tm; 32 struct rtc_time tm;
@@ -36,7 +40,9 @@ static ssize_t rtc_sysfs_show_date(struct class_device *dev, char *buf)
36 return retval; 40 return retval;
37} 41}
38 42
39static ssize_t rtc_sysfs_show_time(struct class_device *dev, char *buf) 43static ssize_t
44rtc_sysfs_show_time(struct device *dev, struct device_attribute *attr,
45 char *buf)
40{ 46{
41 ssize_t retval; 47 ssize_t retval;
42 struct rtc_time tm; 48 struct rtc_time tm;
@@ -50,7 +56,9 @@ static ssize_t rtc_sysfs_show_time(struct class_device *dev, char *buf)
50 return retval; 56 return retval;
51} 57}
52 58
53static ssize_t rtc_sysfs_show_since_epoch(struct class_device *dev, char *buf) 59static ssize_t
60rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
61 char *buf)
54{ 62{
55 ssize_t retval; 63 ssize_t retval;
56 struct rtc_time tm; 64 struct rtc_time tm;
@@ -65,7 +73,7 @@ static ssize_t rtc_sysfs_show_since_epoch(struct class_device *dev, char *buf)
65 return retval; 73 return retval;
66} 74}
67 75
68static struct class_device_attribute rtc_attrs[] = { 76static struct device_attribute rtc_attrs[] = {
69 __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL), 77 __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
70 __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL), 78 __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
71 __ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL), 79 __ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL),
@@ -74,7 +82,8 @@ static struct class_device_attribute rtc_attrs[] = {
74}; 82};
75 83
76static ssize_t 84static ssize_t
77rtc_sysfs_show_wakealarm(struct class_device *dev, char *buf) 85rtc_sysfs_show_wakealarm(struct device *dev, struct device_attribute *attr,
86 char *buf)
78{ 87{
79 ssize_t retval; 88 ssize_t retval;
80 unsigned long alarm; 89 unsigned long alarm;
@@ -98,7 +107,8 @@ rtc_sysfs_show_wakealarm(struct class_device *dev, char *buf)
98} 107}
99 108
100static ssize_t 109static ssize_t
101rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n) 110rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
111 const char *buf, size_t n)
102{ 112{
103 ssize_t retval; 113 ssize_t retval;
104 unsigned long now, alarm; 114 unsigned long now, alarm;
@@ -139,7 +149,7 @@ rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n)
139 retval = rtc_set_alarm(rtc, &alm); 149 retval = rtc_set_alarm(rtc, &alm);
140 return (retval < 0) ? retval : n; 150 return (retval < 0) ? retval : n;
141} 151}
142static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR, 152static DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,
143 rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm); 153 rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm);
144 154
145 155
@@ -150,7 +160,7 @@ static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,
150 */ 160 */
151static inline int rtc_does_wakealarm(struct rtc_device *rtc) 161static inline int rtc_does_wakealarm(struct rtc_device *rtc)
152{ 162{
153 if (!device_can_wakeup(rtc->class_dev.dev)) 163 if (!device_can_wakeup(rtc->dev.parent))
154 return 0; 164 return 0;
155 return rtc->ops->set_alarm != NULL; 165 return rtc->ops->set_alarm != NULL;
156} 166}
@@ -164,10 +174,9 @@ void rtc_sysfs_add_device(struct rtc_device *rtc)
164 if (!rtc_does_wakealarm(rtc)) 174 if (!rtc_does_wakealarm(rtc))
165 return; 175 return;
166 176
167 err = class_device_create_file(&rtc->class_dev, 177 err = device_create_file(&rtc->dev, &dev_attr_wakealarm);
168 &class_device_attr_wakealarm);
169 if (err) 178 if (err)
170 dev_err(rtc->class_dev.dev, "failed to create " 179 dev_err(rtc->dev.parent, "failed to create "
171 "alarm attribute, %d", 180 "alarm attribute, %d",
172 err); 181 err);
173} 182}
@@ -176,11 +185,10 @@ void rtc_sysfs_del_device(struct rtc_device *rtc)
176{ 185{
177 /* REVISIT did we add it successfully? */ 186 /* REVISIT did we add it successfully? */
178 if (rtc_does_wakealarm(rtc)) 187 if (rtc_does_wakealarm(rtc))
179 class_device_remove_file(&rtc->class_dev, 188 device_remove_file(&rtc->dev, &dev_attr_wakealarm);
180 &class_device_attr_wakealarm);
181} 189}
182 190
183void __init rtc_sysfs_init(struct class *rtc_class) 191void __init rtc_sysfs_init(struct class *rtc_class)
184{ 192{
185 rtc_class->class_dev_attrs = rtc_attrs; 193 rtc_class->dev_attrs = rtc_attrs;
186} 194}