[PATCH] powerpc/time: Calculate proper wday

Joakim Tjernlund Joakim.Tjernlund at infinera.com
Tue Sep 18 18:27:41 AEST 2018


On Tue, 2018-09-18 at 10:08 +0200, Mathieu Malaterre wrote:
> 
> 
> On Wed, Aug 29, 2018 at 10:03 AM Joakim Tjernlund <joakim.tjernlund at infinera.com> wrote:
> >
> > to_tm() hardcodes wday to -1 as "No-one uses the day of the week".
> > But recently rtc driver ds1307 does care and tries to correct wday.
> >
> > Add wday calculation(stolen from rtc_time64_to_tm) to to_tm() to please ds1307.
> 
> Is this still an issue after:
> 
> 34efabe41895 powerpc: remove unused to_tm() helper

No, it is not an issue anymore. You can drop this patch.

 Jocke

> 
> ?
> 
> > Signed-off-by: Joakim Tjernlund <joakim.tjernlund at infinera.com>
> > ---
> >  arch/powerpc/kernel/time.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> > index fe6f3a285455..f4a09ee01944 100644
> > --- a/arch/powerpc/kernel/time.c
> > +++ b/arch/powerpc/kernel/time.c
> > @@ -1160,6 +1160,9 @@ void to_tm(int tim, struct rtc_time * tm)
> >         day = tim / SECDAY;
> >         hms = tim % SECDAY;
> >
> > +       /* day of the week, 1970-01-01 was a Thursday */
> > +       tm->tm_wday = (day + 4) % 7;
> > +
> >         /* Hours, minutes, seconds are easy */
> >         tm->tm_hour = hms / 3600;
> >         tm->tm_min = (hms % 3600) / 60;
> > @@ -1180,11 +1183,6 @@ void to_tm(int tim, struct rtc_time * tm)
> >
> >         /* Days are what is left over (+1) from all that. */
> >         tm->tm_mday = day + 1;
> > -
> > -       /*
> > -        * No-one uses the day of the week.
> > -        */
> > -       tm->tm_wday = -1;
> >  }
> >  EXPORT_SYMBOL(to_tm);
> >
> > --
> > 2.16.4



More information about the Linuxppc-dev mailing list