[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-rtc
Subject: Re: [PATCH 2/2] rtc: add rtc-abx80x, a driver for the Abracon AB x80x i2c rtc
From: Philippe De Muyter <phdm () macqel ! be>
Date: 2015-03-15 15:10:17
Message-ID: 20150315151017.GA31712 () frolo ! macqel
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic