From nobody Sat Jun 13 10:31:32 2026 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (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 E6B4713D503 for ; Fri, 8 May 2026 00:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778199451; cv=none; b=SxqlJz+EVr8s5GlMcZbxCTM9gkpO9iL1LX0Z0HeycNuc7ws/zNHsH1y8nqCaIEyIFX4BS1CLn4sFF4a73xRlggayCsc8uNZbGPdZkO0xNqcY3JtygOvDKkdrSe2yV3vMXRIYwhddMJXYRXvCVTRnG70dEPct289mErKMUc56aF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778199451; c=relaxed/simple; bh=vRXpJQN29hjLjmK2OxhdxjRCoqHqZIbkPY3vEmdZBxM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WgrLkagI8pegO95zkCI0XJprtBXV2McOK/uboxS/+Lds6PsXaNKwlLNalV92/Z5qe8dkqrs0yKo9W2CS9X+8WzQy1dlb+inmA6XBMpigca4sR5MSuY5pQHfR0BuFyV8FbZMo+TIyXud5Xqr7LNDZpzgSawY6mVp7EUpoO0DYzRk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=zAB6gMDF; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="zAB6gMDF" Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id A936E2C0183; Fri, 8 May 2026 12:17:25 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1778199445; bh=uywkIOOPdprN1Cctz2PBlY9ZoFYz/Hwr0W+QeaQL52M=; h=From:To:Cc:Subject:Date:From; b=zAB6gMDF11tAfixR+bvE5ByKeYKXCKCfShMNhabJ5ebWXO2wIK8tOCmUkYbr8a+5X nHMtE5If5IZfSyLF1zLX70zGefHo6d2a3mVgosA6bRuMBK4BM4cOuHA9D5bch7DbTm S+9q47o3T6phOwMHusnjiRy395/WiOIpDa/Qrtay+7tuLQDdJ0lfctP+tsaGeXCNWG Mt3FUziQzDiBkMCD2/kZhNvD5BYQ7dS372+K3LnJdYvxLyNjB3p7xklDlOJP23RETE cNpCuoleH/uiSXP7Jrn6v64Lu+dcsu/Zy4tDJ1uVBTADflVkeQhOhnMnAqcOXmqoNa ojYMzwLmoblzA== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Fri, 08 May 2026 12:17:25 +1200 Received: from ronand-dl.ws.atlnz.lc (ronand-dl.ws.atlnz.lc [10.33.12.18]) by pat.atlnz.lc (Postfix) with ESMTP id 776DC13ED2A; Fri, 8 May 2026 12:17:25 +1200 (NZST) Received: by ronand-dl.ws.atlnz.lc (Postfix, from userid 1930) id 7277D84004F; Fri, 8 May 2026 12:17:25 +1200 (NZST) From: Ronan Dalton To: alexandre.belloni@bootlin.com Cc: Ronan Dalton , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Tyler Hicks , Sasha Levin , Meagan Lloyd , Rodolfo Giometti , Chris Packham Subject: [PATCH v2] rtc: ds1307: handle oscillator stop flag for ds1337/ds1339/ds3231 Date: Fri, 8 May 2026 12:17:06 +1200 Message-ID: <20260508001709.3681392-1-ronan.dalton@alliedtelesis.co.nz> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.4 cv=FPe4xPos c=1 sm=1 tr=0 ts=69fd2b95 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=NGcC8JguVDcA:10 a=VwQbUJbxAAAA:8 a=P-IC7800AAAA:8 a=FLmnqZ5pAAAA:8 a=yMhMjlubAAAA:8 a=gUfQWItQAAAA:8 a=vhqSDMIX0PFRHOe_07sA:9 a=3ZKOabzyN94A:10 a=d3PnA9EDa4IxuAV0gXij:22 a=8DxQ4-P9FUvTN4rw3Xy2:22 a=Xud5aiJGVNusHZ8q4fKI:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Content-Type: text/plain; charset="utf-8" Prior to commit 48458654659c ("rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe"), the oscillator stop flag (OSF) bit was checked during device probe for the ds1337, ds1339, ds1341, and ds3231 chips; if it was set, it would be cleared and a warning would be logged saying "SET TIME!". Since that commit, the OSF bit is no longer cleared, but the warning is still printed. Directly following that commit, there was no way to get rid of this warning because nothing cleared the OSF bit on these chips. The commit associated with the previous commit, 523923cfd5d6 ("rtc: ds1307: handle oscillator stop flag (OSF) for ds1341"), made proper use of the OSF when getting and setting the time in the RTC. However, the other RTC variants ds1337, ds1339 and ds3231 didn't have a corresponding change made. Given that the OSF bit is no longer cleared at probe time when it is set, the remaining three chips should have the same handling as the ds1341 chip has for the OSF bit. Fix the issue on the ds1337, ds1339 and ds3231 chips by applying the same logic as the ds1341 has to these chips. Note that any devices brought up between the first referenced commit and this one may begin mistrusting the time reported by the RTC until it is set again, if the bit was never explicitly cleared. Note that only the ds1339 was tested with this change, but the datasheets for the other chips contain essentially identical descriptions of the OSF bit so the same change should work. An alternative to this change could be just to revert the referenced two commits and not use the OSF bit at all, apart from logging a warning and clearing it on probe. Signed-off-by: Ronan Dalton Cc: linux-rtc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Alexandre Belloni Cc: Tyler Hicks Cc: Sasha Levin Cc: Meagan Lloyd Cc: Rodolfo Giometti Cc: Chris Packham Fixes: 48458654659c ("rtc: ds1307: remove clear of oscillator stop flag (OS= F) in probe") --- Changes in v2: - Fix hashes of referenced commits drivers/rtc/rtc-ds1307.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 7205c59ff729..edf81b975dec 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -269,6 +269,16 @@ static int ds1307_get_time(struct device *dev, struct = rtc_time *t) if (tmp & DS1338_BIT_OSF) return -EINVAL; break; + case ds_1337: + case ds_1339: + case ds_1341: + case ds_3231: + ret =3D regmap_read(ds1307->regmap, DS1337_REG_STATUS, &tmp); + if (ret) + return ret; + if (tmp & DS1337_BIT_OSF) + return -EINVAL; + break; case ds_1340: if (tmp & DS1340_BIT_nEOSC) return -EINVAL; @@ -279,13 +289,6 @@ static int ds1307_get_time(struct device *dev, struct = rtc_time *t) if (tmp & DS1340_BIT_OSF) return -EINVAL; break; - case ds_1341: - ret =3D regmap_read(ds1307->regmap, DS1337_REG_STATUS, &tmp); - if (ret) - return ret; - if (tmp & DS1337_BIT_OSF) - return -EINVAL; - break; case ds_1388: ret =3D regmap_read(ds1307->regmap, DS1388_REG_FLAG, &tmp); if (ret) @@ -380,14 +383,17 @@ static int ds1307_set_time(struct device *dev, struct= rtc_time *t) regmap_update_bits(ds1307->regmap, DS1307_REG_CONTROL, DS1338_BIT_OSF, 0); break; + case ds_1337: + case ds_1339: + case ds_1341: + case ds_3231: + regmap_update_bits(ds1307->regmap, DS1337_REG_STATUS, + DS1337_BIT_OSF, 0); + break; case ds_1340: 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); --=20 2.53.0