From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbaIJWIr (ORCPT ); Wed, 10 Sep 2014 18:08:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58467 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166AbaIJWIp (ORCPT ); Wed, 10 Sep 2014 18:08:45 -0400 Date: Wed, 10 Sep 2014 15:08:43 -0700 From: Andrew Morton To: Doug Anderson Cc: Chris Zhong , Heiko =?ISO-8859-1?Q?St=FCbner?= , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Samuel Ortiz , Lee Jones , Liam Girdwood , Alessandro Zummo , Mike Turquette , "broonie@kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , rtc-linux@googlegroups.com, Grant Likely , Lin Huang , Tao Huang , Eddie Cai , zhangqing , xxx , Olof Johansson , Sonny Rao , Dmitry Torokhov , Javier Martinez Canillas , Kever Yang Subject: Re: [PATCH v10 1/3] RTC: RK808: add RTC driver for RK808 Message-Id: <20140910150843.78d9416ae0dada8fccf8063a@linux-foundation.org> In-Reply-To: References: <1410311886-4579-1-git-send-email-zyw@rock-chips.com> <1410311886-4579-2-git-send-email-zyw@rock-chips.com> <20140910134411.8128acce79f2423d4448e8f4@linux-foundation.org> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 Sep 2014 14:37:13 -0700 Doug Anderson wrote: > Andrew, > > On Wed, Sep 10, 2014 at 1:44 PM, Andrew Morton > wrote: > > On Wed, 10 Sep 2014 09:18:04 +0800 Chris Zhong wrote: > > > >> Adding RTC driver for supporting RTC device present inside RK808 PMIC. > >> > >> ... > >> > >> + ret = rtc_valid_tm(&tm); > >> + if (ret) { > >> + dev_warn(&pdev->dev, "invalid date/time and init time\n"); > >> + rk808_rtc_set_time(&pdev->dev, &tm_def); > >> + } > > > > This is somewhat unusual. Most drivers will emit a warning and give up > > when they find the time is wrong. Why is this driver different and is > > this desirable behaviour? > > When you say "give up", what does that mean? I assume the driver > should keep initting, right? Then the user can go in and set a time > later... I think I was misreading current drivers a bit. rtc-cmos.c will go in and set a dummy time but regular low-level drivers don't sanity-check the time at all at setup time. > > I did test things with just removing this chunk of code. You get some > yells at bootup if you put a bogus time in there: > > [ 2.987590] rk808-rtc rk808-rtc: invalid date/time and init time > [ 3.013148] rk808-rtc rk808-rtc: rtc core: registered rk808-rtc as rtc0 > [ 4.586115] rk808-rtc rk808-rtc: hctosys: invalid date/time > > ...but if you later set a valid time then everything is fine. That > seems reasonable behavior to me, so I guess we could just remove this > whole chunk? It appears that after a normal bootup the date/time is > something valid. hm. Having an invalid time is perhaps better than having a valid but incorrect time. When one sees one driver doing something differently from the others one has to wonder "why" and "which one is better". If setting a dummy time is better then all drivers should do it, and I expect this could be done by rtc core at registration time.