]> git.karo-electronics.de Git - linux-beck.git/commitdiff
rtc: Provide flag for rtc devices that don't support UIE
authorJohn Stultz <john.stultz@linaro.org>
Wed, 7 Mar 2012 01:16:09 +0000 (17:16 -0800)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 16 Mar 2012 01:23:10 +0000 (18:23 -0700)
Richard Weinberger noticed that on some RTC hardware that
doesn't support UIE mode, due to coarse granular alarms
(like 1minute resolution), the current virtualized RTC
support doesn't properly error out when UIE is enabled.

Instead the current code queues an alarm for the next second,
but it won't fire until up to a miniute later.

This patch provides a generic way to flag this sort of hardware
and fixes the issue on the mpc5121 where Richard noticed the
problem.

CC: stable@vger.kernel.org
Reported-by: Richard Weinberger <richard@nod.at>
Tested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: John Stultz <john.stultz@linaro.org>
drivers/rtc/interface.c
drivers/rtc/rtc-mpc5121.c
include/linux/rtc.h

index dc87eda6581434c9708173948878e906e46319f6..eb415bd7649418f1d91b5c45b98fe9411f5171d3 100644 (file)
@@ -458,6 +458,11 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
        if (rtc->uie_rtctimer.enabled == enabled)
                goto out;
 
+       if (rtc->uie_unsupported) {
+               err = -EINVAL;
+               goto out;
+       }
+
        if (enabled) {
                struct rtc_time tm;
                ktime_t now, onesec;
index 9d3caccfc250ff6c5dd8a89b5ee296457ec31bcb..613447abdbe510724b6f4c3923e968f894a5b0a5 100644 (file)
@@ -360,6 +360,8 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
                                                &mpc5200_rtc_ops, THIS_MODULE);
        }
 
+       rtc->rtc->uie_unsupported = 1;
+
        if (IS_ERR(rtc->rtc)) {
                err = PTR_ERR(rtc->rtc);
                goto out_free_irq;
index 93f4d035076bc8f295fde5b0a6b5b89e4c5df9ff..fcabfb4873c8dd6e8466233de9d557be4bf2101e 100644 (file)
@@ -202,7 +202,8 @@ struct rtc_device
        struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */
        int pie_enabled;
        struct work_struct irqwork;
-
+       /* Some hardware can't support UIE mode */
+       int uie_unsupported;
 
 #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
        struct work_struct uie_task;