From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752756AbbB1VXB (ORCPT ); Sat, 28 Feb 2015 16:23:01 -0500 Received: from smtprelay0163.hostedemail.com ([216.40.44.163]:50366 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751486AbbB1VW7 (ORCPT ); Sat, 28 Feb 2015 16:22:59 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3870:3871:3872:3873:3874:4321:5007:6119:6261:7903:7904:10004:10400:10848:11026:11232:11473:11658:11914:12050:12296:12517:12519:12663:12740:13069:13160:13229:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: jail85_5403e0cc5fb34 X-Filterd-Recvd-Size: 2706 Message-ID: <1425158574.31561.1.camel@perches.com> Subject: Re: [PATCH] rtc: add Abracon ABx80x driver From: Joe Perches To: Alexandre Belloni Cc: Alessandro Zummo , linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com Date: Sat, 28 Feb 2015 13:22:54 -0800 In-Reply-To: <20150228205243.GF4094@piout.net> References: <1425150876-8141-1-git-send-email-alexandre.belloni@free-electrons.com> <1425151935.25697.5.camel@perches.com> <20150228205243.GF4094@piout.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2015-02-28 at 21:52 +0100, Alexandre Belloni wrote: > > > diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c > > [] > > > +static int ab08xx_get_datetime(struct i2c_client *client, struct rtc_time *tm) [] > > > + tm->tm_sec = bcd2bin(date[AB08XX_REG_SC] & 0x7F); > > > + tm->tm_min = bcd2bin(date[AB08XX_REG_MN] & 0x7F); > > > + tm->tm_hour = bcd2bin(date[AB08XX_REG_HR] & 0x3F); > > > + tm->tm_wday = date[AB08XX_REG_WD] & 0x7; > > > + tm->tm_mday = bcd2bin(date[AB08XX_REG_DA] & 0x3F); > > > + tm->tm_mon = bcd2bin(date[AB08XX_REG_MO] & 0x1F) - 1; > > > + tm->tm_year = bcd2bin(date[AB08XX_REG_YR]); > > > + if (tm->tm_year < 70) > > > + tm->tm_year += 100; > > > + > > > + err = rtc_valid_tm(tm); > > > + if (err < 0) > > > + dev_err(&client->dev, "retrieved date/time is not valid.\n"); > > > > Is setting the date to a known bad value really the desired thing? > > I'm not sure what you mean here, isn't that what is done in almost all > the rtc drivers? Dunno. > A lot of those are simply using return > rtc_valid_tm(tm); My guess is that a userspace program must not try to > use tm when errno is not 0. My thought was that it might be better to use a local struct rtc_time r like r.tm_sec = bcd2bin(date[AB08XX_REG_SC] & 0x7F); r.tm_min = bcd2bin(date[AB08XX_REG_MN] & 0x7F); r.tm_hour = bcd2bin(date[AB08XX_REG_HR] & 0x3F); r.tm_wday = date[AB08XX_REG_WD] & 0x7; r.tm_mday = bcd2bin(date[AB08XX_REG_DA] & 0x3F); r.tm_mon = bcd2bin(date[AB08XX_REG_MO] & 0x1F) - 1; r.tm_year = bcd2bin(date[AB08XX_REG_YR]); if (r.tm_year < 70) r.tm_year += 100; err = rtc_valid_tm(&r); if (!err) *tm = r; else dev_err(&client->dev, "retrieved date/time is not valid\n"); return err;