From: Akinobu Mita <akinobu.mita@gmail.com>
To: rtc-linux@googlegroups.com
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Dennis Aberilla <denzzzhome@yahoo.com>
Subject: [rtc-linux] [PATCH v2 4/4] rtc: ds3232-core: fix read on /dev/rtc after RTC_AIE_ON
Date: Thu, 18 Feb 2016 23:49:32 +0900 [thread overview]
Message-ID: <1455806972-27284-4-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1455806972-27284-1-git-send-email-akinobu.mita@gmail.com>
The rtctest (tools/testing/selftests/timers/rtctest.c) found that
reading ds3232 rtc device immediately return the value 0x20 (RTC_AF)
without waiting alarm interrupt.
This is because alarm_irq_enable() of ds3232 driver changes RTC_AF
flag in rtc->irq_data. So calling ioctl with RTC_AIE_ON generates
invalid value in rtc device.
The lower-level driver should not touch rtc->irq_data directly.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Dennis Aberilla <denzzzhome@yahoo.com>
---
* no changes since v1
drivers/rtc/rtc-ds3232-core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ds3232-core.c b/drivers/rtc/rtc-ds3232-core.c
index 600673a..ca29277 100644
--- a/drivers/rtc/rtc-ds3232-core.c
+++ b/drivers/rtc/rtc-ds3232-core.c
@@ -273,7 +273,7 @@ out:
return ret;
}
-static void ds3232_update_alarm(struct device *dev)
+static void ds3232_update_alarm(struct device *dev, unsigned int enabled)
{
struct ds3232 *ds3232 = dev_get_drvdata(dev);
int control;
@@ -303,7 +303,7 @@ static void ds3232_update_alarm(struct device *dev)
if (control < 0)
goto unlock;
- if (ds3232->rtc->irq_data & (RTC_AF | RTC_UF))
+ if (enabled || (ds3232->rtc->irq_data & RTC_UF))
/* enable alarm1 interrupt */
control |= DS3232_REG_CR_A1IE;
else
@@ -322,12 +322,8 @@ static int ds3232_alarm_irq_enable(struct device *dev, unsigned int enabled)
if (ds3232->ops->irq(dev) <= 0)
return -EINVAL;
- if (enabled)
- ds3232->rtc->irq_data |= RTC_AF;
- else
- ds3232->rtc->irq_data &= ~RTC_AF;
+ ds3232_update_alarm(dev, enabled);
- ds3232_update_alarm(dev);
return 0;
}
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2016-02-18 14:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 14:49 [rtc-linux] [PATCH v2 1/4] rtc: ds3232: rename rtc-ds3232.c to rtc-ds3232-core.c for preparation Akinobu Mita
2016-02-18 14:49 ` [rtc-linux] [PATCH v2 2/4] rtc: ds3232: split into core module and i2c driver Akinobu Mita
2016-02-18 14:49 ` [rtc-linux] [PATCH v2 3/4] rtc: ds3234: use rtc-ds3232 core and support alarm Akinobu Mita
2016-02-18 14:49 ` Akinobu Mita [this message]
2016-02-18 15:04 ` [rtc-linux] Re: [PATCH v2 1/4] rtc: ds3232: rename rtc-ds3232.c to rtc-ds3232-core.c for preparation Alexandre Belloni
2016-02-18 16:00 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455806972-27284-4-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=denzzzhome@yahoo.com \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.