Skip to content

Commit

Permalink
rtc: file close() consistently disables repeating irqs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Brownell authored and Linus Torvalds committed Oct 16, 2008
1 parent 37fc5e2 commit 743e6a5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 47 deletions.
12 changes: 9 additions & 3 deletions drivers/rtc/rtc-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions drivers/rtc/rtc-ds1511.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
};

Expand Down
12 changes: 0 additions & 12 deletions drivers/rtc/rtc-ds1553.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
};

Expand Down
7 changes: 0 additions & 7 deletions drivers/rtc/rtc-sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 0 additions & 12 deletions drivers/rtc/rtc-stk17ta8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
};

Expand Down

0 comments on commit 743e6a5

Please sign in to comment.