From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CB1834A32E; Tue, 26 Aug 2025 13:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756216445; cv=none; b=A6Dr5E3xPtZ82hvgm9XfnELxI+4j5b3T1sdAZx6NXChIWOz/Yp9HMcFkIIwCLFZ5JEit++XlLZqIhR+rmORxCqvp0yhE0BcGRNBLFl56wPFhwunVBE5SpCFl/LMUnoO+0VaKMG97gRgLvbEE8bXfmb47zi+al4SfHPHcnRWAHko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756216445; c=relaxed/simple; bh=pDtt6UTzCpkWsT1AjM2xI0MWj4YCKzsMb2Gu/gTTGS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gtt4JpKDKiXbzbpalRlM2aKwCSUQdbLJriNqTlsDUaKUF2rMPASXTg9Usk1rV9T2R2T6lBzSz6m5zg5OQ0aoRh+mcC22OdFe4xdwtTbX3o1J9TVmzX+Xtq/fh63LFzgue8FCF//ZIAVU3Cs3mX4UKCY5gxNT0scg4xaHTwSfPKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZFKOwiUn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZFKOwiUn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92EC1C4CEF1; Tue, 26 Aug 2025 13:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756216444; bh=pDtt6UTzCpkWsT1AjM2xI0MWj4YCKzsMb2Gu/gTTGS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZFKOwiUn7v5aqG5/nvbbP6xH9195Ug70X7wVSL9MTIRyM5dFEoxPnfzRlPL2GXdVj kUBTphQdam1ISCoQl2L9QyWVVqX/e+DYaYyraYx0YFBIGNWsWG7CiMUTIWFkVLJF/F cePPuU0a1SXiNn3B6iW2SoSdkhT5G03JFWlSF39k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Meagan Lloyd , Tyler Hicks , Rodolfo Giometti , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 414/644] rtc: ds1307: handle oscillator stop flag (OSF) for ds1341 Date: Tue, 26 Aug 2025 13:08:25 +0200 Message-ID: <20250826110956.717265704@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110946.507083938@linuxfoundation.org> References: <20250826110946.507083938@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Meagan Lloyd [ Upstream commit 523923cfd5d622b8f4ba893fdaf29fa6adeb8c3e ] In using CONFIG_RTC_HCTOSYS, rtc_hctosys() will sync the RTC time to the kernel time as long as rtc_read_time() succeeds. In some power loss situations, our supercapacitor-backed DS1342 RTC comes up with either an unpredictable future time or the default 01/01/00 from the datasheet. The oscillator stop flag (OSF) is set in these scenarios due to the power loss and can be used to determine the validity of the RTC data. This change expands the oscillator stop flag (OSF) handling that has already been implemented for some chips to the ds1341 chip (DS1341 and DS1342 share a datasheet). This handling manages the validity of the RTC data in .read_time and .set_time based on the OSF. Signed-off-by: Meagan Lloyd Reviewed-by: Tyler Hicks Acked-by: Rodolfo Giometti Link: https://lore.kernel.org/r/1749665656-30108-3-git-send-email-meaganlloyd@linux.microsoft.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-ds1307.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 1e621080f666..f8e32f5c37e3 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -273,6 +273,13 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) if (tmp & DS1340_BIT_OSF) return -EINVAL; break; + case ds_1341: + ret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &tmp); + if (ret) + return ret; + if (tmp & DS1337_BIT_OSF) + return -EINVAL; + break; case ds_1388: ret = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &tmp); if (ret) @@ -371,6 +378,10 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) regmap_update_bits(ds1307->regmap, DS1340_REG_FLAG, DS1340_BIT_OSF, 0); break; + case ds_1341: + regmap_update_bits(ds1307->regmap, DS1337_REG_STATUS, + DS1337_BIT_OSF, 0); + break; case ds_1388: regmap_update_bits(ds1307->regmap, DS1388_REG_FLAG, DS1388_BIT_OSF, 0); -- 2.39.5