rtc: file close() consistently disables repeating irqs
authorDavid Brownell <dbrownell@users.sourceforge.net>
Thu, 16 Oct 2008 05:03:04 +0000 (22:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Oct 2008 18:21:40 +0000 (11:21 -0700)
Make the rtc framework consistent about disabling 1/second update IRQs
that may have been activated through the /dev interface, when that /dev
file is closed.  (It may have closed because of coredump, etc.) This was
previously done only for emulated update IRQs ...  now, do it always.

Also comment the current policy: repeating IRQs (periodic, update) that
userspace enabled will be cleanly disabled, but alarms are left alone.
Such repeating IRQs are a constant and pointless system load.

Update some RTC drivers to remove now-needless release() methods.  Most
such methods just enforce that policy.  The others all seem to be buggy,
and mistreat in-kernel clients of periodic or alarm IRQs.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Andrew Sharp <andy.sharp@onstor.com>
Cc: Angelo Castello <angelo.castello@st.com>
Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Thomas Hommel <thomas.hommel@gefanuc.com>
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>
drivers/rtc/rtc-dev.c
drivers/rtc/rtc-ds1511.c
drivers/rtc/rtc-ds1553.c
drivers/rtc/rtc-sh.c
drivers/rtc/rtc-stk17ta8.c

index 52e2743b04ecf77bb6a975d6c8609fa042025dea..079e9ed907e06caa6d5a453c56c31e413f0cf6c5 100644 (file)
@@ -432,9 +432,15 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
 {
        struct rtc_device *rtc = file->private_data;
 
-#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
-       clear_uie(rtc);
-#endif
+       /* We shut down the repeating IRQs that userspace enabled,
+        * since nothing is listening to them.
+        *  - Update (UIE) ... currently only managed through ioctls
+        *  - Periodic (PIE) ... also used through rtc_*() interface calls
+        *
+        * Leave the alarm alone; it may be set to trigger a system wakeup
+        * later, or be used by kernel code, and is a one-shot event anyway.
+        */
+       rtc_dev_ioctl(file, RTC_UIE_OFF, 0);
        rtc_irq_set_state(rtc, NULL, 0);
 
        if (rtc->ops->release)
index 0f0d27d1c4ca366916b7958798ac44570681f679..86981d34fbb6717a66d47a11db1287b4e3a4c7f5 100644 (file)
@@ -379,18 +379,6 @@ ds1511_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
- static void
-ds1511_rtc_release(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-
-       if (pdata->irq >= 0) {
-               pdata->irqen = 0;
-               ds1511_rtc_update_alarm(pdata);
-       }
-}
-
  static int
 ds1511_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
 {
@@ -428,7 +416,6 @@ static const struct rtc_class_ops ds1511_rtc_ops = {
        .set_time       = ds1511_rtc_set_time,
        .read_alarm     = ds1511_rtc_read_alarm,
        .set_alarm      = ds1511_rtc_set_alarm,
-       .release        = ds1511_rtc_release,
        .ioctl          = ds1511_rtc_ioctl,
 };
 
index a19f1141554083058d5be71ac4064e81c97ac281..4ef59285b489ec28d05b9c038ae35d28e49a0b40 100644 (file)
@@ -207,17 +207,6 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void ds1553_rtc_release(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-
-       if (pdata->irq >= 0) {
-               pdata->irqen = 0;
-               ds1553_rtc_update_alarm(pdata);
-       }
-}
-
 static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd,
                            unsigned long arg)
 {
@@ -254,7 +243,6 @@ static const struct rtc_class_ops ds1553_rtc_ops = {
        .set_time       = ds1553_rtc_set_time,
        .read_alarm     = ds1553_rtc_read_alarm,
        .set_alarm      = ds1553_rtc_set_alarm,
-       .release        = ds1553_rtc_release,
        .ioctl          = ds1553_rtc_ioctl,
 };
 
index 1f88e9e914ec97d41c139519ab6e2e34c77ea4e2..fcead4c4cd1f339b59b84de1c2d34ea95f38f9f1 100644 (file)
@@ -257,12 +257,6 @@ static inline void sh_rtc_setaie(struct device *dev, unsigned int enable)
        spin_unlock_irq(&rtc->lock);
 }
 
-static void sh_rtc_release(struct device *dev)
-{
-       sh_rtc_setpie(dev, 0);
-       sh_rtc_setaie(dev, 0);
-}
-
 static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
 {
        struct sh_rtc *rtc = dev_get_drvdata(dev);
@@ -559,7 +553,6 @@ static int sh_rtc_irq_set_freq(struct device *dev, int freq)
 }
 
 static struct rtc_class_ops sh_rtc_ops = {
-       .release        = sh_rtc_release,
        .ioctl          = sh_rtc_ioctl,
        .read_time      = sh_rtc_read_time,
        .set_time       = sh_rtc_set_time,
index 31d3c8c28588b9f272104aadd83df86512da2200..9a7e920315fa76c6af27d307c913df0b184dadad 100644 (file)
@@ -215,17 +215,6 @@ static irqreturn_t stk17ta8_rtc_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void stk17ta8_rtc_release(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-
-       if (pdata->irq >= 0) {
-               pdata->irqen = 0;
-               stk17ta8_rtc_update_alarm(pdata);
-       }
-}
-
 static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd,
                            unsigned long arg)
 {
@@ -254,7 +243,6 @@ static const struct rtc_class_ops stk17ta8_rtc_ops = {
        .set_time       = stk17ta8_rtc_set_time,
        .read_alarm     = stk17ta8_rtc_read_alarm,
        .set_alarm      = stk17ta8_rtc_set_alarm,
-       .release        = stk17ta8_rtc_release,
        .ioctl          = stk17ta8_rtc_ioctl,
 };