Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1408348pxb; Sat, 17 Apr 2021 17:23:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4zSlCi860cdR5JhznHXN4gabYt/2itGqd17HVbofX0TEn0hX132ZwLE4pmOsXccaR9xGP X-Received: by 2002:a05:6402:368:: with SMTP id s8mr12257842edw.183.1618705424013; Sat, 17 Apr 2021 17:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618705424; cv=none; d=google.com; s=arc-20160816; b=LcxapP6g0Yc9E+CUq6ARtlizg3zP+B2HjwZ3TfV3fRBuiZ4GNl+KhpeT1JqAJ1Rncb VoZ4S4VQ0POl7ptuMxH2DoD/knJgXxrxhhMKXgWHtlPhD6N/2I/esC+UWhIGOfSOFXpv BKV4Gj1XYp5QGUsRgIqi6RU77Wgdc3NnuLDRfVMdatmK2hbWFx0N/8+UVq+UXPMdCRt7 8HGvqXZjrP90S8t2udW8l9Bd9gmtE0x+9j1+L0y0a0FWJzDaDJgaVjY32eHCNCmkwtEX 2lmG/0AvT8C/hDjWsSfecGz2+rASAPtcl3DmMwsd/VR+qYcVOIYTAv+Q6mqHRbvKK8Pn lsSw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BJp5k93ijngBLpdP6dmI0j/znJ1gPJf0mtnr3FDMB3k=; b=fgH/by3/6vq4pCD9Je9+R94HvZ3tP2f3zk3gQcH8ZCoT2d97bQd+ay8MeFttN/HONY BC4OWATSKVzEv5hdWEzLDEpJ7HUTc/jSbwnCL0IpIf2ETNs0pmBS0QvE+mVbaYMNP0B2 CWoBJd/GvH4Ih33qPN9uBbtPX5KvFEyUne23vNiuatd/37c2bYp6WIwLi8lz+DZDtlm6 87sJftwZjudMyGalS1uiun96lSQeBIWL2aL0LpVcRuifMVZOPvDj91MkR6BnXp1e1xqV yWtHtx1HGxC8/eT5NjqEiLBsHrejPUb+zxXfXFH4QdNS7jFbCyn0hVEd9w4jpcaOk/CS fthA== 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 va9si8068266ejb.665.2021.04.17.17.23.21; Sat, 17 Apr 2021 17:23:44 -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 S236592AbhDRAU4 (ORCPT + 99 others); Sat, 17 Apr 2021 20:20:56 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:55003 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236080AbhDRAU4 (ORCPT ); Sat, 17 Apr 2021 20:20:56 -0400 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id DE64DE0005; Sun, 18 Apr 2021 00:20:27 +0000 (UTC) From: Alexandre Belloni To: Alessandro Zummo , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] rtc: pcf8523: report oscillator failures Date: Sun, 18 Apr 2021 02:20:23 +0200 Message-Id: <20210418002023.1000265-3-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210418002023.1000265-1-alexandre.belloni@bootlin.com> References: <20210418002023.1000265-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Report oscillator failures and invalid date/time on RTC_VL_READ. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-pcf8523.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index feadab8e3bd3..bb23379bbfc7 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c @@ -406,6 +406,8 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct i2c_client *client = to_i2c_client(dev); + unsigned int flags = 0; + u8 value; int ret; switch (cmd) { @@ -414,9 +416,16 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd, if (ret < 0) return ret; if (ret) - ret = RTC_VL_BACKUP_LOW; + flags |= RTC_VL_BACKUP_LOW; + + ret = pcf8523_read(client, REG_SECONDS, &value); + if (ret < 0) + return ret; + + if (value & REG_SECONDS_OS) + flags |= RTC_VL_DATA_INVALID; - return put_user(ret, (unsigned int __user *)arg); + return put_user(flags, (unsigned int __user *)arg); default: return -ENOIOCTLCMD; -- 2.30.2