From 206778f7a8412b3f694cee3d3931e4d77cd5af7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 20 Dec 2019 12:50:16 +0100 Subject: [PATCH] rtc: m41t80: Clear oscillator fault bit during probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This make sure we don't read a bad value later on. Signed-off-by: Guido Günther --- drivers/rtc/rtc-m41t80.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 160dcf68e64ebd..71a52c75793565 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c @@ -959,6 +959,17 @@ static int m41t80_probe(struct i2c_client *client, return rc; } + /* Make sure OF (osciallator failure) is cleared */ + rc = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); + + if (rc >= 0) + rc = i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS, + rc & ~M41T80_FLAGS_OF); + if (rc < 0) { + dev_err(&client->dev, "Can't clear OF bit\n"); + return rc; + } + #ifdef CONFIG_RTC_DRV_M41T80_WDT if (m41t80_data->features & M41T80_FEATURE_HT) { save_client = client;