RE: [rtc-linux] [PATCH] RTC: Add driver for NXP PCF8523 RTC chip

From: Venu Byravarasu
Date: Wed Feb 01 2012 - 22:24:25 EST


> > +/*
> > + * 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;
> > +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/