From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Daniel Romell <danielromell@gmail.com>
Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org, daro@hms.se, jao@hms.se,
mago@hms.se
Subject: Re: [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag
Date: Thu, 11 Aug 2016 12:15:20 +0200 [thread overview]
Message-ID: <20160811101520.GG8132@piout.net> (raw)
In-Reply-To: <1470909555-9226-3-git-send-email-daro@hms.se>
On 11/08/2016 at 11:59:15 +0200, Daniel Romell wrote :
> From: Jan Östlund <jao@hms.se>
>
> While the oscillator failure flag is set, the RTC registers
> should be considered invalid. bq32k_rtc_read_time() now
> returns an error instead of an invalid time.
>
> The failure flag is cleared the next time the clock is set.
>
> Signed-off-by: Daniel Romell <daro@hms.se>
> ---
> drivers/rtc/rtc-bq32k.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
> index 5a0c137..3fc6f7c 100644
> --- a/drivers/rtc/rtc-bq32k.c
> +++ b/drivers/rtc/rtc-bq32k.c
> @@ -93,6 +93,13 @@ static int bq32k_rtc_read_time(struct device *dev, struct rtc_time *tm)
> if (error)
> return error;
>
> + /*
> + * In case of oscillator failure, the register contents should be
> + * considered invalid. The flag is cleared the next time the RTC is set.
> + */
> + if (regs.minutes & BQ32K_OF)
> + return -EIO;
The other drivers return -EINVAL in that case. Else, the change is fine.
> +
> tm->tm_sec = bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
> tm->tm_min = bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
> tm->tm_hour = bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
> @@ -204,13 +211,10 @@ static int bq32k_probe(struct i2c_client *client,
>
> /* Check Oscillator Failure flag */
> error = bq32k_read(dev, ®, BQ32K_MINUTES, 1);
> - if (!error && (reg & BQ32K_OF)) {
> - dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
> - reg &= ~BQ32K_OF;
> - error = bq32k_write(dev, ®, BQ32K_MINUTES, 1);
> - }
> if (error)
> return error;
> + if (reg & BQ32K_OF)
> + dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
>
> if (client->dev.of_node)
> trickle_charger_of_init(dev, client->dev.of_node);
> --
> 2.7.4
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-08-11 10:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 9:59 [PATCH 0/2] bq32000 fixes Daniel Romell
2016-08-11 9:59 ` [PATCH 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
2016-08-11 9:59 ` [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
2016-08-11 10:15 ` Alexandre Belloni [this message]
2016-08-11 11:31 ` [PATCH v2 0/2] bq32000 fixes Daniel Romell
2016-08-11 11:31 ` [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
2016-08-11 13:42 ` Alexandre Belloni
[not found] ` <5b6636b7-ff29-458b-b566-4b97e401b794@googlegroups.com>
2016-08-11 21:13 ` [rtc-linux] " Alexandre Belloni
2016-08-15 7:10 ` Jan Östlund
2016-08-11 11:31 ` [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
2016-08-15 7:10 ` Jan Östlund
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=20160811101520.GG8132@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=a.zummo@towertech.it \
--cc=danielromell@gmail.com \
--cc=daro@hms.se \
--cc=jao@hms.se \
--cc=linux-kernel@vger.kernel.org \
--cc=mago@hms.se \
--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