Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2413100pxb; Sun, 17 Oct 2021 14:16:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzASkiYMYjDz6f1ZAUCSNu3j446eC2EjxoeZ32zcApRoziro8OBSZneu0MnuYv/HYUuz/+ X-Received: by 2002:a63:f512:: with SMTP id w18mr19709051pgh.280.1634505397209; Sun, 17 Oct 2021 14:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634505397; cv=none; d=google.com; s=arc-20160816; b=NjdAVAy1l7Zp6ArzlcPdvMkUpkVnVh99jir86LWZ35nYQpZVAAJqOlXKghaTKeS36t a17OgqYqyqmS15AYLSpZTuwAA9k4a7ybHkGAkKMlYhe9SXfI+glWKVhyLzpq3uDbkdcT +URD6OUibPuQqZ0Ht08fedyPY9HP71n22PcEcfNKcvXBegkVyLIN7AzxfSlCzXtL52tb TUiRo1jxOqeP0p97o/HtAN9exzZjg5fXGaJdMKY09U1bCND+Y4La25hy8i7IFa4B/U5T meHePutEgzWJTA9zKuknSMroPPbKt3X/XodAUyIy+6Ye1DhZG5YLfz1t0WbeuSREaBPj wwXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xqqgXN5w49tw73seQqZE8fdudE5p3cfSw4Yf7MFihbY=; b=yGgX6ClA1RjHjMoH8THkKYM+kSAQAQ9akdmlw3AkZAM/iqYT7+xB9f4JzwcuWHB+bX tYy1T5rwrB/vmpK1w6GneQmIxWhCbP6D2PuZhvMOCBuq8/xOdSVvUl0NfdWrQYfKGgzs 6fqB/bCRr2BYYmPXuNzDBbP5Ta/l//8T7zdKcJStzvSNen9Kog+euvzGEzr5D/blOr6A D2elXR6xVSd/7MpQUWTlt5kdAzNZ2WJctLdzQErr4D7jCfAl+lZNTvW6wkTG/uAocehO Uoa6RLC5Sp2uVAhbAyLTPLin2GJ+S5w1nwKtd96mFULpBH3aIE4ROfmPcvNkAPQYWbVh XxQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mw9si19582823pjb.55.2021.10.17.14.16.25; Sun, 17 Oct 2021 14:16:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238159AbhJOT0O (ORCPT + 99 others); Fri, 15 Oct 2021 15:26:14 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:35945 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbhJOT0N (ORCPT ); Fri, 15 Oct 2021 15:26:13 -0400 Received: (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id E41BA20003; Fri, 15 Oct 2021 19:24:05 +0000 (UTC) From: Alexandre Belloni To: Alessandro Zummo , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rtc: pcf8523: avoid reading BLF in pcf8523_rtc_read_time Date: Fri, 15 Oct 2021 21:24:00 +0200 Message-Id: <20211015192400.818254-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BLF, battery low doesn't mean the time is imprecise or invalid, it simply mean the backup battery has to be replaced. This information can be read using the VL_READ ioctl. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-pcf8523.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index 8b6fb20774bf..09110b3ae25f 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c @@ -24,6 +24,7 @@ #define PCF8523_CONTROL3_PM_DSM BIT(5) /* direct switching mode */ #define PCF8523_CONTROL3_PM_MASK 0xe0 #define PCF8523_CONTROL3_BLF BIT(2) /* battery low bit, read-only */ +#define PCF8523_CONTROL3_BSF BIT(3) #define PCF8523_REG_SECONDS 0x03 #define PCF8523_SECONDS_OS BIT(7) @@ -94,18 +95,6 @@ static int pcf8523_write(struct i2c_client *client, u8 reg, u8 value) return 0; } -static int pcf8523_voltage_low(struct i2c_client *client) -{ - u8 value; - int err; - - err = pcf8523_read(client, PCF8523_REG_CONTROL3, &value); - if (err < 0) - return err; - - return !!(value & PCF8523_CONTROL3_BLF); -} - static int pcf8523_load_capacitance(struct i2c_client *client) { u32 load; @@ -220,14 +209,6 @@ static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm) struct i2c_msg msgs[2]; int err; - err = pcf8523_voltage_low(client); - if (err < 0) { - return err; - } else if (err > 0) { - dev_err(dev, "low voltage detected, time is unreliable\n"); - return -EINVAL; - } - msgs[0].addr = client->addr; msgs[0].flags = 0; msgs[0].len = 1; @@ -412,10 +393,11 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd, switch (cmd) { case RTC_VL_READ: - ret = pcf8523_voltage_low(client); + ret = pcf8523_read(client, PCF8523_REG_CONTROL3, &value); if (ret < 0) return ret; - if (ret) + + if (value & PCF8523_CONTROL3_BLF) flags |= RTC_VL_BACKUP_LOW; ret = pcf8523_read(client, PCF8523_REG_SECONDS, &value); -- 2.31.1