Re: [PATCH v2 1/2] rtc: wilco-ec: Remove yday and wday calculations

From: Nick Crews
Date: Wed Sep 25 2019 - 16:13:59 EST


Hi Alexandre,

Sorry to be a pain, but I passed this by some other Chrome OS
kernel engineers, and when the HW gives a bogus time we
want logging at a more severe level than the dev_dbg() call
in the core, so I'm going to send another revision. It's going to
require duplicated calls to rtc_valid_tm(), but we feel that it is
required.

Thanks,
Nick

On Mon, Sep 23, 2019 at 2:19 PM Alexandre Belloni
<alexandre.belloni@xxxxxxxxxxx> wrote:
>
> On 23/09/2019 11:20:42-0600, Nick Crews wrote:
> > > This is coming from struct tm, it is part of C89 but I think I was not
> > > born when this decision was made. man rtc properly reports that those
> > > fields are unused and no userspace tools are actually making use of
> > > them. Nobody cares about the broken down representation of the time.
> > > What is done is use the ioctl then mktime to have a UNIX timestamp.
> > >
> > > "The mktime function ignores the specified contents of the tm_wday,
> > > tm_yday, tm_gmtoff, and tm_zone members of the broken-down time
> > > structure. It uses the values of the other components to determine the
> > > calendar time; itâs permissible for these components to have
> > > unnormalized values outside their normal ranges. The last thing that
> > > mktime does is adjust the components of the brokentime structure,
> > > including the members that were initially ignored."
> >
> > This is very non-obvious and I only knew this from talking to you,
> > Alexandre. Perhaps we should add this note to the RTC core,
> > such as in the description for rtc_class_ops?
> >
>
> I'm planning to add documentation on what should be done in an RTC
> driver, I'll ensure to add something on this topic.
>
> > For this patch, do you want me to make any further changes?
> >
>
> No need for any changes, however, I can't apply it right now because we
> are in the middle of the merge window.
>
>
> --
> Alexandre Belloni, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com