LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com> To: Philippe De Muyter <phdm@macqel.be> Cc: Andrew Morton <akpm@linux-foundation.org>, Alessandro Zummo <a.zummo@towertech.it>, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de> Subject: Re: [PATCH 2/2] rtc: add rtc-abx80x, a driver for the Abracon AB x80x i2c rtc Date: Sat, 14 Mar 2015 19:09:11 +0100 [thread overview] Message-ID: <20150314180911.GC4560@piout.net> (raw) In-Reply-To: <20150314124441.GA11905@frolo.macqel> 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. > > +static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm) > > +{ > > + struct i2c_client *client = to_i2c_client(dev); > > + int data, err; > > + unsigned char buf[8]; > > The link is not clear between 8 above, the symbolic constants below, and 7 > in the call to i2c_smbus_write_i2c_block_data. > It is because I didn't bother writing the hundreth of seconds, I'll change that and the other issues you pointed. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
next prev parent reply other threads:[~2015-03-14 18:09 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-14 10:05 [PATCH 0/2] rtc: add Abracon ABx80x Alexandre Belloni 2015-03-14 10:05 ` [PATCH 1/2] Documentation: bindings: add abracon,abx80x Alexandre Belloni 2015-03-14 10:05 ` [PATCH 2/2] rtc: add rtc-abx80x, a driver for the Abracon AB x80x i2c rtc Alexandre Belloni 2015-03-14 12:44 ` Philippe De Muyter 2015-03-14 18:09 ` Alexandre Belloni [this message] 2015-03-15 15:10 ` Philippe De Muyter 2015-03-16 10:16 ` Paul Bolle
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20150314180911.GC4560@piout.net \ --to=alexandre.belloni@free-electrons.com \ --cc=a.zummo@towertech.it \ --cc=akpm@linux-foundation.org \ --cc=arnd@arndb.de \ --cc=linux-kernel@vger.kernel.org \ --cc=phdm@macqel.be \ --cc=rtc-linux@googlegroups.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).