Re: [PATCH v3 2/5] rtc: s35390a: Add missing newline to dev_err

Markus Probst <[email protected]>
Newsgroups org.kernel.vger.linux-rtc,dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
On Wed, 2026-08-05 at 20:30 +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] Desynchronization between software state and hardware 24-hour mode after initialization causes time corruption.
> - [High] Alarm hour formatting erroneously adds PM bit in 24-hour mode, causing PM alarms to permanently fail.
> --
> 
> --- Patch [2]: [PATCH v3 2/5] rtc: s35390a: Add missing newline to dev_err ---
> commit 60df926a63720bd3dbdd3b4991c3149af682d4b0
> Author: Markus Probst <[email protected]>
> 
> rtc: s35390a: Add missing newline to dev_err
> 
> This commit fixes a missing newline character in the dev_err call
> within s35390a_probe() when alarm disabling fails.
> 
> > diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> > index b72eef4fb0997..4cfe7034c5165 100644
> > --- a/drivers/rtc/rtc-s35390a.c
> > +++ b/drivers/rtc/rtc-s35390a.c
> > @@ -494,7 +494,7 @@ static int s35390a_probe(struct i2c_client *client)
> >  		buf = 0;
> >  		err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &buf, 1);
> >  		if (err < 0) {
> > -			dev_err(dev, "error disabling alarm");
> > +			dev_err(dev, "error disabling alarm\n");
> >  			return err;
> >  		}
> >  	} else {
> 
> While reviewing this driver, I noticed a couple of pre-existing issues.
> 
> [Severity: High]
> This isn't a bug introduced by this patch, but looking at s35390a_init(),
> is it possible for the software state to become desynchronized from the
> hardware 24-hour mode?
> 
> drivers/rtc/rtc-s35390a.c:s35390a_init() {
>     ...
>     initialize:
> 	buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
> 	ret = s35390a_set_reg(s35390a, S35390A_CMD_STATUS1, &buf, 1);
>     ...
> }
> 
> When this reset is triggered (for instance, via the RTC_VL_CLR ioctl or when
> a brownout is detected), the hardware is explicitly switched to 24-hour mode
> by setting S35390A_FLAG_24H.
> 
> However, s35390a->twentyfourhour is not updated to 1.
> 
> Does this mean subsequent calls to rtc_set_time() will incorrectly use the
> 12-hour formatting rules if twentyfourhour was previously 0, sending invalid
> BCD formats to the chip and corrupting the timekeeping for PM hours?
Yes.
> 
> 
> [Severity: High]
> This is a pre-existing issue, but I have a question about how the alarm hour
> is formatted when the chip is operating in 24-hour mode:
> 
> drivers/rtc/rtc-s35390a.c:s35390a_rtc_set_alarm() {
>     ...
> 	buf[S35390A_ALRM_BYTE_HOURS] = s35390a_hr2reg(s35390a,
> 			alm->time.tm_hour) | 0x80;
> 	buf[S35390A_ALRM_BYTE_MINS] = bin2bcd(alm->time.tm_min) | 0x80;
> 
> 	if (alm->time.tm_hour >= 12)
> 		buf[S35390A_ALRM_BYTE_HOURS] |= 0x40;
>     ...
> }
> 
> If the chip is in 24-hour mode, s35390a_hr2reg() will already return the
> standard 24-hour BCD value (e.g., 0x15 for 15:00).
> 
> Could the unconditional bitwise-OR with 0x40 (the PM bit) corrupt the alarm
> time value in 24-hour mode, causing PM alarms to permanently fail because the
> hardware comparator expects a standard 24-hour BCD value?
No. AM/PM bit gets ignored in 24-hour mode.
signature.asc (application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmp7ZAcbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyAAoJEDR2H/jnrUPSpfEP/jRZ+MH9v/Z+yMa5vJHY
79OSrDJDyjGRJpk/g7Iq/fjh3li0EY9J5BBmWZl4wSUItpUN9Z0QVPNxZQNShXPT
03N5QavT701BN6GRe4B+zxDLq/CxkjFAILiJD+l2SIbKDsae+OhpZ43CP93d8mg1
g6AaW9S+FJsMGgm3u+SJOR4YiFHzc3+j2fHSM4tFh7fRs4lNoagd+0E2qdD7d5t3
sy3RcJs4q6VNg91R4dFlnzKa+Pi1FXKNxQ83j4CeaiGinskv11qr7o+Ey3GUcAx1
0tFX6y5jf7UDGPGStQlc1x1u9gPsIHqPRuj+sXS0fvQywU12eADiuTBDmpWT1+0e
TTDAoAKZl0MNufUnKjuvSEydF0tmh4fdQuzZi1HQsnNHFtqZkqs3txrS0l0qnY8F
CVxuy6fXxp/AdQ60VYfl55U5uP9SgO2mHscmaA63p8p+prUJfG4i2AlUXnShWZZ1
nZksB6rcwBwZaY0SI9ND9BiqF724tFl9zbF+ynKGcn3HI+5G3relzKCDzb90EOVV
EeE/LAXGPlqdTDFtivB0jYXn3/KuksF1sQ6kfgYfge6YOQrvbk7pvkhb/6NYMd8o
DULu5wuw6fBOJ87+kjergTfkgUEYt7YpB7ZzEsOVfRs/GZhUCu9EKSc/llQ3Y1po
AB0LLhj4ja7DHN9l4dtmrn/H
=hu7G
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.