diff options
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/interface.c | 4 | ||||
| -rw-r--r-- | drivers/rtc/rtc-ep93xx.c | 16 | ||||
| -rw-r--r-- | drivers/rtc/rtc-imxdi.c | 1 | ||||
| -rw-r--r-- | drivers/rtc/rtc-lib.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-omap.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-s3c.c | 105 | ||||
| -rw-r--r-- | drivers/rtc/rtc-twl.c | 60 | 
7 files changed, 95 insertions, 95 deletions
| diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 3195dbd3ec34..44e91e598f8d 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
| @@ -639,7 +639,7 @@ EXPORT_SYMBOL_GPL(rtc_irq_unregister); | |||
| 639 | static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled) | 639 | static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled) | 
| 640 | { | 640 | { | 
| 641 | /* | 641 | /* | 
| 642 | * We unconditionally cancel the timer here, because otherwise | 642 | * We always cancel the timer here first, because otherwise | 
| 643 | * we could run into BUG_ON(timer->state != HRTIMER_STATE_CALLBACK); | 643 | * we could run into BUG_ON(timer->state != HRTIMER_STATE_CALLBACK); | 
| 644 | * when we manage to start the timer before the callback | 644 | * when we manage to start the timer before the callback | 
| 645 | * returns HRTIMER_RESTART. | 645 | * returns HRTIMER_RESTART. | 
| @@ -708,7 +708,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq) | |||
| 708 | int err = 0; | 708 | int err = 0; | 
| 709 | unsigned long flags; | 709 | unsigned long flags; | 
| 710 | 710 | ||
| 711 | if (freq <= 0 || freq > 5000) | 711 | if (freq <= 0 || freq > RTC_MAX_FREQ) | 
| 712 | return -EINVAL; | 712 | return -EINVAL; | 
| 713 | retry: | 713 | retry: | 
| 714 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 714 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 
| diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 335551d333b2..14a42a1edc66 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | */ | 36 | */ | 
| 37 | struct ep93xx_rtc { | 37 | struct ep93xx_rtc { | 
| 38 | void __iomem *mmio_base; | 38 | void __iomem *mmio_base; | 
| 39 | struct rtc_device *rtc; | ||
| 39 | }; | 40 | }; | 
| 40 | 41 | ||
| 41 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, | 42 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, | 
| @@ -130,7 +131,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
| 130 | { | 131 | { | 
| 131 | struct ep93xx_rtc *ep93xx_rtc; | 132 | struct ep93xx_rtc *ep93xx_rtc; | 
| 132 | struct resource *res; | 133 | struct resource *res; | 
| 133 | struct rtc_device *rtc; | ||
| 134 | int err; | 134 | int err; | 
| 135 | 135 | ||
| 136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); | 136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); | 
| @@ -151,12 +151,12 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
| 151 | return -ENXIO; | 151 | return -ENXIO; | 
| 152 | 152 | ||
| 153 | pdev->dev.platform_data = ep93xx_rtc; | 153 | pdev->dev.platform_data = ep93xx_rtc; | 
| 154 | platform_set_drvdata(pdev, rtc); | 154 | platform_set_drvdata(pdev, ep93xx_rtc); | 
| 155 | 155 | ||
| 156 | rtc = rtc_device_register(pdev->name, | 156 | ep93xx_rtc->rtc = rtc_device_register(pdev->name, | 
| 157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 
| 158 | if (IS_ERR(rtc)) { | 158 | if (IS_ERR(ep93xx_rtc->rtc)) { | 
| 159 | err = PTR_ERR(rtc); | 159 | err = PTR_ERR(ep93xx_rtc->rtc); | 
| 160 | goto exit; | 160 | goto exit; | 
| 161 | } | 161 | } | 
| 162 | 162 | ||
| @@ -167,7 +167,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
| 167 | return 0; | 167 | return 0; | 
| 168 | 168 | ||
| 169 | fail: | 169 | fail: | 
| 170 | rtc_device_unregister(rtc); | 170 | rtc_device_unregister(ep93xx_rtc->rtc); | 
| 171 | exit: | 171 | exit: | 
| 172 | platform_set_drvdata(pdev, NULL); | 172 | platform_set_drvdata(pdev, NULL); | 
| 173 | pdev->dev.platform_data = NULL; | 173 | pdev->dev.platform_data = NULL; | 
| @@ -176,11 +176,11 @@ exit: | |||
| 176 | 176 | ||
| 177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 
| 178 | { | 178 | { | 
| 179 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); | 
| 180 | 180 | ||
| 181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 
| 182 | platform_set_drvdata(pdev, NULL); | 182 | platform_set_drvdata(pdev, NULL); | 
| 183 | rtc_device_unregister(rtc); | 183 | rtc_device_unregister(ep93xx_rtc->rtc); | 
| 184 | pdev->dev.platform_data = NULL; | 184 | pdev->dev.platform_data = NULL; | 
| 185 | 185 | ||
| 186 | return 0; | 186 | return 0; | 
| diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c index 2dd3c0163272..d93a9608b1f0 100644 --- a/drivers/rtc/rtc-imxdi.c +++ b/drivers/rtc/rtc-imxdi.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/module.h> | 35 | #include <linux/module.h> | 
| 36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> | 
| 37 | #include <linux/rtc.h> | 37 | #include <linux/rtc.h> | 
| 38 | #include <linux/sched.h> | ||
| 38 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> | 
| 39 | 40 | ||
| 40 | /* DryIce Register Definitions */ | 41 | /* DryIce Register Definitions */ | 
| diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 075f1708deae..c4cf05731118 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
| @@ -85,6 +85,8 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | |||
| 85 | time -= tm->tm_hour * 3600; | 85 | time -= tm->tm_hour * 3600; | 
| 86 | tm->tm_min = time / 60; | 86 | tm->tm_min = time / 60; | 
| 87 | tm->tm_sec = time - tm->tm_min * 60; | 87 | tm->tm_sec = time - tm->tm_min * 60; | 
| 88 | |||
| 89 | tm->tm_isdst = 0; | ||
| 88 | } | 90 | } | 
| 89 | EXPORT_SYMBOL(rtc_time_to_tm); | 91 | EXPORT_SYMBOL(rtc_time_to_tm); | 
| 90 | 92 | ||
| diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index bcae8dd41496..7789002bdd5c 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
| @@ -368,7 +368,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
| 368 | pr_info("%s: already running\n", pdev->name); | 368 | pr_info("%s: already running\n", pdev->name); | 
| 369 | 369 | ||
| 370 | /* force to 24 hour mode */ | 370 | /* force to 24 hour mode */ | 
| 371 | new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP); | 371 | new_ctrl = reg & (OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP); | 
| 372 | new_ctrl |= OMAP_RTC_CTRL_STOP; | 372 | new_ctrl |= OMAP_RTC_CTRL_STOP; | 
| 373 | 373 | ||
| 374 | /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE: | 374 | /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE: | 
| diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 9329dbb9ebab..7639ab906f02 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
| @@ -51,6 +51,27 @@ static enum s3c_cpu_type s3c_rtc_cpu_type; | |||
| 51 | 51 | ||
| 52 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); | 52 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); | 
| 53 | 53 | ||
| 54 | static void s3c_rtc_alarm_clk_enable(bool enable) | ||
| 55 | { | ||
| 56 | static DEFINE_SPINLOCK(s3c_rtc_alarm_clk_lock); | ||
| 57 | static bool alarm_clk_enabled; | ||
| 58 | unsigned long irq_flags; | ||
| 59 | |||
| 60 | spin_lock_irqsave(&s3c_rtc_alarm_clk_lock, irq_flags); | ||
| 61 | if (enable) { | ||
| 62 | if (!alarm_clk_enabled) { | ||
| 63 | clk_enable(rtc_clk); | ||
| 64 | alarm_clk_enabled = true; | ||
| 65 | } | ||
| 66 | } else { | ||
| 67 | if (alarm_clk_enabled) { | ||
| 68 | clk_disable(rtc_clk); | ||
| 69 | alarm_clk_enabled = false; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | spin_unlock_irqrestore(&s3c_rtc_alarm_clk_lock, irq_flags); | ||
| 73 | } | ||
| 74 | |||
| 54 | /* IRQ Handlers */ | 75 | /* IRQ Handlers */ | 
| 55 | 76 | ||
| 56 | static irqreturn_t s3c_rtc_alarmirq(int irq, void *id) | 77 | static irqreturn_t s3c_rtc_alarmirq(int irq, void *id) | 
| @@ -64,6 +85,9 @@ static irqreturn_t s3c_rtc_alarmirq(int irq, void *id) | |||
| 64 | writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP); | 85 | writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP); | 
| 65 | 86 | ||
| 66 | clk_disable(rtc_clk); | 87 | clk_disable(rtc_clk); | 
| 88 | |||
| 89 | s3c_rtc_alarm_clk_enable(false); | ||
| 90 | |||
| 67 | return IRQ_HANDLED; | 91 | return IRQ_HANDLED; | 
| 68 | } | 92 | } | 
| 69 | 93 | ||
| @@ -97,6 +121,8 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled) | |||
| 97 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); | 121 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); | 
| 98 | clk_disable(rtc_clk); | 122 | clk_disable(rtc_clk); | 
| 99 | 123 | ||
| 124 | s3c_rtc_alarm_clk_enable(enabled); | ||
| 125 | |||
| 100 | return 0; | 126 | return 0; | 
| 101 | } | 127 | } | 
| 102 | 128 | ||
| @@ -152,10 +178,6 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 152 | goto retry_get_time; | 178 | goto retry_get_time; | 
| 153 | } | 179 | } | 
| 154 | 180 | ||
| 155 | pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n", | ||
| 156 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | ||
| 157 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | ||
| 158 | |||
| 159 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | 181 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | 
| 160 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | 182 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | 
| 161 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | 183 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | 
| @@ -164,6 +186,11 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
| 164 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | 186 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | 
| 165 | 187 | ||
| 166 | rtc_tm->tm_year += 100; | 188 | rtc_tm->tm_year += 100; | 
| 189 | |||
| 190 | pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n", | ||
| 191 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | ||
| 192 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | ||
| 193 | |||
| 167 | rtc_tm->tm_mon -= 1; | 194 | rtc_tm->tm_mon -= 1; | 
| 168 | 195 | ||
| 169 | clk_disable(rtc_clk); | 196 | clk_disable(rtc_clk); | 
| @@ -269,10 +296,9 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 269 | clk_enable(rtc_clk); | 296 | clk_enable(rtc_clk); | 
| 270 | pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 297 | pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 
| 271 | alrm->enabled, | 298 | alrm->enabled, | 
| 272 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 299 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, | 
| 273 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 300 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 
| 274 | 301 | ||
| 275 | |||
| 276 | alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; | 302 | alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; | 
| 277 | writeb(0x00, base + S3C2410_RTCALM); | 303 | writeb(0x00, base + S3C2410_RTCALM); | 
| 278 | 304 | ||
| @@ -319,49 +345,7 @@ static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | |||
| 319 | return 0; | 345 | return 0; | 
| 320 | } | 346 | } | 
| 321 | 347 | ||
| 322 | static int s3c_rtc_open(struct device *dev) | ||
| 323 | { | ||
| 324 | struct platform_device *pdev = to_platform_device(dev); | ||
| 325 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | ||
| 326 | int ret; | ||
| 327 | |||
| 328 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | ||
| 329 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev); | ||
| 330 | |||
| 331 | if (ret) { | ||
| 332 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | ||
| 333 | return ret; | ||
| 334 | } | ||
| 335 | |||
| 336 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | ||
| 337 | IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev); | ||
| 338 | |||
| 339 | if (ret) { | ||
| 340 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | ||
| 341 | goto tick_err; | ||
| 342 | } | ||
| 343 | |||
| 344 | return ret; | ||
| 345 | |||
| 346 | tick_err: | ||
| 347 | free_irq(s3c_rtc_alarmno, rtc_dev); | ||
| 348 | return ret; | ||
| 349 | } | ||
| 350 | |||
| 351 | static void s3c_rtc_release(struct device *dev) | ||
| 352 | { | ||
| 353 | struct platform_device *pdev = to_platform_device(dev); | ||
| 354 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | ||
| 355 | |||
| 356 | /* do not clear AIE here, it may be needed for wake */ | ||
| 357 | |||
| 358 | free_irq(s3c_rtc_alarmno, rtc_dev); | ||
| 359 | free_irq(s3c_rtc_tickno, rtc_dev); | ||
| 360 | } | ||
| 361 | |||
| 362 | static const struct rtc_class_ops s3c_rtcops = { | 348 | static const struct rtc_class_ops s3c_rtcops = { | 
| 363 | .open = s3c_rtc_open, | ||
| 364 | .release = s3c_rtc_release, | ||
| 365 | .read_time = s3c_rtc_gettime, | 349 | .read_time = s3c_rtc_gettime, | 
| 366 | .set_time = s3c_rtc_settime, | 350 | .set_time = s3c_rtc_settime, | 
| 367 | .read_alarm = s3c_rtc_getalarm, | 351 | .read_alarm = s3c_rtc_getalarm, | 
| @@ -425,6 +409,9 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
| 425 | { | 409 | { | 
| 426 | struct rtc_device *rtc = platform_get_drvdata(dev); | 410 | struct rtc_device *rtc = platform_get_drvdata(dev); | 
| 427 | 411 | ||
| 412 | free_irq(s3c_rtc_alarmno, rtc); | ||
| 413 | free_irq(s3c_rtc_tickno, rtc); | ||
| 414 | |||
| 428 | platform_set_drvdata(dev, NULL); | 415 | platform_set_drvdata(dev, NULL); | 
| 429 | rtc_device_unregister(rtc); | 416 | rtc_device_unregister(rtc); | 
| 430 | 417 | ||
| @@ -548,10 +535,32 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
| 548 | 535 | ||
| 549 | s3c_rtc_setfreq(&pdev->dev, 1); | 536 | s3c_rtc_setfreq(&pdev->dev, 1); | 
| 550 | 537 | ||
| 538 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | ||
| 539 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc); | ||
| 540 | if (ret) { | ||
| 541 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | ||
| 542 | goto err_alarm_irq; | ||
| 543 | } | ||
| 544 | |||
| 545 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | ||
| 546 | IRQF_DISABLED, "s3c2410-rtc tick", rtc); | ||
| 547 | if (ret) { | ||
| 548 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | ||
| 549 | free_irq(s3c_rtc_alarmno, rtc); | ||
| 550 | goto err_tick_irq; | ||
| 551 | } | ||
| 552 | |||
| 551 | clk_disable(rtc_clk); | 553 | clk_disable(rtc_clk); | 
| 552 | 554 | ||
| 553 | return 0; | 555 | return 0; | 
| 554 | 556 | ||
| 557 | err_tick_irq: | ||
| 558 | free_irq(s3c_rtc_alarmno, rtc); | ||
| 559 | |||
| 560 | err_alarm_irq: | ||
| 561 | platform_set_drvdata(pdev, NULL); | ||
| 562 | rtc_device_unregister(rtc); | ||
| 563 | |||
| 555 | err_nortc: | 564 | err_nortc: | 
| 556 | s3c_rtc_enable(pdev, 0); | 565 | s3c_rtc_enable(pdev, 0); | 
| 557 | clk_disable(rtc_clk); | 566 | clk_disable(rtc_clk); | 
| diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index 9a81f778d6b2..20687d55e7a7 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
| @@ -362,14 +362,6 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) | |||
| 362 | int res; | 362 | int res; | 
| 363 | u8 rd_reg; | 363 | u8 rd_reg; | 
| 364 | 364 | ||
| 365 | #ifdef CONFIG_LOCKDEP | ||
| 366 | /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which | ||
| 367 | * we don't want and can't tolerate. Although it might be | ||
| 368 | * friendlier not to borrow this thread context... | ||
| 369 | */ | ||
| 370 | local_irq_enable(); | ||
| 371 | #endif | ||
| 372 | |||
| 373 | res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 365 | res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 
| 374 | if (res) | 366 | if (res) | 
| 375 | goto out; | 367 | goto out; | 
| @@ -428,24 +420,12 @@ static struct rtc_class_ops twl_rtc_ops = { | |||
| 428 | static int __devinit twl_rtc_probe(struct platform_device *pdev) | 420 | static int __devinit twl_rtc_probe(struct platform_device *pdev) | 
| 429 | { | 421 | { | 
| 430 | struct rtc_device *rtc; | 422 | struct rtc_device *rtc; | 
| 431 | int ret = 0; | 423 | int ret = -EINVAL; | 
| 432 | int irq = platform_get_irq(pdev, 0); | 424 | int irq = platform_get_irq(pdev, 0); | 
| 433 | u8 rd_reg; | 425 | u8 rd_reg; | 
| 434 | 426 | ||
| 435 | if (irq <= 0) | 427 | if (irq <= 0) | 
| 436 | return -EINVAL; | 428 | goto out1; | 
| 437 | |||
| 438 | rtc = rtc_device_register(pdev->name, | ||
| 439 | &pdev->dev, &twl_rtc_ops, THIS_MODULE); | ||
| 440 | if (IS_ERR(rtc)) { | ||
| 441 | ret = PTR_ERR(rtc); | ||
| 442 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | ||
| 443 | PTR_ERR(rtc)); | ||
| 444 | goto out0; | ||
| 445 | |||
| 446 | } | ||
| 447 | |||
| 448 | platform_set_drvdata(pdev, rtc); | ||
| 449 | 429 | ||
| 450 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 430 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 
| 451 | if (ret < 0) | 431 | if (ret < 0) | 
| @@ -462,14 +442,6 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev) | |||
| 462 | if (ret < 0) | 442 | if (ret < 0) | 
| 463 | goto out1; | 443 | goto out1; | 
| 464 | 444 | ||
| 465 | ret = request_irq(irq, twl_rtc_interrupt, | ||
| 466 | IRQF_TRIGGER_RISING, | ||
| 467 | dev_name(&rtc->dev), rtc); | ||
| 468 | if (ret < 0) { | ||
| 469 | dev_err(&pdev->dev, "IRQ is not free.\n"); | ||
| 470 | goto out1; | ||
| 471 | } | ||
| 472 | |||
| 473 | if (twl_class_is_6030()) { | 445 | if (twl_class_is_6030()) { | 
| 474 | twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK, | 446 | twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK, | 
| 475 | REG_INT_MSK_LINE_A); | 447 | REG_INT_MSK_LINE_A); | 
| @@ -480,28 +452,44 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev) | |||
| 480 | /* Check RTC module status, Enable if it is off */ | 452 | /* Check RTC module status, Enable if it is off */ | 
| 481 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); | 453 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); | 
| 482 | if (ret < 0) | 454 | if (ret < 0) | 
| 483 | goto out2; | 455 | goto out1; | 
| 484 | 456 | ||
| 485 | if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { | 457 | if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { | 
| 486 | dev_info(&pdev->dev, "Enabling TWL-RTC.\n"); | 458 | dev_info(&pdev->dev, "Enabling TWL-RTC.\n"); | 
| 487 | rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; | 459 | rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; | 
| 488 | ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); | 460 | ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); | 
| 489 | if (ret < 0) | 461 | if (ret < 0) | 
| 490 | goto out2; | 462 | goto out1; | 
| 491 | } | 463 | } | 
| 492 | 464 | ||
| 493 | /* init cached IRQ enable bits */ | 465 | /* init cached IRQ enable bits */ | 
| 494 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); | 466 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); | 
| 495 | if (ret < 0) | 467 | if (ret < 0) | 
| 468 | goto out1; | ||
| 469 | |||
| 470 | rtc = rtc_device_register(pdev->name, | ||
| 471 | &pdev->dev, &twl_rtc_ops, THIS_MODULE); | ||
| 472 | if (IS_ERR(rtc)) { | ||
| 473 | ret = PTR_ERR(rtc); | ||
| 474 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | ||
| 475 | PTR_ERR(rtc)); | ||
| 476 | goto out1; | ||
| 477 | } | ||
| 478 | |||
| 479 | ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt, | ||
| 480 | IRQF_TRIGGER_RISING, | ||
| 481 | dev_name(&rtc->dev), rtc); | ||
| 482 | if (ret < 0) { | ||
| 483 | dev_err(&pdev->dev, "IRQ is not free.\n"); | ||
| 496 | goto out2; | 484 | goto out2; | 
| 485 | } | ||
| 497 | 486 | ||
| 498 | return ret; | 487 | platform_set_drvdata(pdev, rtc); | 
| 488 | return 0; | ||
| 499 | 489 | ||
| 500 | out2: | 490 | out2: | 
| 501 | free_irq(irq, rtc); | ||
| 502 | out1: | ||
| 503 | rtc_device_unregister(rtc); | 491 | rtc_device_unregister(rtc); | 
| 504 | out0: | 492 | out1: | 
| 505 | return ret; | 493 | return ret; | 
| 506 | } | 494 | } | 
| 507 | 495 | ||
