Re: [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm
From: Lad, Prabhakar
Date: Fri Aug 21 2026 - 16:44:27 EST
Hi Wolfram,
THank you for the review.
On Fri, Aug 21, 2026 at 4:08 PM Wolfram Sang
<wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Aug 21, 2026 at 02:55:55PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
> >
> > 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.
>
I'll drop it.
Cheers,
Prabhakar
> > Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
>
> Other than that:
>
> Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
> Tested-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
>