mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
rtc-at91rm9200: avoid spurious irqs
This fixes kernel http://bugzilla.kernel.org/show_bug.cgi?id=11112 (bogus RTC update IRQs reported) for rtc-at91rm9200 by scrubbing old IRQ status before enabling IRQs. It also removes nonfunctional periodic IRQ support from this driver; only update IRQs are reported, or provided by the hardware. I suspect some other RTCs probably have versions of #11112; it's easy to overlook, since most non-RTC drivers don't care about spurious IRQs: they're not reported to userspace. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Report-by: W Unruh <unruh@physics.ubc.ca> Cc: Andrew Victor <avictor.za@gmail.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
773be7ee97
commit
449321b39f
1 changed files with 6 additions and 10 deletions
|
@ -171,8 +171,10 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||||
| BIN2BCD(tm.tm_mday) << 24
|
| BIN2BCD(tm.tm_mday) << 24
|
||||||
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
|
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
|
||||||
|
|
||||||
if (alrm->enabled)
|
if (alrm->enabled) {
|
||||||
|
at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM);
|
||||||
at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
|
at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
|
||||||
|
}
|
||||||
|
|
||||||
pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
|
pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
|
||||||
at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
|
at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
|
||||||
|
@ -191,28 +193,22 @@ static int at91_rtc_ioctl(struct device *dev, unsigned int cmd,
|
||||||
|
|
||||||
pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg);
|
pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg);
|
||||||
|
|
||||||
|
/* important: scrub old status before enabling IRQs */
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case RTC_AIE_OFF: /* alarm off */
|
case RTC_AIE_OFF: /* alarm off */
|
||||||
at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM);
|
at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM);
|
||||||
break;
|
break;
|
||||||
case RTC_AIE_ON: /* alarm on */
|
case RTC_AIE_ON: /* alarm on */
|
||||||
|
at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM);
|
||||||
at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
|
at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
|
||||||
break;
|
break;
|
||||||
case RTC_UIE_OFF: /* update off */
|
case RTC_UIE_OFF: /* update off */
|
||||||
case RTC_PIE_OFF: /* periodic off */
|
|
||||||
at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV);
|
at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV);
|
||||||
break;
|
break;
|
||||||
case RTC_UIE_ON: /* update on */
|
case RTC_UIE_ON: /* update on */
|
||||||
case RTC_PIE_ON: /* periodic on */
|
at91_sys_write(AT91_RTC_SCCR, AT91_RTC_SECEV);
|
||||||
at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV);
|
at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV);
|
||||||
break;
|
break;
|
||||||
case RTC_IRQP_READ: /* read periodic alarm frequency */
|
|
||||||
ret = put_user(AT91_RTC_FREQ, (unsigned long *) arg);
|
|
||||||
break;
|
|
||||||
case RTC_IRQP_SET: /* set periodic alarm frequency */
|
|
||||||
if (arg != AT91_RTC_FREQ)
|
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
ret = -ENOIOCTLCMD;
|
ret = -ENOIOCTLCMD;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue