* [PATCH] rtc: ds1307: Check the calibration register read result
@ 2026-11-12 7:16 Zhu Jun
2026-11-12 7:19 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-12 7:16 UTC (permalink / raw)
To: alexandre.belloni; +Cc: linux-rtc, linux-kernel, Zhu Jun
m41txx_rtc_read_offset() ignores regmap_read() failures and calculates
the calibration offset from an uninitialized control register value.
An I2C transfer error can therefore be reported as a successful offset
read with an arbitrary result.
Return the read error before decoding the register or updating the
caller's offset.
Fixes: 79230ff64167 ("rtc: ds1307: add offset sysfs for mt41txx chips.")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/rtc/rtc-ds1307.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 8ab28cc2f181..2e9f0b3d2a93 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -853,9 +853,12 @@ static int m41txx_rtc_read_offset(struct device *dev, long *offset)
{
struct ds1307 *ds1307 = dev_get_drvdata(dev);
unsigned int ctrl_reg;
+ int ret;
u8 val;
- regmap_read(ds1307->regmap, M41TXX_REG_CONTROL, &ctrl_reg);
+ ret = regmap_read(ds1307->regmap, M41TXX_REG_CONTROL, &ctrl_reg);
+ if (ret)
+ return ret;
val = ctrl_reg & M41TXX_M_CALIBRATION;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: ds1307: Check the calibration register read result
2026-11-12 7:16 [PATCH] rtc: ds1307: Check the calibration register read result Zhu Jun
@ 2026-11-12 7:19 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-12 7:19 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-rtc, Alexandre Belloni
> m41txx_rtc_read_offset() ignores regmap_read() failures and calculates
> the calibration offset from an uninitialized control register value.
> An I2C transfer error can therefore be reported as a successful offset
> read with an arbitrary result.
>
> Return the read error before decoding the register or updating the
> caller's offset.
>
> Fixes: 79230ff64167 ("rtc: ds1307: add offset sysfs for mt41txx chips.")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112071627.154412-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 7:16 [PATCH] rtc: ds1307: Check the calibration register read result Zhu Jun
2026-11-12 7:19 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox