diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2011-08-25 18:59:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-25 21:51:00 -0400 |
commit | 62d1760180c84cba68cc83696fa0bde0593007bd (patch) | |
tree | 67aac33c82bec7cc50034374c58b7ef1f5bd38a2 /drivers/rtc/rtc-s3c.c | |
parent | 4e8896cde182b4eab6f2d0af9b6eef87720fae0d (diff) |
drivers/rtc/rtc-s3c.c: allow multiple open / allow no-ioctl-open'ed rtc to have irq.
The previous rtc-s3c had two issues related with its IRQ.
1. Users cannot open rtc multiple times because an open operation
calls request_irq on the same IRQ. (e.g., two user processes wants to
open and read RTC time from rtc-s3c at the same time)
2. If alarm is set and no one has the rtc opened with filesystem
(either the alarm is set by kernel/boot-loader or user set an alarm and
closed rtc dev file), the pending bit is not cleared and no further
interrupt is invoked. When the alarm is used by the system itself such
as a resume from suspend-to-RAM or other Low-power modes/idle, this is
a critical issue.
This patch mitigates these issues by calling request_irq at probe and
free_irq at remove.
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Changhwan Youn <chaos.youn@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 067207afc086..4e7c04e773e0 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -319,49 +319,7 @@ static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | |||
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
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 = { | 322 | static const struct rtc_class_ops s3c_rtcops = { |
363 | .open = s3c_rtc_open, | ||
364 | .release = s3c_rtc_release, | ||
365 | .read_time = s3c_rtc_gettime, | 323 | .read_time = s3c_rtc_gettime, |
366 | .set_time = s3c_rtc_settime, | 324 | .set_time = s3c_rtc_settime, |
367 | .read_alarm = s3c_rtc_getalarm, | 325 | .read_alarm = s3c_rtc_getalarm, |
@@ -425,6 +383,9 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
425 | { | 383 | { |
426 | struct rtc_device *rtc = platform_get_drvdata(dev); | 384 | struct rtc_device *rtc = platform_get_drvdata(dev); |
427 | 385 | ||
386 | free_irq(s3c_rtc_alarmno, rtc); | ||
387 | free_irq(s3c_rtc_tickno, rtc); | ||
388 | |||
428 | platform_set_drvdata(dev, NULL); | 389 | platform_set_drvdata(dev, NULL); |
429 | rtc_device_unregister(rtc); | 390 | rtc_device_unregister(rtc); |
430 | 391 | ||
@@ -548,10 +509,32 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
548 | 509 | ||
549 | s3c_rtc_setfreq(&pdev->dev, 1); | 510 | s3c_rtc_setfreq(&pdev->dev, 1); |
550 | 511 | ||
512 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | ||
513 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc); | ||
514 | if (ret) { | ||
515 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | ||
516 | goto err_alarm_irq; | ||
517 | } | ||
518 | |||
519 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | ||
520 | IRQF_DISABLED, "s3c2410-rtc tick", rtc); | ||
521 | if (ret) { | ||
522 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | ||
523 | free_irq(s3c_rtc_alarmno, rtc); | ||
524 | goto err_tick_irq; | ||
525 | } | ||
526 | |||
551 | clk_disable(rtc_clk); | 527 | clk_disable(rtc_clk); |
552 | 528 | ||
553 | return 0; | 529 | return 0; |
554 | 530 | ||
531 | err_tick_irq: | ||
532 | free_irq(s3c_rtc_alarmno, rtc); | ||
533 | |||
534 | err_alarm_irq: | ||
535 | platform_set_drvdata(pdev, NULL); | ||
536 | rtc_device_unregister(rtc); | ||
537 | |||
555 | err_nortc: | 538 | err_nortc: |
556 | s3c_rtc_enable(pdev, 0); | 539 | s3c_rtc_enable(pdev, 0); |
557 | clk_disable(rtc_clk); | 540 | clk_disable(rtc_clk); |