[PATCH 5/5] dm: rtc: Try to handle the localtime() race

Simon Glass sjg at chromium.org
Mon Aug 1 21:13:20 CEST 2022


Hi Heinrich,

On Mon, 1 Aug 2022 at 09:00, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 8/1/22 15:58, Simon Glass wrote:
> > At present the sandbox timer uses localtime() which can jump around twice
> > a year when daylight-saving time changes.
> >
> > It would be tricky to make use of gmtime() since we still need to present
> > the time in local time, as seems to be required by U-Boot's RTC interface.
> >
> > The problem can only happen once, so use a loop to detect it and try
> > again. This should be sufficient to detect either a change in the 'second'
> > value, or a daylight-saving change. We can assume that the latter also
> > incorporates a 'second' change, so there is no need to loop more than
> > twice.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
>
> Linux systems tend to use UTC on the RTC. There is no reason for
> sandbox_defconfig to deviate. Please, avoid all this complication by
> reading the time with gmtime() instead of localtime().

That is an API change...how will we show the local time in that case?
I suppose we need to add this concept to rtc.h ?

Regards,
Simon


More information about the U-Boot mailing list