aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
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
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')
-rw-r--r--drivers/rtc/hctosys.c14
-rw-r--r--drivers/rtc/interface.c78
-rw-r--r--drivers/rtc/rtc-at91rm9200.c2
-rw-r--r--drivers/rtc/rtc-cmos.c12
-rw-r--r--drivers/rtc/rtc-core.h2
-rw-r--r--drivers/rtc/rtc-dev.c27
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-omap.c4
-rw-r--r--drivers/rtc/rtc-pl031.c2
-rw-r--r--drivers/rtc/rtc-proc.c19
-rw-r--r--drivers/rtc/rtc-s3c.c4
-rw-r--r--drivers/rtc/rtc-sa1100.c4
-rw-r--r--drivers/rtc/rtc-sh.c6
-rw-r--r--drivers/rtc/rtc-sysfs.c18
-rw-r--r--drivers/rtc/rtc-test.c6
-rw-r--r--drivers/rtc/rtc-vr41xx.c4
16 files changed, 103 insertions, 101 deletions
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index d02fe9a0001f..f48a8aed5b0f 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -26,15 +26,15 @@ static int __init rtc_hctosys(void)
26{ 26{
27 int err; 27 int err;
28 struct rtc_time tm; 28 struct rtc_time tm;
29 struct class_device *class_dev = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); 29 struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
30 30
31 if (class_dev == NULL) { 31 if (rtc == NULL) {
32 printk("%s: unable to open rtc device (%s)\n", 32 printk("%s: unable to open rtc device (%s)\n",
33 __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); 33 __FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
34 return -ENODEV; 34 return -ENODEV;
35 } 35 }
36 36
37 err = rtc_read_time(class_dev, &tm); 37 err = rtc_read_time(rtc, &tm);
38 if (err == 0) { 38 if (err == 0) {
39 err = rtc_valid_tm(&tm); 39 err = rtc_valid_tm(&tm);
40 if (err == 0) { 40 if (err == 0) {
@@ -46,7 +46,7 @@ static int __init rtc_hctosys(void)
46 46
47 do_settimeofday(&tv); 47 do_settimeofday(&tv);
48 48
49 dev_info(class_dev->dev, 49 dev_info(rtc->class_dev.dev,
50 "setting the system clock to " 50 "setting the system clock to "
51 "%d-%02d-%02d %02d:%02d:%02d (%u)\n", 51 "%d-%02d-%02d %02d:%02d:%02d (%u)\n",
52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
@@ -54,14 +54,14 @@ static int __init rtc_hctosys(void)
54 (unsigned int) tv.tv_sec); 54 (unsigned int) tv.tv_sec);
55 } 55 }
56 else 56 else
57 dev_err(class_dev->dev, 57 dev_err(rtc->class_dev.dev,
58 "hctosys: invalid date/time\n"); 58 "hctosys: invalid date/time\n");
59 } 59 }
60 else 60 else
61 dev_err(class_dev->dev, 61 dev_err(rtc->class_dev.dev,
62 "hctosys: unable to read the hardware clock\n"); 62 "hctosys: unable to read the hardware clock\n");
63 63
64 rtc_class_close(class_dev); 64 rtc_class_close(rtc);
65 65
66 return 0; 66 return 0;
67} 67}
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index ef40df0f169d..d9d326ff6253 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -13,10 +13,9 @@
13 13
14#include <linux/rtc.h> 14#include <linux/rtc.h>
15 15
16int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm) 16int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
17{ 17{
18 int err; 18 int err;
19 struct rtc_device *rtc = to_rtc_device(class_dev);
20 19
21 err = mutex_lock_interruptible(&rtc->ops_lock); 20 err = mutex_lock_interruptible(&rtc->ops_lock);
22 if (err) 21 if (err)
@@ -28,7 +27,7 @@ int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm)
28 err = -EINVAL; 27 err = -EINVAL;
29 else { 28 else {
30 memset(tm, 0, sizeof(struct rtc_time)); 29 memset(tm, 0, sizeof(struct rtc_time));
31 err = rtc->ops->read_time(class_dev->dev, tm); 30 err = rtc->ops->read_time(rtc->class_dev.dev, tm);
32 } 31 }
33 32
34 mutex_unlock(&rtc->ops_lock); 33 mutex_unlock(&rtc->ops_lock);
@@ -36,10 +35,9 @@ int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm)
36} 35}
37EXPORT_SYMBOL_GPL(rtc_read_time); 36EXPORT_SYMBOL_GPL(rtc_read_time);
38 37
39int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm) 38int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
40{ 39{
41 int err; 40 int err;
42 struct rtc_device *rtc = to_rtc_device(class_dev);
43 41
44 err = rtc_valid_tm(tm); 42 err = rtc_valid_tm(tm);
45 if (err != 0) 43 if (err != 0)
@@ -54,17 +52,16 @@ int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm)
54 else if (!rtc->ops->set_time) 52 else if (!rtc->ops->set_time)
55 err = -EINVAL; 53 err = -EINVAL;
56 else 54 else
57 err = rtc->ops->set_time(class_dev->dev, tm); 55 err = rtc->ops->set_time(rtc->class_dev.dev, tm);
58 56
59 mutex_unlock(&rtc->ops_lock); 57 mutex_unlock(&rtc->ops_lock);
60 return err; 58 return err;
61} 59}
62EXPORT_SYMBOL_GPL(rtc_set_time); 60EXPORT_SYMBOL_GPL(rtc_set_time);
63 61
64int rtc_set_mmss(struct class_device *class_dev, unsigned long secs) 62int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
65{ 63{
66 int err; 64 int err;
67 struct rtc_device *rtc = to_rtc_device(class_dev);
68 65
69 err = mutex_lock_interruptible(&rtc->ops_lock); 66 err = mutex_lock_interruptible(&rtc->ops_lock);
70 if (err) 67 if (err)
@@ -73,11 +70,11 @@ int rtc_set_mmss(struct class_device *class_dev, unsigned long secs)
73 if (!rtc->ops) 70 if (!rtc->ops)
74 err = -ENODEV; 71 err = -ENODEV;
75 else if (rtc->ops->set_mmss) 72 else if (rtc->ops->set_mmss)
76 err = rtc->ops->set_mmss(class_dev->dev, secs); 73 err = rtc->ops->set_mmss(rtc->class_dev.dev, secs);
77 else if (rtc->ops->read_time && rtc->ops->set_time) { 74 else if (rtc->ops->read_time && rtc->ops->set_time) {
78 struct rtc_time new, old; 75 struct rtc_time new, old;
79 76
80 err = rtc->ops->read_time(class_dev->dev, &old); 77 err = rtc->ops->read_time(rtc->class_dev.dev, &old);
81 if (err == 0) { 78 if (err == 0) {
82 rtc_time_to_tm(secs, &new); 79 rtc_time_to_tm(secs, &new);
83 80
@@ -89,7 +86,8 @@ int rtc_set_mmss(struct class_device *class_dev, unsigned long secs)
89 */ 86 */
90 if (!((old.tm_hour == 23 && old.tm_min == 59) || 87 if (!((old.tm_hour == 23 && old.tm_min == 59) ||
91 (new.tm_hour == 23 && new.tm_min == 59))) 88 (new.tm_hour == 23 && new.tm_min == 59)))
92 err = rtc->ops->set_time(class_dev->dev, &new); 89 err = rtc->ops->set_time(rtc->class_dev.dev,
90 &new);
93 } 91 }
94 } 92 }
95 else 93 else
@@ -101,10 +99,9 @@ int rtc_set_mmss(struct class_device *class_dev, unsigned long secs)
101} 99}
102EXPORT_SYMBOL_GPL(rtc_set_mmss); 100EXPORT_SYMBOL_GPL(rtc_set_mmss);
103 101
104int rtc_read_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm) 102int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
105{ 103{
106 int err; 104 int err;
107 struct rtc_device *rtc = to_rtc_device(class_dev);
108 105
109 err = mutex_lock_interruptible(&rtc->ops_lock); 106 err = mutex_lock_interruptible(&rtc->ops_lock);
110 if (err) 107 if (err)
@@ -116,7 +113,7 @@ int rtc_read_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
116 err = -EINVAL; 113 err = -EINVAL;
117 else { 114 else {
118 memset(alarm, 0, sizeof(struct rtc_wkalrm)); 115 memset(alarm, 0, sizeof(struct rtc_wkalrm));
119 err = rtc->ops->read_alarm(class_dev->dev, alarm); 116 err = rtc->ops->read_alarm(rtc->class_dev.dev, alarm);
120 } 117 }
121 118
122 mutex_unlock(&rtc->ops_lock); 119 mutex_unlock(&rtc->ops_lock);
@@ -124,10 +121,9 @@ int rtc_read_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
124} 121}
125EXPORT_SYMBOL_GPL(rtc_read_alarm); 122EXPORT_SYMBOL_GPL(rtc_read_alarm);
126 123
127int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm) 124int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
128{ 125{
129 int err; 126 int err;
130 struct rtc_device *rtc = to_rtc_device(class_dev);
131 127
132 err = mutex_lock_interruptible(&rtc->ops_lock); 128 err = mutex_lock_interruptible(&rtc->ops_lock);
133 if (err) 129 if (err)
@@ -138,7 +134,7 @@ int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
138 else if (!rtc->ops->set_alarm) 134 else if (!rtc->ops->set_alarm)
139 err = -EINVAL; 135 err = -EINVAL;
140 else 136 else
141 err = rtc->ops->set_alarm(class_dev->dev, alarm); 137 err = rtc->ops->set_alarm(rtc->class_dev.dev, alarm);
142 138
143 mutex_unlock(&rtc->ops_lock); 139 mutex_unlock(&rtc->ops_lock);
144 return err; 140 return err;
@@ -147,16 +143,14 @@ EXPORT_SYMBOL_GPL(rtc_set_alarm);
147 143
148/** 144/**
149 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs 145 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
150 * @class_dev: the rtc's class device 146 * @rtc: the rtc device
151 * @num: how many irqs are being reported (usually one) 147 * @num: how many irqs are being reported (usually one)
152 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF 148 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
153 * Context: in_interrupt(), irqs blocked 149 * Context: in_interrupt(), irqs blocked
154 */ 150 */
155void rtc_update_irq(struct class_device *class_dev, 151void rtc_update_irq(struct rtc_device *rtc,
156 unsigned long num, unsigned long events) 152 unsigned long num, unsigned long events)
157{ 153{
158 struct rtc_device *rtc = to_rtc_device(class_dev);
159
160 spin_lock(&rtc->irq_lock); 154 spin_lock(&rtc->irq_lock);
161 rtc->irq_data = (rtc->irq_data + (num << 8)) | events; 155 rtc->irq_data = (rtc->irq_data + (num << 8)) | events;
162 spin_unlock(&rtc->irq_lock); 156 spin_unlock(&rtc->irq_lock);
@@ -171,40 +165,43 @@ void rtc_update_irq(struct class_device *class_dev,
171} 165}
172EXPORT_SYMBOL_GPL(rtc_update_irq); 166EXPORT_SYMBOL_GPL(rtc_update_irq);
173 167
174struct class_device *rtc_class_open(char *name) 168struct rtc_device *rtc_class_open(char *name)
175{ 169{
176 struct class_device *class_dev = NULL, 170 struct class_device *class_dev_tmp;
177 *class_dev_tmp; 171 struct rtc_device *rtc = NULL;
178 172
179 down(&rtc_class->sem); 173 down(&rtc_class->sem);
180 list_for_each_entry(class_dev_tmp, &rtc_class->children, node) { 174 list_for_each_entry(class_dev_tmp, &rtc_class->children, node) {
181 if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) { 175 if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) {
182 class_dev = class_device_get(class_dev_tmp); 176 class_dev_tmp = class_device_get(class_dev_tmp);
177 if (class_dev_tmp)
178 rtc = to_rtc_device(class_dev_tmp);
183 break; 179 break;
184 } 180 }
185 } 181 }
186 182
187 if (class_dev) { 183 if (rtc) {
188 if (!try_module_get(to_rtc_device(class_dev)->owner)) 184 if (!try_module_get(rtc->owner)) {
189 class_dev = NULL; 185 class_device_put(class_dev_tmp);
186 rtc = NULL;
187 }
190 } 188 }
191 up(&rtc_class->sem); 189 up(&rtc_class->sem);
192 190
193 return class_dev; 191 return rtc;
194} 192}
195EXPORT_SYMBOL_GPL(rtc_class_open); 193EXPORT_SYMBOL_GPL(rtc_class_open);
196 194
197void rtc_class_close(struct class_device *class_dev) 195void rtc_class_close(struct rtc_device *rtc)
198{ 196{
199 module_put(to_rtc_device(class_dev)->owner); 197 module_put(rtc->owner);
200 class_device_put(class_dev); 198 class_device_put(&rtc->class_dev);
201} 199}
202EXPORT_SYMBOL_GPL(rtc_class_close); 200EXPORT_SYMBOL_GPL(rtc_class_close);
203 201
204int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task) 202int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
205{ 203{
206 int retval = -EBUSY; 204 int retval = -EBUSY;
207 struct rtc_device *rtc = to_rtc_device(class_dev);
208 205
209 if (task == NULL || task->func == NULL) 206 if (task == NULL || task->func == NULL)
210 return -EINVAL; 207 return -EINVAL;
@@ -220,9 +217,8 @@ int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task)
220} 217}
221EXPORT_SYMBOL_GPL(rtc_irq_register); 218EXPORT_SYMBOL_GPL(rtc_irq_register);
222 219
223void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task) 220void rtc_irq_unregister(struct rtc_device *rtc, struct rtc_task *task)
224{ 221{
225 struct rtc_device *rtc = to_rtc_device(class_dev);
226 222
227 spin_lock_irq(&rtc->irq_task_lock); 223 spin_lock_irq(&rtc->irq_task_lock);
228 if (rtc->irq_task == task) 224 if (rtc->irq_task == task)
@@ -231,11 +227,10 @@ void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task)
231} 227}
232EXPORT_SYMBOL_GPL(rtc_irq_unregister); 228EXPORT_SYMBOL_GPL(rtc_irq_unregister);
233 229
234int rtc_irq_set_state(struct class_device *class_dev, struct rtc_task *task, int enabled) 230int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled)
235{ 231{
236 int err = 0; 232 int err = 0;
237 unsigned long flags; 233 unsigned long flags;
238 struct rtc_device *rtc = to_rtc_device(class_dev);
239 234
240 if (rtc->ops->irq_set_state == NULL) 235 if (rtc->ops->irq_set_state == NULL)
241 return -ENXIO; 236 return -ENXIO;
@@ -246,17 +241,16 @@ int rtc_irq_set_state(struct class_device *class_dev, struct rtc_task *task, int
246 spin_unlock_irqrestore(&rtc->irq_task_lock, flags); 241 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
247 242
248 if (err == 0) 243 if (err == 0)
249 err = rtc->ops->irq_set_state(class_dev->dev, enabled); 244 err = rtc->ops->irq_set_state(rtc->class_dev.dev, enabled);
250 245
251 return err; 246 return err;
252} 247}
253EXPORT_SYMBOL_GPL(rtc_irq_set_state); 248EXPORT_SYMBOL_GPL(rtc_irq_set_state);
254 249
255int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int freq) 250int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
256{ 251{
257 int err = 0; 252 int err = 0;
258 unsigned long flags; 253 unsigned long flags;
259 struct rtc_device *rtc = to_rtc_device(class_dev);
260 254
261 if (rtc->ops->irq_set_freq == NULL) 255 if (rtc->ops->irq_set_freq == NULL)
262 return -ENXIO; 256 return -ENXIO;
@@ -267,7 +261,7 @@ int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int
267 spin_unlock_irqrestore(&rtc->irq_task_lock, flags); 261 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
268 262
269 if (err == 0) { 263 if (err == 0) {
270 err = rtc->ops->irq_set_freq(class_dev->dev, freq); 264 err = rtc->ops->irq_set_freq(rtc->class_dev.dev, freq);
271 if (err == 0) 265 if (err == 0)
272 rtc->irq_freq = freq; 266 rtc->irq_freq = freq;
273 } 267 }
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index ac0e68e2f025..2f06b5f9fb7b 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -263,7 +263,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id)
263 263
264 at91_sys_write(AT91_RTC_SCCR, rtsr); /* clear status reg */ 264 at91_sys_write(AT91_RTC_SCCR, rtsr); /* clear status reg */
265 265
266 rtc_update_irq(&rtc->class_dev, 1, events); 266 rtc_update_irq(rtc, 1, events);
267 267
268 pr_debug("%s(): num=%ld, events=0x%02lx\n", __FUNCTION__, 268 pr_debug("%s(): num=%ld, events=0x%02lx\n", __FUNCTION__,
269 events >> 8, events & 0x000000FF); 269 events >> 8, events & 0x000000FF);
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 7c0d60910077..4b586ebb5814 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -203,7 +203,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
203 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 203 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
204 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; 204 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
205 if (is_intr(rtc_intr)) 205 if (is_intr(rtc_intr))
206 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 206 rtc_update_irq(cmos->rtc, 1, rtc_intr);
207 207
208 /* update alarm */ 208 /* update alarm */
209 CMOS_WRITE(hrs, RTC_HOURS_ALARM); 209 CMOS_WRITE(hrs, RTC_HOURS_ALARM);
@@ -223,7 +223,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
223 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 223 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
224 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; 224 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
225 if (is_intr(rtc_intr)) 225 if (is_intr(rtc_intr))
226 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 226 rtc_update_irq(cmos->rtc, 1, rtc_intr);
227 } 227 }
228 228
229 spin_unlock_irq(&rtc_lock); 229 spin_unlock_irq(&rtc_lock);
@@ -304,7 +304,7 @@ cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
304 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 304 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
305 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; 305 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
306 if (is_intr(rtc_intr)) 306 if (is_intr(rtc_intr))
307 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 307 rtc_update_irq(cmos->rtc, 1, rtc_intr);
308 spin_unlock_irqrestore(&rtc_lock, flags); 308 spin_unlock_irqrestore(&rtc_lock, flags);
309 return 0; 309 return 0;
310} 310}
@@ -471,7 +471,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
471 if (is_valid_irq(rtc_irq)) 471 if (is_valid_irq(rtc_irq))
472 retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED, 472 retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
473 cmos_rtc.rtc->class_dev.class_id, 473 cmos_rtc.rtc->class_dev.class_id,
474 &cmos_rtc.rtc->class_dev); 474 cmos_rtc.rtc);
475 if (retval < 0) { 475 if (retval < 0) {
476 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); 476 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
477 goto cleanup1; 477 goto cleanup1;
@@ -555,7 +555,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
555 irqstat = CMOS_READ(RTC_INTR_FLAGS); 555 irqstat = CMOS_READ(RTC_INTR_FLAGS);
556 irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF; 556 irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF;
557 if (is_intr(irqstat)) 557 if (is_intr(irqstat))
558 rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat); 558 rtc_update_irq(cmos->rtc, 1, irqstat);
559 } 559 }
560 spin_unlock_irq(&rtc_lock); 560 spin_unlock_irq(&rtc_lock);
561 561
@@ -590,7 +590,7 @@ static int cmos_resume(struct device *dev)
590 tmp = CMOS_READ(RTC_INTR_FLAGS); 590 tmp = CMOS_READ(RTC_INTR_FLAGS);
591 tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF; 591 tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF;
592 if (is_intr(tmp)) 592 if (is_intr(tmp))
593 rtc_update_irq(&cmos->rtc->class_dev, 1, tmp); 593 rtc_update_irq(cmos->rtc, 1, tmp);
594 spin_unlock_irq(&rtc_lock); 594 spin_unlock_irq(&rtc_lock);
595 } 595 }
596 596
diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index c3c495ed1869..c9891423a468 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -1,3 +1,5 @@
1extern int rtc_interface_register(struct class_interface *intf);
2
1#ifdef CONFIG_RTC_INTF_DEV 3#ifdef CONFIG_RTC_INTF_DEV
2 4
3extern void __init rtc_dev_init(void); 5extern void __init rtc_dev_init(void);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 3fa6138523b5..623cb8d06b02 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -32,7 +32,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
32 if (!(mutex_trylock(&rtc->char_lock))) 32 if (!(mutex_trylock(&rtc->char_lock)))
33 return -EBUSY; 33 return -EBUSY;
34 34
35 file->private_data = &rtc->class_dev; 35 file->private_data = rtc;
36 36
37 err = ops->open ? ops->open(rtc->class_dev.dev) : 0; 37 err = ops->open ? ops->open(rtc->class_dev.dev) : 0;
38 if (err == 0) { 38 if (err == 0) {
@@ -61,7 +61,7 @@ static void rtc_uie_task(struct work_struct *work)
61 int num = 0; 61 int num = 0;
62 int err; 62 int err;
63 63
64 err = rtc_read_time(&rtc->class_dev, &tm); 64 err = rtc_read_time(rtc, &tm);
65 65
66 local_irq_disable(); 66 local_irq_disable();
67 spin_lock(&rtc->irq_lock); 67 spin_lock(&rtc->irq_lock);
@@ -79,7 +79,7 @@ static void rtc_uie_task(struct work_struct *work)
79 } 79 }
80 spin_unlock(&rtc->irq_lock); 80 spin_unlock(&rtc->irq_lock);
81 if (num) 81 if (num)
82 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF); 82 rtc_update_irq(rtc, num, RTC_UF | RTC_IRQF);
83 local_irq_enable(); 83 local_irq_enable();
84} 84}
85static void rtc_uie_timer(unsigned long data) 85static void rtc_uie_timer(unsigned long data)
@@ -121,7 +121,7 @@ static int set_uie(struct rtc_device *rtc)
121 struct rtc_time tm; 121 struct rtc_time tm;
122 int err; 122 int err;
123 123
124 err = rtc_read_time(&rtc->class_dev, &tm); 124 err = rtc_read_time(rtc, &tm);
125 if (err) 125 if (err)
126 return err; 126 return err;
127 spin_lock_irq(&rtc->irq_lock); 127 spin_lock_irq(&rtc->irq_lock);
@@ -210,8 +210,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
210 unsigned int cmd, unsigned long arg) 210 unsigned int cmd, unsigned long arg)
211{ 211{
212 int err = 0; 212 int err = 0;
213 struct class_device *class_dev = file->private_data; 213 struct rtc_device *rtc = file->private_data;
214 struct rtc_device *rtc = to_rtc_device(class_dev);
215 const struct rtc_class_ops *ops = rtc->ops; 214 const struct rtc_class_ops *ops = rtc->ops;
216 struct rtc_time tm; 215 struct rtc_time tm;
217 struct rtc_wkalrm alarm; 216 struct rtc_wkalrm alarm;
@@ -252,7 +251,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
252 251
253 /* try the driver's ioctl interface */ 252 /* try the driver's ioctl interface */
254 if (ops->ioctl) { 253 if (ops->ioctl) {
255 err = ops->ioctl(class_dev->dev, cmd, arg); 254 err = ops->ioctl(rtc->class_dev.dev, cmd, arg);
256 if (err != -ENOIOCTLCMD) 255 if (err != -ENOIOCTLCMD)
257 return err; 256 return err;
258 } 257 }
@@ -264,7 +263,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
264 263
265 switch (cmd) { 264 switch (cmd) {
266 case RTC_ALM_READ: 265 case RTC_ALM_READ:
267 err = rtc_read_alarm(class_dev, &alarm); 266 err = rtc_read_alarm(rtc, &alarm);
268 if (err < 0) 267 if (err < 0)
269 return err; 268 return err;
270 269
@@ -284,11 +283,11 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
284 alarm.time.tm_wday = -1; 283 alarm.time.tm_wday = -1;
285 alarm.time.tm_yday = -1; 284 alarm.time.tm_yday = -1;
286 alarm.time.tm_isdst = -1; 285 alarm.time.tm_isdst = -1;
287 err = rtc_set_alarm(class_dev, &alarm); 286 err = rtc_set_alarm(rtc, &alarm);
288 break; 287 break;
289 288
290 case RTC_RD_TIME: 289 case RTC_RD_TIME:
291 err = rtc_read_time(class_dev, &tm); 290 err = rtc_read_time(rtc, &tm);
292 if (err < 0) 291 if (err < 0)
293 return err; 292 return err;
294 293
@@ -300,7 +299,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
300 if (copy_from_user(&tm, uarg, sizeof(tm))) 299 if (copy_from_user(&tm, uarg, sizeof(tm)))
301 return -EFAULT; 300 return -EFAULT;
302 301
303 err = rtc_set_time(class_dev, &tm); 302 err = rtc_set_time(rtc, &tm);
304 break; 303 break;
305 304
306 case RTC_IRQP_READ: 305 case RTC_IRQP_READ:
@@ -310,7 +309,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
310 309
311 case RTC_IRQP_SET: 310 case RTC_IRQP_SET:
312 if (ops->irq_set_freq) 311 if (ops->irq_set_freq)
313 err = rtc_irq_set_freq(class_dev, rtc->irq_task, arg); 312 err = rtc_irq_set_freq(rtc, rtc->irq_task, arg);
314 break; 313 break;
315 314
316#if 0 315#if 0
@@ -336,11 +335,11 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
336 if (copy_from_user(&alarm, uarg, sizeof(alarm))) 335 if (copy_from_user(&alarm, uarg, sizeof(alarm)))
337 return -EFAULT; 336 return -EFAULT;
338 337
339 err = rtc_set_alarm(class_dev, &alarm); 338 err = rtc_set_alarm(rtc, &alarm);
340 break; 339 break;
341 340
342 case RTC_WKALM_RD: 341 case RTC_WKALM_RD:
343 err = rtc_read_alarm(class_dev, &alarm); 342 err = rtc_read_alarm(rtc, &alarm);
344 if (err < 0) 343 if (err < 0)
345 return err; 344 return err;
346 345
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index e27176c0e18f..afa64c7fa2e2 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -203,7 +203,7 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
203 events |= RTC_UF; 203 events |= RTC_UF;
204 else 204 else
205 events |= RTC_AF; 205 events |= RTC_AF;
206 rtc_update_irq(&pdata->rtc->class_dev, 1, events); 206 rtc_update_irq(pdata->rtc, 1, events);
207 return IRQ_HANDLED; 207 return IRQ_HANDLED;
208} 208}
209 209
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 9de8d67f4f8d..4ca3a5182cdb 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -124,7 +124,7 @@ static void rtc_wait_not_busy(void)
124 /* now we have ~15 usec to read/write various registers */ 124 /* now we have ~15 usec to read/write various registers */
125} 125}
126 126
127static irqreturn_t rtc_irq(int irq, void *class_dev) 127static irqreturn_t rtc_irq(int irq, void *rtc)
128{ 128{
129 unsigned long events = 0; 129 unsigned long events = 0;
130 u8 irq_data; 130 u8 irq_data;
@@ -141,7 +141,7 @@ static irqreturn_t rtc_irq(int irq, void *class_dev)
141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT) 141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
142 events |= RTC_IRQF | RTC_UF; 142 events |= RTC_IRQF | RTC_UF;
143 143
144 rtc_update_irq(class_dev, 1, events); 144 rtc_update_irq(rtc, 1, events);
145 145
146 return IRQ_HANDLED; 146 return IRQ_HANDLED;
147} 147}
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index f13daa9fecaa..e4bf68ca96f7 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -51,7 +51,7 @@ static irqreturn_t pl031_interrupt(int irq, void *dev_id)
51{ 51{
52 struct rtc_device *rtc = dev_id; 52 struct rtc_device *rtc = dev_id;
53 53
54 rtc_update_irq(&rtc->class_dev, 1, RTC_AF); 54 rtc_update_irq(rtc, 1, RTC_AF);
55 55
56 return IRQ_HANDLED; 56 return IRQ_HANDLED;
57} 57}
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 1bd624fc685c..195be6587b30 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -16,18 +16,21 @@
16#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18 18
19#include "rtc-core.h"
20
21
19static struct class_device *rtc_dev = NULL; 22static struct class_device *rtc_dev = NULL;
20static DEFINE_MUTEX(rtc_lock); 23static DEFINE_MUTEX(rtc_lock);
21 24
22static int rtc_proc_show(struct seq_file *seq, void *offset) 25static int rtc_proc_show(struct seq_file *seq, void *offset)
23{ 26{
24 int err; 27 int err;
25 struct class_device *class_dev = seq->private; 28 struct rtc_device *rtc = seq->private;
26 const struct rtc_class_ops *ops = to_rtc_device(class_dev)->ops; 29 const struct rtc_class_ops *ops = rtc->ops;
27 struct rtc_wkalrm alrm; 30 struct rtc_wkalrm alrm;
28 struct rtc_time tm; 31 struct rtc_time tm;
29 32
30 err = rtc_read_time(class_dev, &tm); 33 err = rtc_read_time(rtc, &tm);
31 if (err == 0) { 34 if (err == 0) {
32 seq_printf(seq, 35 seq_printf(seq,
33 "rtc_time\t: %02d:%02d:%02d\n" 36 "rtc_time\t: %02d:%02d:%02d\n"
@@ -36,7 +39,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
36 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 39 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
37 } 40 }
38 41
39 err = rtc_read_alarm(class_dev, &alrm); 42 err = rtc_read_alarm(rtc, &alrm);
40 if (err == 0) { 43 if (err == 0) {
41 seq_printf(seq, "alrm_time\t: "); 44 seq_printf(seq, "alrm_time\t: ");
42 if ((unsigned int)alrm.time.tm_hour <= 24) 45 if ((unsigned int)alrm.time.tm_hour <= 24)
@@ -74,19 +77,19 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
74 seq_printf(seq, "24hr\t\t: yes\n"); 77 seq_printf(seq, "24hr\t\t: yes\n");
75 78
76 if (ops->proc) 79 if (ops->proc)
77 ops->proc(class_dev->dev, seq); 80 ops->proc(rtc->class_dev.dev, seq);
78 81
79 return 0; 82 return 0;
80} 83}
81 84
82static int rtc_proc_open(struct inode *inode, struct file *file) 85static int rtc_proc_open(struct inode *inode, struct file *file)
83{ 86{
84 struct class_device *class_dev = PDE(inode)->data; 87 struct rtc_device *rtc = PDE(inode)->data;
85 88
86 if (!try_module_get(THIS_MODULE)) 89 if (!try_module_get(THIS_MODULE))
87 return -ENODEV; 90 return -ENODEV;
88 91
89 return single_open(file, rtc_proc_show, class_dev); 92 return single_open(file, rtc_proc_show, rtc);
90} 93}
91 94
92static int rtc_proc_release(struct inode *inode, struct file *file) 95static int rtc_proc_release(struct inode *inode, struct file *file)
@@ -118,7 +121,7 @@ static int rtc_proc_add_device(struct class_device *class_dev,
118 121
119 ent->proc_fops = &rtc_proc_fops; 122 ent->proc_fops = &rtc_proc_fops;
120 ent->owner = rtc->owner; 123 ent->owner = rtc->owner;
121 ent->data = class_dev; 124 ent->data = rtc;
122 125
123 dev_dbg(class_dev->dev, "rtc intf: proc\n"); 126 dev_dbg(class_dev->dev, "rtc intf: proc\n");
124 } 127 }
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 9a79a24a7487..3617c970caaa 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -50,7 +50,7 @@ static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
50{ 50{
51 struct rtc_device *rdev = id; 51 struct rtc_device *rdev = id;
52 52
53 rtc_update_irq(&rdev->class_dev, 1, RTC_AF | RTC_IRQF); 53 rtc_update_irq(rdev, 1, RTC_AF | RTC_IRQF);
54 return IRQ_HANDLED; 54 return IRQ_HANDLED;
55} 55}
56 56
@@ -58,7 +58,7 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
58{ 58{
59 struct rtc_device *rdev = id; 59 struct rtc_device *rdev = id;
60 60
61 rtc_update_irq(&rdev->class_dev, tick_count++, RTC_PF | RTC_IRQF); 61 rtc_update_irq(rdev, tick_count++, RTC_PF | RTC_IRQF);
62 return IRQ_HANDLED; 62 return IRQ_HANDLED;
63} 63}
64 64
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 677bae820dc3..0918b787c4dd 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -93,7 +93,7 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
93 if (rtsr & RTSR_HZ) 93 if (rtsr & RTSR_HZ)
94 events |= RTC_UF | RTC_IRQF; 94 events |= RTC_UF | RTC_IRQF;
95 95
96 rtc_update_irq(&rtc->class_dev, 1, events); 96 rtc_update_irq(rtc, 1, events);
97 97
98 if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm)) 98 if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm))
99 rtc_update_alarm(&rtc_alarm); 99 rtc_update_alarm(&rtc_alarm);
@@ -119,7 +119,7 @@ static irqreturn_t timer1_interrupt(int irq, void *dev_id)
119 */ 119 */
120 OSSR = OSSR_M1; /* clear match on timer1 */ 120 OSSR = OSSR_M1; /* clear match on timer1 */
121 121
122 rtc_update_irq(&rtc->class_dev, rtc_timer1_count, RTC_PF | RTC_IRQF); 122 rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF);
123 123
124 if (rtc_timer1_count == 1) 124 if (rtc_timer1_count == 1)
125 rtc_timer1_count = (rtc_freq * ((1<<30)/(TIMER_FREQ>>2))); 125 rtc_timer1_count = (rtc_freq * ((1<<30)/(TIMER_FREQ>>2)));
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 198b9f22fbff..6abf4811958c 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -104,7 +104,7 @@ static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
104 104
105 writeb(tmp, rtc->regbase + RCR1); 105 writeb(tmp, rtc->regbase + RCR1);
106 106
107 rtc_update_irq(&rtc->rtc_dev->class_dev, 1, events); 107 rtc_update_irq(&rtc->rtc_dev, 1, events);
108 108
109 spin_unlock(&rtc->lock); 109 spin_unlock(&rtc->lock);
110 110
@@ -139,7 +139,7 @@ static irqreturn_t sh_rtc_alarm(int irq, void *dev_id)
139 139
140 rtc->rearm_aie = 1; 140 rtc->rearm_aie = 1;
141 141
142 rtc_update_irq(&rtc->rtc_dev->class_dev, 1, events); 142 rtc_update_irq(&rtc->rtc_dev, 1, events);
143 } 143 }
144 144
145 spin_unlock(&rtc->lock); 145 spin_unlock(&rtc->lock);
@@ -153,7 +153,7 @@ static irqreturn_t sh_rtc_periodic(int irq, void *dev_id)
153 153
154 spin_lock(&rtc->lock); 154 spin_lock(&rtc->lock);
155 155
156 rtc_update_irq(&rtc->rtc_dev->class_dev, 1, RTC_PF | RTC_IRQF); 156 rtc_update_irq(&rtc->rtc_dev, 1, RTC_PF | RTC_IRQF);
157 157
158 spin_unlock(&rtc->lock); 158 spin_unlock(&rtc->lock);
159 159
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,
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index f50a1b8e1607..254c9fce27da 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -101,11 +101,11 @@ static ssize_t test_irq_store(struct device *dev,
101 retval = count; 101 retval = count;
102 local_irq_disable(); 102 local_irq_disable();
103 if (strncmp(buf, "tick", 4) == 0) 103 if (strncmp(buf, "tick", 4) == 0)
104 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF); 104 rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF);
105 else if (strncmp(buf, "alarm", 5) == 0) 105 else if (strncmp(buf, "alarm", 5) == 0)
106 rtc_update_irq(&rtc->class_dev, 1, RTC_AF | RTC_IRQF); 106 rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF);
107 else if (strncmp(buf, "update", 6) == 0) 107 else if (strncmp(buf, "update", 6) == 0)
108 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF); 108 rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF);
109 else 109 else
110 retval = -EINVAL; 110 retval = -EINVAL;
111 local_irq_enable(); 111 local_irq_enable();
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index e40322b71938..e9f9c5489468 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -275,7 +275,7 @@ static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id)
275 275
276 rtc2_write(RTCINTREG, ELAPSEDTIME_INT); 276 rtc2_write(RTCINTREG, ELAPSEDTIME_INT);
277 277
278 rtc_update_irq(&rtc->class_dev, 1, RTC_AF); 278 rtc_update_irq(rtc, 1, RTC_AF);
279 279
280 return IRQ_HANDLED; 280 return IRQ_HANDLED;
281} 281}
@@ -291,7 +291,7 @@ static irqreturn_t rtclong1_interrupt(int irq, void *dev_id)
291 rtc1_write(RTCL1LREG, count); 291 rtc1_write(RTCL1LREG, count);
292 rtc1_write(RTCL1HREG, count >> 16); 292 rtc1_write(RTCL1HREG, count >> 16);
293 293
294 rtc_update_irq(&rtc->class_dev, 1, RTC_PF); 294 rtc_update_irq(rtc, 1, RTC_PF);
295 295
296 return IRQ_HANDLED; 296 return IRQ_HANDLED;
297} 297}