On Sat, Mar 14, 2015 at 07:09:11PM +0100, Alexandre Belloni wrote: > On 14/03/2015 at 13:44:41 +0100, Philippe De Muyter wrote : > > > + tm->tm_sec = bcd2bin(date[ABX8XX_REG_SC] & 0x7F); > > > + tm->tm_min = bcd2bin(date[ABX8XX_REG_MN] & 0x7F); > > > + tm->tm_hour = bcd2bin(date[ABX8XX_REG_HR] & 0x3F); > > > + tm->tm_wday = date[ABX8XX_REG_WD] & 0x7; > > > + tm->tm_mday = bcd2bin(date[ABX8XX_REG_DA] & 0x3F); > > > + tm->tm_mon = bcd2bin(date[ABX8XX_REG_MO] & 0x1F) - 1; > > > + tm->tm_year = bcd2bin(date[ABX8XX_REG_YR]); > > > + if (tm->tm_year < 70) > > > > Is that still useful for a driver written in 2015 ? > > > > I'd say that this is actually the only correct way to do it. Only dates > before 01/01/1970 00:00 are considered invalid. So, unless adding a > check like: > > if (tm->tm_year < 100) > return -EINVAL; > > in abx80x_rtc_set_time, setting and then reading a date before 2000 will > fail silently. I'm open to add that check.
You are right. It is actually more a consistency problem between rtc drivers and thus a question for the rtc-subsytem maintainer. Philippe -- Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/