From: akpm@linux-foundation.org (Andrew Morton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable()
Date: Tue, 18 Sep 2012 16:07:40 -0700 [thread overview]
Message-ID: <20120918160740.6dbdc797.akpm@linux-foundation.org> (raw)
In-Reply-To: <1345277408-30044-1-git-send-email-LW@KARO-electronics.de>
On Sat, 18 Aug 2012 10:10:08 +0200
Lothar Wa__mann <LW@karo-electronics.de> wrote:
> If snvs_rtc_enable() happens to be descheduled for a period longer
> than the timout period, a timeout may be indicated even if the RTC
> status has changed meanwhile. Force a status read at the end of the
> timeout period to prevent bogus timeout errors.
(delayed, sorry)
> --- a/drivers/rtc/rtc-snvs.c
> +++ b/drivers/rtc/rtc-snvs.c
> @@ -81,6 +81,13 @@ static void rtc_write_sync_lp(void __iomem *ioaddr)
> }
> }
>
> +static int snvs_rtc_enable_done(int enable, void __iomem *addr)
> +{
> + u32 lpcr = readl(addr + SNVS_LPCR);
> +
> + return !!enable ^ !(lpcr & SNVS_LPCR_SRTC_ENV);
> +}
> +
> static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
> {
> unsigned long timeout = jiffies + msecs_to_jiffies(1);
> @@ -99,18 +106,15 @@ static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
> spin_unlock_irqrestore(&data->lock, flags);
>
> while (1) {
> - lpcr = readl(data->ioaddr + SNVS_LPCR);
> + if (snvs_rtc_enable_done(enable, data->ioaddr))
> + break;
>
> - if (enable) {
> - if (lpcr & SNVS_LPCR_SRTC_ENV)
> - break;
> - } else {
> - if (!(lpcr & SNVS_LPCR_SRTC_ENV))
> + if (time_after(jiffies, timeout)) {
> + if (snvs_rtc_enable_done(enable, data->ioaddr))
> break;
> + else
> + return -ETIMEDOUT;
> }
> -
> - if (time_after(jiffies, timeout))
> - return -ETIMEDOUT;
> }
>
> return 0;
I think this will have been addressed by
http://ozlabs.org/~akpm/mmots/broken-out/rtc-snvs-add-freescale-rtc-snvs-driver-fix.patch?
prev parent reply other threads:[~2012-09-18 23:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-18 8:10 [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable() Lothar Waßmann
2012-08-18 12:46 ` Shawn Guo
2012-08-18 13:14 ` Lothar Waßmann
2015-05-10 21:42 ` Alexandre Belloni
2012-09-18 23:07 ` Andrew Morton [this message]
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=20120918160740.6dbdc797.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).