aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-sysfs.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-05-08 03:33:30 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:18 -0400
commitab6a2d70d18edc7a716ef3127b9e13382faec98c (patch)
tree6de624dfcbd0181e54e21f1730d2a52ae9822c47 /drivers/rtc/rtc-sysfs.c
parent5726fb2012f0d96153113ddb7f988a0daea587ce (diff)
rtc: rtc interfaces don't use class_device
This patch removes class_device from the programming interface that the RTC framework exposes to the rest of the kernel. Now an rtc_device is passed, which is more type-safe and streamlines all the relevant code. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-By: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-sysfs.c')
-rw-r--r--drivers/rtc/rtc-sysfs.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 899ab8c514fa..97444b45cc26 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -12,6 +12,9 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14 14
15#include "rtc-core.h"
16
17
15/* device attributes */ 18/* device attributes */
16 19
17static ssize_t rtc_sysfs_show_name(struct class_device *dev, char *buf) 20static ssize_t rtc_sysfs_show_name(struct class_device *dev, char *buf)
@@ -25,7 +28,7 @@ static ssize_t rtc_sysfs_show_date(struct class_device *dev, char *buf)
25 ssize_t retval; 28 ssize_t retval;
26 struct rtc_time tm; 29 struct rtc_time tm;
27 30
28 retval = rtc_read_time(dev, &tm); 31 retval = rtc_read_time(to_rtc_device(dev), &tm);
29 if (retval == 0) { 32 if (retval == 0) {
30 retval = sprintf(buf, "%04d-%02d-%02d\n", 33 retval = sprintf(buf, "%04d-%02d-%02d\n",
31 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 34 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
@@ -40,7 +43,7 @@ static ssize_t rtc_sysfs_show_time(struct class_device *dev, char *buf)
40 ssize_t retval; 43 ssize_t retval;
41 struct rtc_time tm; 44 struct rtc_time tm;
42 45
43 retval = rtc_read_time(dev, &tm); 46 retval = rtc_read_time(to_rtc_device(dev), &tm);
44 if (retval == 0) { 47 if (retval == 0) {
45 retval = sprintf(buf, "%02d:%02d:%02d\n", 48 retval = sprintf(buf, "%02d:%02d:%02d\n",
46 tm.tm_hour, tm.tm_min, tm.tm_sec); 49 tm.tm_hour, tm.tm_min, tm.tm_sec);
@@ -55,7 +58,7 @@ static ssize_t rtc_sysfs_show_since_epoch(struct class_device *dev, char *buf)
55 ssize_t retval; 58 ssize_t retval;
56 struct rtc_time tm; 59 struct rtc_time tm;
57 60
58 retval = rtc_read_time(dev, &tm); 61 retval = rtc_read_time(to_rtc_device(dev), &tm);
59 if (retval == 0) { 62 if (retval == 0) {
60 unsigned long time; 63 unsigned long time;
61 rtc_tm_to_time(&tm, &time); 64 rtc_tm_to_time(&tm, &time);
@@ -94,7 +97,7 @@ rtc_sysfs_show_wakealarm(struct class_device *dev, char *buf)
94 * REVISIT maybe we should require RTC implementations to 97 * REVISIT maybe we should require RTC implementations to
95 * disable the RTC alarm after it triggers, for uniformity. 98 * disable the RTC alarm after it triggers, for uniformity.
96 */ 99 */
97 retval = rtc_read_alarm(dev, &alm); 100 retval = rtc_read_alarm(to_rtc_device(dev), &alm);
98 if (retval == 0 && alm.enabled) { 101 if (retval == 0 && alm.enabled) {
99 rtc_tm_to_time(&alm.time, &alarm); 102 rtc_tm_to_time(&alm.time, &alarm);
100 retval = sprintf(buf, "%lu\n", alarm); 103 retval = sprintf(buf, "%lu\n", alarm);
@@ -109,11 +112,12 @@ rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n)
109 ssize_t retval; 112 ssize_t retval;
110 unsigned long now, alarm; 113 unsigned long now, alarm;
111 struct rtc_wkalrm alm; 114 struct rtc_wkalrm alm;
115 struct rtc_device *rtc = to_rtc_device(dev);
112 116
113 /* Only request alarms that trigger in the future. Disable them 117 /* Only request alarms that trigger in the future. Disable them
114 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC. 118 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
115 */ 119 */
116 retval = rtc_read_time(dev, &alm.time); 120 retval = rtc_read_time(rtc, &alm.time);
117 if (retval < 0) 121 if (retval < 0)
118 return retval; 122 return retval;
119 rtc_tm_to_time(&alm.time, &now); 123 rtc_tm_to_time(&alm.time, &now);
@@ -124,7 +128,7 @@ rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n)
124 * entirely prevent that here, without even the minimal 128 * entirely prevent that here, without even the minimal
125 * locking from the /dev/rtcN api. 129 * locking from the /dev/rtcN api.
126 */ 130 */
127 retval = rtc_read_alarm(dev, &alm); 131 retval = rtc_read_alarm(rtc, &alm);
128 if (retval < 0) 132 if (retval < 0)
129 return retval; 133 return retval;
130 if (alm.enabled) 134 if (alm.enabled)
@@ -141,7 +145,7 @@ rtc_sysfs_set_wakealarm(struct class_device *dev, const char *buf, size_t n)
141 } 145 }
142 rtc_time_to_tm(alarm, &alm.time); 146 rtc_time_to_tm(alarm, &alm.time);
143 147
144 retval = rtc_set_alarm(dev, &alm); 148 retval = rtc_set_alarm(rtc, &alm);
145 return (retval < 0) ? retval : n; 149 return (retval < 0) ? retval : n;
146} 150}
147static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR, 151static const CLASS_DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR,