From: Gabriele Mazzotta <gabriele.mzt@gmail.com>
To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
matthew.garrett@nebula.com
Subject: [rtc-linux] Re: [PATCH 1/2] rtc-cmos: Clear expired alarm after resume
Date: Wed, 1 Jun 2016 18:11:17 +0200 [thread overview]
Message-ID: <337d25d5-f5e2-c2db-e3fa-57a820ef16ac@gmail.com> (raw)
In-Reply-To: <1464795615-7748-1-git-send-email-gabriele.mzt@gmail.com>
On 01/06/2016 17:40, Gabriele Mazzotta wrote:
> If the system wakes up because of a wake alarm, the internal state
> of the alarm is not updated. As consequence, the state no longer
> reflects the actual state of the hardware and setting a new alarm
> is not possible until the expired alarm is cleared.
>
> Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
> ---
> drivers/rtc/rtc-cmos.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index fbe9c72..fd121e3 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -900,11 +900,33 @@ static inline int cmos_poweroff(struct device *dev)
>
> #ifdef CONFIG_PM_SLEEP
>
> +static void cmos_check_alarm(struct device *dev)
> +{
> + struct cmos_rtc *cmos = dev_get_drvdata(dev);
> + struct rtc_wkalrm alarm;
> + struct rtc_time now;
> + time64_t t_now;
> + time64_t t_expires;
> +
> + cmos_read_time(dev, &now);
> + rtc_read_alarm(cmos->rtc, &alarm);
Here it should probably check the return value and exit in case of error.
> + t_now = rtc_tm_to_time64(&now);
> + t_expires = rtc_tm_to_time64(&alarm.time);
> +
> + if (t_expires <= t_now && alarm.enabled) {
> + alarm.enabled = 0;
> + cmos->suspend_ctrl &= ~RTC_AIE;
> + rtc_set_alarm(cmos->rtc, &alarm);
Same here.
> + }
> +}
> +
> static int cmos_resume(struct device *dev)
> {
> struct cmos_rtc *cmos = dev_get_drvdata(dev);
> unsigned char tmp;
>
> + cmos_check_alarm(dev);
> +
> if (cmos->enabled_wake) {
> if (cmos->wake_off)
> cmos->wake_off(dev);
>
--
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-06-01 16:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 15:40 [rtc-linux] [PATCH 1/2] rtc-cmos: Clear expired alarm after resume Gabriele Mazzotta
2016-06-01 15:40 ` [rtc-linux] [PATCH 2/2] rtc-cmos: Restore " Gabriele Mazzotta
2016-06-01 16:11 ` Gabriele Mazzotta [this message]
2016-06-04 14:46 ` [rtc-linux] Re: [PATCH 1/2] rtc-cmos: Clear expired " Alexandre Belloni
2016-06-04 16:58 ` Gabriele Mazzotta
2016-06-04 17:48 ` Alexandre Belloni
2016-08-25 14:54 ` Gabriele Mazzotta
2016-08-30 23:28 ` Alexandre Belloni
2016-08-31 15:05 ` Gabriele Mazzotta
2016-08-31 16:08 ` Alexandre Belloni
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=337d25d5-f5e2-c2db-e3fa-57a820ef16ac@gmail.com \
--to=gabriele.mzt@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox