From nobody Sun Jun 14 07:48:40 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 13BA027CB35 for ; Fri, 1 May 2026 04:51:36 +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=1777611099; cv=none; b=M1lMufto66R5l/iRXc8McnmBYhrZqzyifG547fV7lrEIoAOmetRHeGuCab8m8DqOPmMMBBBzeHsRjrL+5Q4OK1bOV3PJDMfXQAWAqkvCZ+hOLklxkl60oyh74WDXAqkJBZQ6Txxui7Woi0ZcqFhGAQHUf5tggCf9BVzGYfeNqhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777611099; c=relaxed/simple; bh=zgYKV0g8h/sbwHqqHgRPQ20vs2Bs5Np7r5DJDXulGhw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZUvnllQft0GIFAFddv3Elygss6PgnjjSw4jvkEvveFT8BE8ci5OlhTfWyScwCDi73CJF+wMbt47R0RhSdCac8IFa2CKHJzZEDcoQRluJaBIA1Nu2wir4d8pkuBXy+1GWgSdstSVPQ4t9tWc6qtFKZ/RiLE36t7igMw6XJEqZj1Y= 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=Mi8G2Amy; 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="Mi8G2Amy" 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 7B8A22C023A; Fri, 1 May 2026 16:51:28 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1777611088; bh=jmTSEhdwhbLZM471o2oxoaWmb7pz1B/7IQxuHd6Pubs=; h=From:To:Cc:Subject:Date:From; b=Mi8G2Amyw43NH34OqQmWrsjNRf5BFEg/RV3lN4z2B/rGKVXnzhxzqQu3Tg4tbS2/D LihPvfUijmg6lPhWxQRxZdy4muxjS7ztoQziacZRgw1p4VcZ8d+YSm+tAjWiWyDRuA sJKAAk7HjzWqEZ7BVab+3xCt0zheGmNubqsVHsXWXlSzneoQ83m1aNqDlhku2MgJFe 4Iw0RNtW66kdQgPdN+mx3Hanb4uKr3j7odG8m0tZGRS/QljmcTAqtlXCbJTOutbP0L PnvYGdY2+Rnke97Zj3K/OhiDZubNgz+JMQ61ShHYSeGxyiVMOnd3UNU2VFrRrWkLdk xtdsuiZYZK9Dw== 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, 01 May 2026 16:51:28 +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 5565C13EC7E; Fri, 1 May 2026 16:51:28 +1200 (NZST) Received: by ronand-dl.ws.atlnz.lc (Postfix, from userid 1930) id 4FE0484004F; Fri, 1 May 2026 16:51:28 +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] rtc: ds1307: handle oscillator stop flag for ds1337/ds1339/ds3231 Date: Fri, 1 May 2026 16:46:10 +1200 Message-ID: <20260501044657.1003980-2-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=69f43150 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 6cb0d8587b96 ("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, ae03a28e12a7 ("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: 6cb0d8587b96 ("rtc: ds1307: remove clear of oscillator stop flag (OS= F) in probe") Reviewed-by: Chris Packham Reviewed-by: Meagan Lloyd Reviewed-by: Tyler Hicks --- 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