Re: [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm

Wolfram Sang <[email protected]>
Newsgroups org.kernel.vger.linux-rtc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-renesas-soc,org.kernel.vger.stable
Message-ID <aohqChLVqwiTpICo@ninjato>
On Fri, Aug 21, 2026 at 02:55:55PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <[email protected]>
> 
> RZN1_RTC_ALW is a weekday bitmask where bit N represents weekday N.
> When no alarm has been configured, the register has its power-on-reset
> value of zero.
> 
> rzn1_rtc_read_alarm() uses fls() to convert the weekday bitmask into a
> weekday number. When RZN1_RTC_ALW is zero, fls(0) returns zero and
> fls(wday) - 1 evaluates to -1. This invalid weekday is then used to
> calculate the alarm date and can either leave tm_wday set to -1 or
> produce a fabricated alarm date.
> 
> Treat a zero RZN1_RTC_ALW value as an unset alarm weekday and return
> without calculating the alarm date. Move reading RZN1_RTC_CTL1 before
> this check so that alrm->enabled is updated for both configured and
> unconfigured alarms.
> 
> On a cold-booted board with no alarm configured, the following was
> observed before the fix:
> 
>     root@rzn2h-evk:~# cat /proc/driver/rtc
>     rtc_time        : 00:00:19
>     rtc_date        : 2000-01-01
>     alrm_time       : 00:00:00
>     alrm_date       : 2000-01-07
>     alarm_IRQ       : no
>     alrm_pending    : no
>     update IRQ enabled      : no
>     periodic IRQ enabled    : no
>     periodic IRQ frequency  : 1
>     max user IRQ frequency  : 64
>     24hr            : yes
> 
> After the fix:
> 
>     root@rzn2h-evk:~# cat /proc/driver/rtc
>     rtc_time        : 00:00:25
>     rtc_date        : 2000-01-01
>     alrm_time       : 00:00:00
>     alrm_date       : 2000-01-01
>     alarm_IRQ       : no
>     alrm_pending    : no
>     update IRQ enabled      : no
>     periodic IRQ enabled    : no
>     periodic IRQ frequency  : 1
>     max user IRQ frequency  : 64
>     24hr            : yes

The output of the tests could be dropped IMO, but I'll leave this for
the RTC maintainers.

> Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> Cc: [email protected]
> Signed-off-by: Lad Prabhakar <[email protected]>

Other than that:

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

iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmqIagoACgkQFA3kzBSg
Kbanig//alOlGkCyf35IsdJBWIIAPBCYVu57zK1+oNcGjQN4NSHA0Vv242bkQvga
VVCDonOLfK9Ej7YKBB9t1tqa59eosiW9/bqSVCnqC/AmQHnjnF6RGBOdbIx+KR9Q
8+lePfPtN/hbGAy1uCzT5uSNY06JaZ9/kNxUNv0BqPQX4QLzwjvFiZSk0SPAQ+0u
oE0n9HLlm+AIrlR2Xy/h7vN9rR5W+lih+fiW/kt9CsV9QDcPyjU3qD8FwXFIf038
EX38SEVd02xqgCOqQV/lKQrJMxgmQlCgyCoVhjhhnBCFU1FDO5OfzHg9xau60npz
eMvHFDPOKZZK0SPCJW2eFE5LOXSElO8btK2WFtvOCMsx4b93284b/7YtWX92o89s
/IR2lzbFdMhrxPE0UP5E+RjmtG6Rf6vLiics90h+VBNtCFeX/TscGrA0n+KYt1ZH
+kA3IusRRhIjkbAz7Cu/LWBHiGE//nqGDi7uralGJ43/svARimBLomWoibPx4hlP
RpU3yvnIBV33O8WKjBPUG0Jsfo/w7gaP7SKGjtGo8JSX7HXNlJrLxWnU85/PChkI
Yo0RjHceJo+Ab2b6UWKlNYbcj3UNls7B8QaurZzSRLHxc+zMvjjXRFbgGMAkvJtM
I6nP8fbgguyUXsLJ4Jayr2MPOZQLpSNdIZZjEGM6OKivx0DR3MI=
=Mil6
-----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.