diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 6 | ||||
-rw-r--r-- | drivers/rtc/interface.c | 54 | ||||
-rw-r--r-- | drivers/rtc/rtc-at91sam9.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-dev.c | 51 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1672.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-isl1208.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-max6900.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rtc-starfire.c | 66 | ||||
-rw-r--r-- | drivers/rtc/rtc-twl4030.c | 2 |
11 files changed, 136 insertions, 77 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 123092d8a984..165a81843357 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -102,9 +102,13 @@ config RTC_INTF_DEV_UIE_EMUL | |||
102 | depends on RTC_INTF_DEV | 102 | depends on RTC_INTF_DEV |
103 | help | 103 | help |
104 | Provides an emulation for RTC_UIE if the underlying rtc chip | 104 | Provides an emulation for RTC_UIE if the underlying rtc chip |
105 | driver does not expose RTC_UIE ioctls. Those requests generate | 105 | driver does not expose RTC_UIE ioctls. Those requests generate |
106 | once-per-second update interrupts, used for synchronization. | 106 | once-per-second update interrupts, used for synchronization. |
107 | 107 | ||
108 | The emulation code will read the time from the hardware | ||
109 | clock several times per second, please enable this option | ||
110 | only if you know that you really need it. | ||
111 | |||
108 | config RTC_DRV_TEST | 112 | config RTC_DRV_TEST |
109 | tristate "Test driver/device" | 113 | tristate "Test driver/device" |
110 | help | 114 | help |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index a04c1b6b1575..fd2c652504ff 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -307,6 +307,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
307 | } | 307 | } |
308 | EXPORT_SYMBOL_GPL(rtc_set_alarm); | 308 | EXPORT_SYMBOL_GPL(rtc_set_alarm); |
309 | 309 | ||
310 | int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) | ||
311 | { | ||
312 | int err = mutex_lock_interruptible(&rtc->ops_lock); | ||
313 | if (err) | ||
314 | return err; | ||
315 | |||
316 | if (!rtc->ops) | ||
317 | err = -ENODEV; | ||
318 | else if (!rtc->ops->alarm_irq_enable) | ||
319 | err = -EINVAL; | ||
320 | else | ||
321 | err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled); | ||
322 | |||
323 | mutex_unlock(&rtc->ops_lock); | ||
324 | return err; | ||
325 | } | ||
326 | EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable); | ||
327 | |||
328 | int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) | ||
329 | { | ||
330 | int err = mutex_lock_interruptible(&rtc->ops_lock); | ||
331 | if (err) | ||
332 | return err; | ||
333 | |||
334 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | ||
335 | if (enabled == 0 && rtc->uie_irq_active) { | ||
336 | mutex_unlock(&rtc->ops_lock); | ||
337 | return rtc_dev_update_irq_enable_emul(rtc, enabled); | ||
338 | } | ||
339 | #endif | ||
340 | |||
341 | if (!rtc->ops) | ||
342 | err = -ENODEV; | ||
343 | else if (!rtc->ops->update_irq_enable) | ||
344 | err = -EINVAL; | ||
345 | else | ||
346 | err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled); | ||
347 | |||
348 | mutex_unlock(&rtc->ops_lock); | ||
349 | |||
350 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | ||
351 | /* | ||
352 | * Enable emulation if the driver did not provide | ||
353 | * the update_irq_enable function pointer or if returned | ||
354 | * -EINVAL to signal that it has been configured without | ||
355 | * interrupts or that are not available at the moment. | ||
356 | */ | ||
357 | if (err == -EINVAL) | ||
358 | err = rtc_dev_update_irq_enable_emul(rtc, enabled); | ||
359 | #endif | ||
360 | return err; | ||
361 | } | ||
362 | EXPORT_SYMBOL_GPL(rtc_update_irq_enable); | ||
363 | |||
310 | /** | 364 | /** |
311 | * rtc_update_irq - report RTC periodic, alarm, and/or update irqs | 365 | * rtc_update_irq - report RTC periodic, alarm, and/or update irqs |
312 | * @rtc: the rtc device | 366 | * @rtc: the rtc device |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 2133f37906f2..d5e4e637ddec 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <mach/board.h> | 22 | #include <mach/board.h> |
23 | #include <mach/at91_rtt.h> | 23 | #include <mach/at91_rtt.h> |
24 | #include <mach/cpu.h> | ||
24 | 25 | ||
25 | 26 | ||
26 | /* | 27 | /* |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index ecdea44ae4e5..45152f4952d6 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -92,10 +92,10 @@ static void rtc_uie_timer(unsigned long data) | |||
92 | spin_unlock_irqrestore(&rtc->irq_lock, flags); | 92 | spin_unlock_irqrestore(&rtc->irq_lock, flags); |
93 | } | 93 | } |
94 | 94 | ||
95 | static void clear_uie(struct rtc_device *rtc) | 95 | static int clear_uie(struct rtc_device *rtc) |
96 | { | 96 | { |
97 | spin_lock_irq(&rtc->irq_lock); | 97 | spin_lock_irq(&rtc->irq_lock); |
98 | if (rtc->irq_active) { | 98 | if (rtc->uie_irq_active) { |
99 | rtc->stop_uie_polling = 1; | 99 | rtc->stop_uie_polling = 1; |
100 | if (rtc->uie_timer_active) { | 100 | if (rtc->uie_timer_active) { |
101 | spin_unlock_irq(&rtc->irq_lock); | 101 | spin_unlock_irq(&rtc->irq_lock); |
@@ -108,9 +108,10 @@ static void clear_uie(struct rtc_device *rtc) | |||
108 | flush_scheduled_work(); | 108 | flush_scheduled_work(); |
109 | spin_lock_irq(&rtc->irq_lock); | 109 | spin_lock_irq(&rtc->irq_lock); |
110 | } | 110 | } |
111 | rtc->irq_active = 0; | 111 | rtc->uie_irq_active = 0; |
112 | } | 112 | } |
113 | spin_unlock_irq(&rtc->irq_lock); | 113 | spin_unlock_irq(&rtc->irq_lock); |
114 | return 0; | ||
114 | } | 115 | } |
115 | 116 | ||
116 | static int set_uie(struct rtc_device *rtc) | 117 | static int set_uie(struct rtc_device *rtc) |
@@ -122,8 +123,8 @@ static int set_uie(struct rtc_device *rtc) | |||
122 | if (err) | 123 | if (err) |
123 | return err; | 124 | return err; |
124 | spin_lock_irq(&rtc->irq_lock); | 125 | spin_lock_irq(&rtc->irq_lock); |
125 | if (!rtc->irq_active) { | 126 | if (!rtc->uie_irq_active) { |
126 | rtc->irq_active = 1; | 127 | rtc->uie_irq_active = 1; |
127 | rtc->stop_uie_polling = 0; | 128 | rtc->stop_uie_polling = 0; |
128 | rtc->oldsecs = tm.tm_sec; | 129 | rtc->oldsecs = tm.tm_sec; |
129 | rtc->uie_task_active = 1; | 130 | rtc->uie_task_active = 1; |
@@ -134,6 +135,16 @@ static int set_uie(struct rtc_device *rtc) | |||
134 | spin_unlock_irq(&rtc->irq_lock); | 135 | spin_unlock_irq(&rtc->irq_lock); |
135 | return 0; | 136 | return 0; |
136 | } | 137 | } |
138 | |||
139 | int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, unsigned int enabled) | ||
140 | { | ||
141 | if (enabled) | ||
142 | return set_uie(rtc); | ||
143 | else | ||
144 | return clear_uie(rtc); | ||
145 | } | ||
146 | EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul); | ||
147 | |||
137 | #endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */ | 148 | #endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */ |
138 | 149 | ||
139 | static ssize_t | 150 | static ssize_t |
@@ -357,6 +368,22 @@ static long rtc_dev_ioctl(struct file *file, | |||
357 | err = rtc_irq_set_state(rtc, NULL, 0); | 368 | err = rtc_irq_set_state(rtc, NULL, 0); |
358 | break; | 369 | break; |
359 | 370 | ||
371 | case RTC_AIE_ON: | ||
372 | mutex_unlock(&rtc->ops_lock); | ||
373 | return rtc_alarm_irq_enable(rtc, 1); | ||
374 | |||
375 | case RTC_AIE_OFF: | ||
376 | mutex_unlock(&rtc->ops_lock); | ||
377 | return rtc_alarm_irq_enable(rtc, 0); | ||
378 | |||
379 | case RTC_UIE_ON: | ||
380 | mutex_unlock(&rtc->ops_lock); | ||
381 | return rtc_update_irq_enable(rtc, 1); | ||
382 | |||
383 | case RTC_UIE_OFF: | ||
384 | mutex_unlock(&rtc->ops_lock); | ||
385 | return rtc_update_irq_enable(rtc, 0); | ||
386 | |||
360 | case RTC_IRQP_SET: | 387 | case RTC_IRQP_SET: |
361 | err = rtc_irq_set_freq(rtc, NULL, arg); | 388 | err = rtc_irq_set_freq(rtc, NULL, arg); |
362 | break; | 389 | break; |
@@ -401,17 +428,6 @@ static long rtc_dev_ioctl(struct file *file, | |||
401 | err = -EFAULT; | 428 | err = -EFAULT; |
402 | return err; | 429 | return err; |
403 | 430 | ||
404 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | ||
405 | case RTC_UIE_OFF: | ||
406 | mutex_unlock(&rtc->ops_lock); | ||
407 | clear_uie(rtc); | ||
408 | return 0; | ||
409 | |||
410 | case RTC_UIE_ON: | ||
411 | mutex_unlock(&rtc->ops_lock); | ||
412 | err = set_uie(rtc); | ||
413 | return err; | ||
414 | #endif | ||
415 | default: | 431 | default: |
416 | err = -ENOTTY; | 432 | err = -ENOTTY; |
417 | break; | 433 | break; |
@@ -440,7 +456,10 @@ static int rtc_dev_release(struct inode *inode, struct file *file) | |||
440 | * Leave the alarm alone; it may be set to trigger a system wakeup | 456 | * Leave the alarm alone; it may be set to trigger a system wakeup |
441 | * later, or be used by kernel code, and is a one-shot event anyway. | 457 | * later, or be used by kernel code, and is a one-shot event anyway. |
442 | */ | 458 | */ |
459 | |||
460 | /* Keep ioctl until all drivers are converted */ | ||
443 | rtc_dev_ioctl(file, RTC_UIE_OFF, 0); | 461 | rtc_dev_ioctl(file, RTC_UIE_OFF, 0); |
462 | rtc_update_irq_enable(rtc, 0); | ||
444 | rtc_irq_set_state(rtc, NULL, 0); | 463 | rtc_irq_set_state(rtc, NULL, 0); |
445 | 464 | ||
446 | if (rtc->ops->release) | 465 | if (rtc->ops->release) |
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 341d7a5b45a2..4e91419e8911 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -209,12 +209,18 @@ static int ds1672_probe(struct i2c_client *client, | |||
209 | return err; | 209 | return err; |
210 | } | 210 | } |
211 | 211 | ||
212 | static struct i2c_device_id ds1672_id[] = { | ||
213 | { "ds1672", 0 }, | ||
214 | { } | ||
215 | }; | ||
216 | |||
212 | static struct i2c_driver ds1672_driver = { | 217 | static struct i2c_driver ds1672_driver = { |
213 | .driver = { | 218 | .driver = { |
214 | .name = "rtc-ds1672", | 219 | .name = "rtc-ds1672", |
215 | }, | 220 | }, |
216 | .probe = &ds1672_probe, | 221 | .probe = &ds1672_probe, |
217 | .remove = &ds1672_remove, | 222 | .remove = &ds1672_remove, |
223 | .id_table = ds1672_id, | ||
218 | }; | 224 | }; |
219 | 225 | ||
220 | static int __init ds1672_init(void) | 226 | static int __init ds1672_init(void) |
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 2cd77ab8fc66..054e05294af8 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -328,6 +328,13 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) | |||
328 | int sr; | 328 | int sr; |
329 | u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; | 329 | u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; |
330 | 330 | ||
331 | /* The clock has an 8 bit wide bcd-coded register (they never learn) | ||
332 | * for the year. tm_year is an offset from 1900 and we are interested | ||
333 | * in the 2000-2099 range, so any value less than 100 is invalid. | ||
334 | */ | ||
335 | if (tm->tm_year < 100) | ||
336 | return -EINVAL; | ||
337 | |||
331 | regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); | 338 | regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); |
332 | regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); | 339 | regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); |
333 | regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL; | 340 | regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL; |
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 80782798763f..a4f6665ab3c5 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c | |||
@@ -247,12 +247,18 @@ max6900_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | static struct i2c_device_id max6900_id[] = { | ||
251 | { "max6900", 0 }, | ||
252 | { } | ||
253 | }; | ||
254 | |||
250 | static struct i2c_driver max6900_driver = { | 255 | static struct i2c_driver max6900_driver = { |
251 | .driver = { | 256 | .driver = { |
252 | .name = "rtc-max6900", | 257 | .name = "rtc-max6900", |
253 | }, | 258 | }, |
254 | .probe = max6900_probe, | 259 | .probe = max6900_probe, |
255 | .remove = max6900_remove, | 260 | .remove = max6900_remove, |
261 | .id_table = max6900_id, | ||
256 | }; | 262 | }; |
257 | 263 | ||
258 | static int __init max6900_init(void) | 264 | static int __init max6900_init(void) |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index f59277bbedaa..7a568beba3f0 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
27 | #include <asm/io.h> | 27 | #include <asm/io.h> |
28 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
29 | #include <asm/plat-s3c/regs-rtc.h> | 29 | #include <plat/regs-rtc.h> |
30 | 30 | ||
31 | /* I have yet to find an S3C implementation with more than one | 31 | /* I have yet to find an S3C implementation with more than one |
32 | * of these rtc blocks in */ | 32 | * of these rtc blocks in */ |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 66a9bb85bbe8..d26a5f82aaba 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -38,11 +38,11 @@ | |||
38 | #include <mach/pxa-regs.h> | 38 | #include <mach/pxa-regs.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #define TIMER_FREQ CLOCK_TICK_RATE | ||
42 | #define RTC_DEF_DIVIDER 32768 - 1 | 41 | #define RTC_DEF_DIVIDER 32768 - 1 |
43 | #define RTC_DEF_TRIM 0 | 42 | #define RTC_DEF_TRIM 0 |
44 | 43 | ||
45 | static unsigned long rtc_freq = 1024; | 44 | static unsigned long rtc_freq = 1024; |
45 | static unsigned long timer_freq; | ||
46 | static struct rtc_time rtc_alarm; | 46 | static struct rtc_time rtc_alarm; |
47 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 47 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
48 | 48 | ||
@@ -157,7 +157,7 @@ static irqreturn_t timer1_interrupt(int irq, void *dev_id) | |||
157 | rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF); | 157 | rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF); |
158 | 158 | ||
159 | if (rtc_timer1_count == 1) | 159 | if (rtc_timer1_count == 1) |
160 | rtc_timer1_count = (rtc_freq * ((1<<30)/(TIMER_FREQ>>2))); | 160 | rtc_timer1_count = (rtc_freq * ((1 << 30) / (timer_freq >> 2))); |
161 | 161 | ||
162 | return IRQ_HANDLED; | 162 | return IRQ_HANDLED; |
163 | } | 163 | } |
@@ -166,7 +166,7 @@ static int sa1100_rtc_read_callback(struct device *dev, int data) | |||
166 | { | 166 | { |
167 | if (data & RTC_PF) { | 167 | if (data & RTC_PF) { |
168 | /* interpolate missed periods and set match for the next */ | 168 | /* interpolate missed periods and set match for the next */ |
169 | unsigned long period = TIMER_FREQ/rtc_freq; | 169 | unsigned long period = timer_freq / rtc_freq; |
170 | unsigned long oscr = OSCR; | 170 | unsigned long oscr = OSCR; |
171 | unsigned long osmr1 = OSMR1; | 171 | unsigned long osmr1 = OSMR1; |
172 | unsigned long missed = (oscr - osmr1)/period; | 172 | unsigned long missed = (oscr - osmr1)/period; |
@@ -263,7 +263,7 @@ static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
263 | return 0; | 263 | return 0; |
264 | case RTC_PIE_ON: | 264 | case RTC_PIE_ON: |
265 | spin_lock_irq(&sa1100_rtc_lock); | 265 | spin_lock_irq(&sa1100_rtc_lock); |
266 | OSMR1 = TIMER_FREQ/rtc_freq + OSCR; | 266 | OSMR1 = timer_freq / rtc_freq + OSCR; |
267 | OIER |= OIER_E1; | 267 | OIER |= OIER_E1; |
268 | rtc_timer1_count = 1; | 268 | rtc_timer1_count = 1; |
269 | spin_unlock_irq(&sa1100_rtc_lock); | 269 | spin_unlock_irq(&sa1100_rtc_lock); |
@@ -271,7 +271,7 @@ static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
271 | case RTC_IRQP_READ: | 271 | case RTC_IRQP_READ: |
272 | return put_user(rtc_freq, (unsigned long *)arg); | 272 | return put_user(rtc_freq, (unsigned long *)arg); |
273 | case RTC_IRQP_SET: | 273 | case RTC_IRQP_SET: |
274 | if (arg < 1 || arg > TIMER_FREQ) | 274 | if (arg < 1 || arg > timer_freq) |
275 | return -EINVAL; | 275 | return -EINVAL; |
276 | rtc_freq = arg; | 276 | rtc_freq = arg; |
277 | return 0; | 277 | return 0; |
@@ -352,6 +352,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
352 | { | 352 | { |
353 | struct rtc_device *rtc; | 353 | struct rtc_device *rtc; |
354 | 354 | ||
355 | timer_freq = get_clock_tick_rate(); | ||
356 | |||
355 | /* | 357 | /* |
356 | * According to the manual we should be able to let RTTR be zero | 358 | * According to the manual we should be able to let RTTR be zero |
357 | * and then a default diviser for a 32.768KHz clock is used. | 359 | * and then a default diviser for a 32.768KHz clock is used. |
diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c index 7ccb0dd700af..5be98bfd7ed3 100644 --- a/drivers/rtc/rtc-starfire.c +++ b/drivers/rtc/rtc-starfire.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/time.h> | ||
10 | #include <linux/rtc.h> | 9 | #include <linux/rtc.h> |
11 | #include <linux/platform_device.h> | 10 | #include <linux/platform_device.h> |
12 | 11 | ||
@@ -16,11 +15,6 @@ MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | |||
16 | MODULE_DESCRIPTION("Starfire RTC driver"); | 15 | MODULE_DESCRIPTION("Starfire RTC driver"); |
17 | MODULE_LICENSE("GPL"); | 16 | MODULE_LICENSE("GPL"); |
18 | 17 | ||
19 | struct starfire_rtc { | ||
20 | struct rtc_device *rtc; | ||
21 | spinlock_t lock; | ||
22 | }; | ||
23 | |||
24 | static u32 starfire_get_time(void) | 18 | static u32 starfire_get_time(void) |
25 | { | 19 | { |
26 | static char obp_gettod[32]; | 20 | static char obp_gettod[32]; |
@@ -35,64 +29,31 @@ static u32 starfire_get_time(void) | |||
35 | 29 | ||
36 | static int starfire_read_time(struct device *dev, struct rtc_time *tm) | 30 | static int starfire_read_time(struct device *dev, struct rtc_time *tm) |
37 | { | 31 | { |
38 | struct starfire_rtc *p = dev_get_drvdata(dev); | 32 | rtc_time_to_tm(starfire_get_time(), tm); |
39 | unsigned long flags, secs; | 33 | return rtc_valid_tm(tm); |
40 | |||
41 | spin_lock_irqsave(&p->lock, flags); | ||
42 | secs = starfire_get_time(); | ||
43 | spin_unlock_irqrestore(&p->lock, flags); | ||
44 | |||
45 | rtc_time_to_tm(secs, tm); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int starfire_set_time(struct device *dev, struct rtc_time *tm) | ||
51 | { | ||
52 | unsigned long secs; | ||
53 | int err; | ||
54 | |||
55 | err = rtc_tm_to_time(tm, &secs); | ||
56 | if (err) | ||
57 | return err; | ||
58 | |||
59 | /* Do nothing, time is set using the service processor | ||
60 | * console on this platform. | ||
61 | */ | ||
62 | return 0; | ||
63 | } | 34 | } |
64 | 35 | ||
65 | static const struct rtc_class_ops starfire_rtc_ops = { | 36 | static const struct rtc_class_ops starfire_rtc_ops = { |
66 | .read_time = starfire_read_time, | 37 | .read_time = starfire_read_time, |
67 | .set_time = starfire_set_time, | ||
68 | }; | 38 | }; |
69 | 39 | ||
70 | static int __devinit starfire_rtc_probe(struct platform_device *pdev) | 40 | static int __init starfire_rtc_probe(struct platform_device *pdev) |
71 | { | 41 | { |
72 | struct starfire_rtc *p = kzalloc(sizeof(*p), GFP_KERNEL); | 42 | struct rtc_device *rtc = rtc_device_register("starfire", &pdev->dev, |
73 | 43 | &starfire_rtc_ops, THIS_MODULE); | |
74 | if (!p) | 44 | if (IS_ERR(rtc)) |
75 | return -ENOMEM; | 45 | return PTR_ERR(rtc); |
76 | 46 | ||
77 | spin_lock_init(&p->lock); | 47 | platform_set_drvdata(pdev, rtc); |
78 | 48 | ||
79 | p->rtc = rtc_device_register("starfire", &pdev->dev, | ||
80 | &starfire_rtc_ops, THIS_MODULE); | ||
81 | if (IS_ERR(p->rtc)) { | ||
82 | int err = PTR_ERR(p->rtc); | ||
83 | kfree(p); | ||
84 | return err; | ||
85 | } | ||
86 | platform_set_drvdata(pdev, p); | ||
87 | return 0; | 49 | return 0; |
88 | } | 50 | } |
89 | 51 | ||
90 | static int __devexit starfire_rtc_remove(struct platform_device *pdev) | 52 | static int __exit starfire_rtc_remove(struct platform_device *pdev) |
91 | { | 53 | { |
92 | struct starfire_rtc *p = platform_get_drvdata(pdev); | 54 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
93 | 55 | ||
94 | rtc_device_unregister(p->rtc); | 56 | rtc_device_unregister(rtc); |
95 | kfree(p); | ||
96 | 57 | ||
97 | return 0; | 58 | return 0; |
98 | } | 59 | } |
@@ -102,13 +63,12 @@ static struct platform_driver starfire_rtc_driver = { | |||
102 | .name = "rtc-starfire", | 63 | .name = "rtc-starfire", |
103 | .owner = THIS_MODULE, | 64 | .owner = THIS_MODULE, |
104 | }, | 65 | }, |
105 | .probe = starfire_rtc_probe, | 66 | .remove = __exit_p(starfire_rtc_remove), |
106 | .remove = __devexit_p(starfire_rtc_remove), | ||
107 | }; | 67 | }; |
108 | 68 | ||
109 | static int __init starfire_rtc_init(void) | 69 | static int __init starfire_rtc_init(void) |
110 | { | 70 | { |
111 | return platform_driver_register(&starfire_rtc_driver); | 71 | return platform_driver_probe(&starfire_rtc_driver, starfire_rtc_probe); |
112 | } | 72 | } |
113 | 73 | ||
114 | static void __exit starfire_rtc_exit(void) | 74 | static void __exit starfire_rtc_exit(void) |
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c index abe87a4d2665..01d8da9afdc8 100644 --- a/drivers/rtc/rtc-twl4030.c +++ b/drivers/rtc/rtc-twl4030.c | |||
@@ -337,7 +337,7 @@ static int twl4030_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
337 | } | 337 | } |
338 | 338 | ||
339 | #else | 339 | #else |
340 | #define omap_rtc_ioctl NULL | 340 | #define twl4030_rtc_ioctl NULL |
341 | #endif | 341 | #endif |
342 | 342 | ||
343 | static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) | 343 | static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) |