Re: [PATCH v4 03/15] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary

Wolfram Sang <[email protected]>
Newsgroups org.kernel.vger.linux-renesas-soc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc,org.kernel.vger.stable
Message-ID <aoWoTOTbl-ewHeUY@shikoro>
On Wed, Aug 19, 2026 at 11:39:14AM +0100, Prabhakar wrote:
> From: Lad Prabhakar <[email protected]>
> 
> rzn1_rtc_set_alarm() calculates the alarm weekday from the difference
> between the alarm day and the current day of the month. When the alarm
> crosses a month boundary, this difference can become negative. Since
> days_ahead is unsigned, it underflows and results in an incorrect
> weekday being programmed into RZN1_RTC_ALW.
> 
> The RTC core already provides a fully populated struct rtc_time for
> the alarm, including the correct tm_wday. Use tm->tm_wday directly
> instead of recalculating the weekday from the day-of-month.
> 
> This avoids the underflow and ensures alarms scheduled across a month
> boundary use the correct weekday.
> 
> Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> Cc: [email protected]
> Signed-off-by: Lad Prabhakar <[email protected]>

Suggested-by: Wolfram Sang <[email protected]>
Reviewed-by: Wolfram Sang <[email protected]>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmqFqEgACgkQFA3kzBSg
KbZmMhAAocPEAcPVS9Q5+xg5+1T2F0qy5PbXo/vuqmLBIcj68Ms6O3s8ScViXTcB
tKvNbQ6bn+Vt5/TwYw3zyvmvRwBzAsJxGFDd3fkVQLIGwYWmEYH1ca2BaS7GSu1R
cTndE8BIf3zq0/f3TGz6MKOL6K8MitPpmmXHrTC+ulC/sPbwAuyBgbjgaqtXQJFe
0OLudvJTSj3qTv/3V7J8DDliNHI/2IeUlBOB/TYl2uNxUBhmocd330fzdE5KrKXa
OmWwTK6V0AUILbnhgssYK63KKFIhymTR7CWPj0KDoUPPlPjRbSZJBEJ4tkjkY5bu
sawFrTz/3UJSecFU9UZzy2g5ZQSMPVHtq8DNCyEWo6b5g64haNIvMkJ3LzJUFsh8
SQW5RI9EbIymXXfrah5ooAWO6XDpm0YQwoDFua0IVGmON9aiGA5yxAq66Q8AQ2qR
xy8SR4PjHUD7yJEXIqVrOrvJDC2eLouh8I0M2/kbz99BE2SAnhnWiMP+0dITuaml
jqv30ZXuuHsgC6ZNwTqH6/N9v/k5zhhcMdg1s9+Yv7dJ4Oqw/f9Lcz4UquCf2elf
1M7aAyiN7nolcJd4zyehmnyivXwse6mucvd0H0KXZzfXUM5cV8LvEx09MVmthdgi
wZcHUk97lRfCbwJ943OSwNyk7dael+R9Hzu6TrvpOfzVPW8nYG0=
=xr9R
-----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.