lkml.org 
[lkml]   [2012]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [rtc-linux] [PATCH] RTC: Add driver for NXP PCF8523 RTC chip
> > +/*
> > + * In the routines that deal directly with the pcf8523 hardware, we use
> > + * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.

Do we really need to limit year w.r.t. epoch?
Instead why don't you define a macro for base year in your driver itself?
With this, the same driver may be usable forever, without any modifications
except for this macro (which also need to change once in a century).
If you use year w.r.t. epoch, this driver definitely need modification before year 2070.

> > + */
> > +static int pcf8523_get_datetime(struct i2c_client *client, struct rtc_time
> *tm)
> > +{
> > + struct pcf8523 *pcf8523 = i2c_get_clientdata(client);
> > + unsigned char buf[14] = { PCF8523_REG_CTL1 };
> > + /* the clock can give out invalid datetime, but we cannot return
> > + * -EINVAL otherwise hwclock will refuse to set the time on bootup.
> > + */

Somehow I feel to set the RTC to a known time, probably the BASE year, in such
error cases.
>
> This comment seems to imply that the driver allows hwclock to set the
> time to something which we know is incorrect? If so, wouldn't it be
> better to leave the time at something obviously wrong, such as 1 Jan
> 1970?
>
> > + if (rtc_valid_tm(tm) < 0)
> > + dev_err(&client->dev, "retrieved date/time is not valid.\n");
> > +
> > + return 0;
> > +}


\
 
 \ /
  Last update: 2012-02-02 04:27    [from the cache]
©2003-2011 Jasper Spaans