Re: [PATCH] m68k: Fix off-by-one calendar month

From: Arnd Bergmann
Date: Tue Apr 24 2018 - 08:54:26 EST


On Tue, Apr 24, 2018 at 12:37 PM, Alexandre Belloni
<alexandre.belloni@xxxxxxxxxxx> wrote:
> On 24/04/2018 12:06:30+0200, Geert Uytterhoeven wrote:
>>
>> On Mon, Apr 23, 2018 at 3:02 AM, Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:
>> <snip>
>>
>> > --- a/arch/m68k/kernel/time.c
>> > +++ b/arch/m68k/kernel/time.c
>> > @@ -74,17 +74,17 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
>> > void read_persistent_clock(struct timespec *ts)
>> > {
>> > struct rtc_time time;
>> > +
>> > ts->tv_sec = 0;
>> > ts->tv_nsec = 0;
>> >
>> > - if (mach_hwclk) {
>> > - mach_hwclk(0, &time);
>> > + if (!mach_hwclk)
>> > + return;
>> > +
>> > + mach_hwclk(0, &time);
>> >
>> > - if ((time.tm_year += 1900) < 1970)
>> > - time.tm_year += 100;
>
> Note that this change may break existing users.

I had the same thought but then realized that the +=100 logic was simply
moved into the individual drivers, so the behavior should not change here.

> I'm perfectly fine with
> it as doing this is generally wrong anyway and this is something I'd
> like to see eliminated.

I think most of the m68k RTC hardware uses two-digit BCD year numbers,
so we can't just remove it without implementing something else to
lift the RTC into the current century.

Arnd