lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: 
 <TY7PR01MB14818A301AD396B57AC28919FCDB2A@TY7PR01MB14818.jpnprd01.prod.outlook.com>
Date: Wed, 24 Dec 2025 05:06:24 +0000
From: <nobuhiro.iwamatsu.x90@...l.toshiba>
To: <fredrik.m.olsson@...s.com>, <alexandre.belloni@...tlin.com>,
        <robh@...nel.org>, <krzk+dt@...nel.org>, <conor+dt@...nel.org>
CC: <linux-rtc@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <kernel@...s.com>
Subject: RE: [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for
 rx8130

Hi Fredrik,

> -----Original Message-----
> From: Fredrik M Olsson <fredrik.m.olsson@...s.com>
> Sent: Friday, December 19, 2025 9:11 PM
> To: Alexandre Belloni <alexandre.belloni@...tlin.com>; Rob Herring
> <robh@...nel.org>; Krzysztof Kozlowski <krzk+dt@...nel.org>; Conor Dooley
> <conor+dt@...nel.org>; iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@...l.toshiba>
> Cc: linux-rtc@...r.kernel.org; devicetree@...r.kernel.org;
> linux-kernel@...r.kernel.org; Fredrik M Olsson <fredrik.m.olsson@...s.com>;
> kernel@...s.com
> Subject: [PATCH 2/4] rtc: ds1307: Fix off-by-one issue with wday for rx8130
> 
> The RTC represent each weekday with a individual bit set in the WDAY register,
> where the 0th bit represent the first day of the week and the 6th bit represents
> the last day of the week. For each passed day the chip performs a
> rotary-left-shift by one to advance the weekday by one.
> 
> The tm_wday field represent weekdays by a value in the range of 0-6.
> 
> The fls() function return the bit index of the last bit set. To handle when there
> are no bits set it will return 0, and if the 0th bit is set it will return 1, and if the
> 1st bit is set it will return 2, and so on.
> 
> In order to make the result of the fls() function fall into the expected range of
> 0-6 (instead of 1-7) this patch subtracts one from the result (which matches
> how the value is written in ds1307_set_time()).
> 
> Fixes: 204756f016726 ("rtc: ds1307: Fix wday settings for rx8130")
> Signed-off-by: Fredrik M Olsson <fredrik.m.olsson@...s.com>

Thanks for fixing.

Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@...l.toshiba>

Best regards,
  Nobuhiro

> ---
>  drivers/rtc/rtc-ds1307.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index
> 7205c59ff729..bf42c250ea7d 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -308,7 +308,7 @@ static int ds1307_get_time(struct device *dev, struct
> rtc_time *t)
>  	t->tm_hour = bcd2bin(tmp);
>  	/* rx8130 is bit position, not BCD */
>  	if (ds1307->type == rx_8130)
> -		t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f);
> +		t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f) - 1;
>  	else
>  		t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1;
>  	t->tm_mday = bcd2bin(regs[DS1307_REG_MDAY] & 0x3f);
> 
> --
> 2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ