public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
@ 2024-10-06  0:15 Nobuhiro Iwamatsu
  2024-10-06  0:58 ` Maciej W. Rozycki
  2024-10-07 13:59 ` Alexandre Belloni
  0 siblings, 2 replies; 4+ messages in thread
From: Nobuhiro Iwamatsu @ 2024-10-06  0:15 UTC (permalink / raw)
  To: alexandre.belloni, linux-rtc, linux-kernel; +Cc: Nobuhiro Iwamatsu

The is_leap_year() for determining leap year is provided in rtc lib.
This uses is_leap_year() instead of its own leap year determination
routine.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 drivers/rtc/rtc-mc146818-lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
index 651bf3c279c74..ce4d68de05831 100644
--- a/drivers/rtc/rtc-mc146818-lib.c
+++ b/drivers/rtc/rtc-mc146818-lib.c
@@ -232,8 +232,7 @@ int mc146818_set_time(struct rtc_time *time)
 
 #ifdef CONFIG_MACH_DECSTATION
 	real_yrs = yrs;
-	leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
-			!((yrs + 1900) % 400));
+	leap_yr = is_leap_year(yrs + 1900);
 	yrs = 72;
 
 	/*
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
  2024-10-06  0:15 [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years Nobuhiro Iwamatsu
@ 2024-10-06  0:58 ` Maciej W. Rozycki
  2024-10-07 13:59 ` Alexandre Belloni
  1 sibling, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2024-10-06  0:58 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu; +Cc: alexandre.belloni, linux-rtc, linux-kernel

On Sun, 6 Oct 2024, Nobuhiro Iwamatsu wrote:

> The is_leap_year() for determining leap year is provided in rtc lib.
> This uses is_leap_year() instead of its own leap year determination
> routine.

 Good catch!  As a DECstation maintainer:

Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>

Thank you for making this clean-up to this 22 years old code!

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
  2024-10-06  0:15 [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years Nobuhiro Iwamatsu
  2024-10-06  0:58 ` Maciej W. Rozycki
@ 2024-10-07 13:59 ` Alexandre Belloni
  2024-10-07 23:23   ` Nobuhiro Iwamatsu
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2024-10-07 13:59 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu; +Cc: linux-rtc, linux-kernel

Hello,

On 06/10/2024 09:15:53+0900, Nobuhiro Iwamatsu wrote:
> The is_leap_year() for determining leap year is provided in rtc lib.
> This uses is_leap_year() instead of its own leap year determination
> routine.
> 
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>  drivers/rtc/rtc-mc146818-lib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
> index 651bf3c279c74..ce4d68de05831 100644
> --- a/drivers/rtc/rtc-mc146818-lib.c
> +++ b/drivers/rtc/rtc-mc146818-lib.c
> @@ -232,8 +232,7 @@ int mc146818_set_time(struct rtc_time *time)
>  
>  #ifdef CONFIG_MACH_DECSTATION
>  	real_yrs = yrs;
> -	leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
> -			!((yrs + 1900) % 400));
> +	leap_yr = is_leap_year(yrs + 1900);

Could you also eliminate the leap_yr variable?

Thanks!

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
  2024-10-07 13:59 ` Alexandre Belloni
@ 2024-10-07 23:23   ` Nobuhiro Iwamatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Nobuhiro Iwamatsu @ 2024-10-07 23:23 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel

Hi,

2024年10月7日(月) 22:59 Alexandre Belloni <alexandre.belloni@bootlin.com>:
>
> Hello,
>
> On 06/10/2024 09:15:53+0900, Nobuhiro Iwamatsu wrote:
> > The is_leap_year() for determining leap year is provided in rtc lib.
> > This uses is_leap_year() instead of its own leap year determination
> > routine.
> >
> > Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> > ---
> >  drivers/rtc/rtc-mc146818-lib.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
> > index 651bf3c279c74..ce4d68de05831 100644
> > --- a/drivers/rtc/rtc-mc146818-lib.c
> > +++ b/drivers/rtc/rtc-mc146818-lib.c
> > @@ -232,8 +232,7 @@ int mc146818_set_time(struct rtc_time *time)
> >
> >  #ifdef CONFIG_MACH_DECSTATION
> >       real_yrs = yrs;
> > -     leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
> > -                     !((yrs + 1900) % 400));
> > +     leap_yr = is_leap_year(yrs + 1900);
>
> Could you also eliminate the leap_yr variable?
>

Yes, I will send v2  patch that deleted it.

> Thanks!

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org / kernel.org}
   GPG ID: 32247FBB40AD1FA6

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-07 23:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06  0:15 [PATCH] rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years Nobuhiro Iwamatsu
2024-10-06  0:58 ` Maciej W. Rozycki
2024-10-07 13:59 ` Alexandre Belloni
2024-10-07 23:23   ` Nobuhiro Iwamatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox