[{"id":3685028,"web_url":"http://patchwork.ozlabs.org/comment/3685028/","msgid":"<18e8ff9e-5bb9-423b-91c6-5e4b37ef4455@alliedtelesis.co.nz>","list_archive_url":null,"date":"2026-05-01T05:14:33","subject":"Re: [PATCH] rtc: ds1307: handle oscillator stop flag for\n ds1337/ds1339/ds3231","submitter":{"id":27499,"url":"http://patchwork.ozlabs.org/api/people/27499/","name":"Chris Packham","email":"chris.packham@alliedtelesis.co.nz"},"content":"Hi Ronan\n\nOn 01/05/2026 16:46, Ronan Dalton wrote:\n> Prior to commit 6cb0d8587b96 (\"rtc: ds1307: remove clear of oscillator\n> stop flag (OSF) in probe\"), the oscillator stop flag (OSF) bit was\n> checked during device probe for the ds1337, ds1339, ds1341, and ds3231\n> chips; if it was set, it would be cleared and a warning would be logged\n> saying \"SET TIME!\". Since that commit, the OSF bit is no longer cleared,\n> but the warning is still printed.\n>\n> Directly following that commit, there was no way to get rid of this\n> warning because nothing cleared the OSF bit on these chips.\n>\n> The commit associated with the previous commit, ae03a28e12a7 (\"rtc:\n> ds1307: handle oscillator stop flag (OSF) for ds1341\"), made proper use\n> of the OSF when getting and setting the time in the RTC. However, the\n> other RTC variants ds1337, ds1339 and ds3231 didn't have a corresponding\n> change made.\n>\n> Given that the OSF bit is no longer cleared at probe time when it is\n> set, the remaining three chips should have the same handling as the\n> ds1341 chip has for the OSF bit.\n>\n> Fix the issue on the ds1337, ds1339 and ds3231 chips by applying the\n> same logic as the ds1341 has to these chips.\n>\n> Note that any devices brought up between the first referenced commit and\n> this one may begin mistrusting the time reported by the RTC until it is\n> set again, if the bit was never explicitly cleared.\n>\n> Note that only the ds1339 was tested with this change, but the\n> datasheets for the other chips contain essentially identical\n> descriptions of the OSF bit so the same change should work.\n>\n> An alternative to this change could be just to revert the referenced two\n> commits and not use the OSF bit at all, apart from logging a warning and\n> clearing it on probe.\n>\n> Signed-off-by: Ronan Dalton <ronan.dalton@alliedtelesis.co.nz>\n> Cc: linux-rtc@vger.kernel.org\n> Cc: linux-kernel@vger.kernel.org\n> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>\n> Cc: Tyler Hicks <code@tyhicks.com>\n> Cc: Sasha Levin <sashal@kernel.org>\n> Cc: Meagan Lloyd <meaganlloyd@linux.microsoft.com>\n> Cc: Rodolfo Giometti <giometti@enneenne.com>\n> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>\n> Fixes: 6cb0d8587b96 (\"rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe\")\n\nReviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>\n\n> ---\n>   drivers/rtc/rtc-ds1307.c | 28 +++++++++++++++++-----------\n>   1 file changed, 17 insertions(+), 11 deletions(-)\n>\n> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c\n> index 7205c59ff729..edf81b975dec 100644\n> --- a/drivers/rtc/rtc-ds1307.c\n> +++ b/drivers/rtc/rtc-ds1307.c\n> @@ -269,6 +269,16 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)\n>   \t\tif (tmp & DS1338_BIT_OSF)\n>   \t\t\treturn -EINVAL;\n>   \t\tbreak;\n> +\tcase ds_1337:\n> +\tcase ds_1339:\n> +\tcase ds_1341:\n> +\tcase ds_3231:\n> +\t\tret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &tmp);\n> +\t\tif (ret)\n> +\t\t\treturn ret;\n> +\t\tif (tmp & DS1337_BIT_OSF)\n> +\t\t\treturn -EINVAL;\n> +\t\tbreak;\n>   \tcase ds_1340:\n>   \t\tif (tmp & DS1340_BIT_nEOSC)\n>   \t\t\treturn -EINVAL;\n> @@ -279,13 +289,6 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)\n>   \t\tif (tmp & DS1340_BIT_OSF)\n>   \t\t\treturn -EINVAL;\n>   \t\tbreak;\n> -\tcase ds_1341:\n> -\t\tret = regmap_read(ds1307->regmap, DS1337_REG_STATUS, &tmp);\n> -\t\tif (ret)\n> -\t\t\treturn ret;\n> -\t\tif (tmp & DS1337_BIT_OSF)\n> -\t\t\treturn -EINVAL;\n> -\t\tbreak;\n>   \tcase ds_1388:\n>   \t\tret = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &tmp);\n>   \t\tif (ret)\n> @@ -380,14 +383,17 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)\n>   \t\tregmap_update_bits(ds1307->regmap, DS1307_REG_CONTROL,\n>   \t\t\t\t   DS1338_BIT_OSF, 0);\n>   \t\tbreak;\n> +\tcase ds_1337:\n> +\tcase ds_1339:\n> +\tcase ds_1341:\n> +\tcase ds_3231:\n> +\t\tregmap_update_bits(ds1307->regmap, DS1337_REG_STATUS,\n> +\t\t\t\t   DS1337_BIT_OSF, 0);\n> +\t\tbreak;\n>   \tcase ds_1340:\n>   \t\tregmap_update_bits(ds1307->regmap, DS1340_REG_FLAG,\n>   \t\t\t\t   DS1340_BIT_OSF, 0);\n>   \t\tbreak;\n> -\tcase ds_1341:\n> -\t\tregmap_update_bits(ds1307->regmap, DS1337_REG_STATUS,\n> -\t\t\t\t   DS1337_BIT_OSF, 0);\n> -\t\tbreak;\n>   \tcase ds_1388:\n>   \t\tregmap_update_bits(ds1307->regmap, DS1388_REG_FLAG,\n>   \t\t\t\t   DS1388_BIT_OSF, 0);","headers":{"Return-Path":"\n <linux-rtc+bounces-6458-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-rtc@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz\n header.a=rsa-sha256 header.s=mail181024 header.b=m+LG91fZ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-rtc+bounces-6458-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=alliedtelesis.co.nz\n header.i=@alliedtelesis.co.nz header.b=\"m+LG91fZ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=202.36.163.20","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=alliedtelesis.co.nz"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6K3c2RHMz1y04\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 15:14:52 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id E85873017029\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  1 May 2026 05:14:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 44245324B1F;\n\tFri,  1 May 2026 05:14:39 +0000 (UTC)","from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz\n [202.36.163.20])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B1EBF2D0C7B\n\tfor <linux-rtc@vger.kernel.org>; Fri,  1 May 2026 05:14:35 +0000 (UTC)","from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(Client did not present a certificate)\n\tby gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 939AA2C0453;\n\tFri,  1 May 2026 17:14:33 +1200 (NZST)","from svr-chch-ex2.atlnz.lc (Not Verified[2001:df5:b000:bc8::76]) by\n svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305)\n\tid <B69f436b90001>; Fri, 01 May 2026 17:14:33 +1200","from svr-chch-ex2.atlnz.lc (2001:df5:b000:bc8:f753:6de:11c0:a008) by\n svr-chch-ex2.atlnz.lc (2001:df5:b000:bc8:f753:6de:11c0:a008) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1748.39; Fri, 1 May 2026 17:14:33 +1200","from svr-chch-ex2.atlnz.lc ([fe80::a9eb:c9b7:8b52:9567]) by\n svr-chch-ex2.atlnz.lc ([fe80::a9eb:c9b7:8b52:9567%15]) with mapi id\n 15.02.1748.039; Fri, 1 May 2026 17:14:33 +1200"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777612479; cv=none;\n b=gnzM8re5PQvGXwaf2+JWMJpGKkTC4PEesIkHDecYvEjinZh2L+ewZZl9/OYQl8L2nX/bKT3t1H3gGVIUkPSlz0bFZ9tvR6an3cCpkgrwYudDQ6Yn3Wo+xXmZnkx0gNtcjITfVwDSjf9aHDAX4RSHGXPYuppcbQIvJGhHPrtfiJ0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777612479; c=relaxed/simple;\n\tbh=DTGxvOhj0zLw3HPmvxh44+w4GeXTagErMSRbW9DnE6A=;\n\th=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To:\n\t Content-Type:MIME-Version;\n b=slCwXcdFPZdNjSR5xymq1VlR2OponIPFHYoqL+hBDgg8ummItJSfl0kefOeUy8xFUg+LA3FQJ3m/9mC+cvd3H/jBybzg47opaUuXMV/17G8HsC2XrfgC0TEiQa5i7iy2lyhdtoe+D6H5SDnbmUNBPc5e9rRMLWKCr/yWgOBOD40=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz;\n spf=pass smtp.mailfrom=alliedtelesis.co.nz;\n dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz\n header.i=@alliedtelesis.co.nz header.b=m+LG91fZ;\n arc=none smtp.client-ip=202.36.163.20","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz;\n\ts=mail181024; t=1777612473;\n\tbh=DTGxvOhj0zLw3HPmvxh44+w4GeXTagErMSRbW9DnE6A=;\n\th=From:To:CC:Subject:Date:References:In-Reply-To:From;\n\tb=m+LG91fZ/If3nSfuFYsS9k5rUHkWbBnARQl9Ex5OvE4anUMc2EyKwCJ9voJIU9BXR\n\t 7LqmgrZetg0E9qPbe3uszrp2VTwYb6Ytmib0DeeX9R5b+3BLLlnmjEojwrN65iAO+J\n\t 5YEJe5MkFqDQtqKGb4dnII5DzEAMabgMnuXaWIHrZe+I6zFLf/D/zjbnJM1sEOjpgT\n\t Vb00JTnhTfv8mxjW5ZJ4nXSfSmYA3hb0QUBniKzG9YzUxv2bUu7o7yh6mGzKMWlO6z\n\t XlBhcThdqTXLO3/ylZJKTqPDOGp4RIGww4qsY6MbtJmP3wH6UtgUcjp2A8RnOl5tJy\n\t kXx9LDoO3PHpQ==","From":"Chris Packham <Chris.Packham@alliedtelesis.co.nz>","To":"Ronan Dalton <Ronan.Dalton@alliedtelesis.co.nz>,\n\t\"alexandre.belloni@bootlin.com\" <alexandre.belloni@bootlin.com>","CC":"\"linux-rtc@vger.kernel.org\" <linux-rtc@vger.kernel.org>,\n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>, Tyler Hicks\n\t<code@tyhicks.com>, Sasha Levin <sashal@kernel.org>, Meagan Lloyd\n\t<meaganlloyd@linux.microsoft.com>, Rodolfo Giometti <giometti@enneenne.com>","Subject":"Re: [PATCH] rtc: ds1307: handle oscillator stop flag for\n ds1337/ds1339/ds3231","Thread-Topic":"[PATCH] rtc: ds1307: handle oscillator stop flag for\n ds1337/ds1339/ds3231","Thread-Index":"AQHc2SYs/dzU9DqYhU6v2CJYbHsOHLX311IA","Date":"Fri, 1 May 2026 05:14:33 +0000","Message-ID":"<18e8ff9e-5bb9-423b-91c6-5e4b37ef4455@alliedtelesis.co.nz>","References":"<20260501044657.1003980-2-ronan.dalton@alliedtelesis.co.nz>","In-Reply-To":"<20260501044657.1003980-2-ronan.dalton@alliedtelesis.co.nz>","Accept-Language":"en-NZ, en-US","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","Content-Type":"text/plain; charset=\"utf-8\"","Content-ID":"<B0ADF9565BE6E84B8CD1228554648143@alliedtelesis.co.nz>","Content-Transfer-Encoding":"base64","Precedence":"bulk","X-Mailing-List":"linux-rtc@vger.kernel.org","List-Id":"<linux-rtc.vger.kernel.org>","List-Subscribe":"<mailto:linux-rtc+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-rtc+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","X-SEG-SpamProfiler-Analysis":"v=2.4 cv=FPe4xPos c=1 sm=1 tr=0 ts=69f436b9\n a=Xf/6aR1Nyvzi7BryhOrcLQ==:117 a=xqWC_Br6kY4A:10 a=drD7vYo3kbIA:10\n a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VwQbUJbxAAAA:8 a=P-IC7800AAAA:8\n a=FLmnqZ5pAAAA:8 a=yMhMjlubAAAA:8 a=gUfQWItQAAAA:8 a=u5EYUK4S4NM-VeQ87e0A:9\n a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=d3PnA9EDa4IxuAV0gXij:22\n a=8DxQ4-P9FUvTN4rw3Xy2:22 a=Xud5aiJGVNusHZ8q4fKI:22","X-SEG-SpamProfiler-Score":"0"}}]