Re: [PATCH] rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode

[email protected] Tue, 21 Jul 2026 08:30:21 +0000
Newsgroups org.kernel.vger.linux-rtc
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Read-modify-write on the write-0-to-clear FLAG register can silently clear asynchronous hardware flags.
--

--- Patch [1]: [PATCH] rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode ---
commit 8a134031395cee2cc4d889ef300ebcec83e18b1b
Author: Robert Leussler <[email protected]>
Subject: rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode

This commit fixes the RX8130 wakeup alarm by setting the WADA bit in the
Extension register so the day-of-month alarm works correctly, rather than
failing as an out-of-range day-of-week alarm.

> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -656,13 +656,13 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t)
>  
>  	/* Read control registers. */
>  	ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_EXTENSION, ctl,
>  			       sizeof(ctl));
>  	if (ret < 0)
>  		return ret;
>  
> -	ctl[0] &= RX8130_REG_EXTENSION_WADA;
> +	ctl[0] |= RX8130_REG_EXTENSION_WADA;
>  	ctl[1] &= ~RX8130_REG_FLAG_AF;

[Severity: High]
This is a pre-existing issue, but could this read-modify-write sequence on 
the FLAG register (ctl[1]) silently clear asynchronous hardware flags like 
the Voltage Low Flag (VLF)?

Because the FLAG register uses write-0-to-clear semantics, any bits that
are read as 0 will be written back as 0. If a hardware flag like VLF is
asserted in the slow I2C window between regmap_bulk_read() and
regmap_bulk_write(), wouldn't writing back a 0 accidentally clear it and
potentially hide an oscillator failure from userspace?

This same read-modify-write pattern also appears to be present during
interrupt handling in rx8130_irq().

>  	ctl[2] &= ~RX8130_REG_CONTROL0_AIE;
>  
>  	ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl,
>  				sizeof(ctl));

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1