From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752503AbcHKKPe (ORCPT ); Thu, 11 Aug 2016 06:15:34 -0400 Received: from down.free-electrons.com ([37.187.137.238]:51338 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750803AbcHKKPc (ORCPT ); Thu, 11 Aug 2016 06:15:32 -0400 Date: Thu, 11 Aug 2016 12:15:20 +0200 From: Alexandre Belloni To: Daniel Romell 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 Message-ID: <20160811101520.GG8132@piout.net> References: <1470909555-9226-1-git-send-email-daro@hms.se> <1470909555-9226-3-git-send-email-daro@hms.se> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1470909555-9226-3-git-send-email-daro@hms.se> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/08/2016 at 11:59:15 +0200, Daniel Romell wrote : > From: Jan Östlund > > 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 > --- > 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