From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.free-electrons.com (down.free-electrons.com. [37.187.137.238]) by gmr-mx.google.com with ESMTP id y203si773725wmc.2.2015.12.01.13.04.18 for ; Tue, 01 Dec 2015 13:04:18 -0800 (PST) Date: Tue, 1 Dec 2015 22:04:17 +0100 From: Alexandre Belloni To: Joshua Clayton Cc: Alessandro Zummo , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] Re: [PATCH 6/9] rtc-pcf2123: avoid resetting the clock if possible Message-ID: <20151201210417.GA22136@piout.net> References: <20151124232512.GG3950@piout.net> <20151201122351.27e3f542@jclayton-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <20151201122351.27e3f542@jclayton-pc> Reply-To: rtc-linux@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , On 01/12/2015 at 12:23:51 -0800, Joshua Clayton wrote : > On Wed, 25 Nov 2015 00:25:12 +0100 > Alexandre Belloni wrote: > > > On 04/11/2015 at 07:36:37 -0800, Joshua Clayton wrote : > > > + ret = pcf2123_rtc_read_time(dev, &tm); > > > + if (ret < 0) > > > + return false; > > > + > > > + if (rtc_valid_tm(&tm) < 0) { > > > + dev_err(dev, "retrieved date/time is not > > > valid.\n"); > > > + return false; > > > + } > > > + > > > > I would remove that test as basically, the date/time will only be > > valid when OSC_HAS_STOPPED is not set. > > > OSC_HAS_STOPPED really only protects us in case everything else > looks good, but we've lost power. > There are other reasons to check for a valid time. > Specifically, if there is no communication with the device, the spi > operation will succeed and return all zeros or all ones. > Since either of these results in an invalid time, it is a nice way > to probe whether we really have a pcf2123 compatible device. > > I don't think I should remove this test, but I can add a comment OK but then pcf2123_rtc_read_time actually returns rtc_valid_tm(tm) ;) The proper course of action is probably to do the OSC_HAS_STOPPED check in pcf2123_rtc_read_time then you don't even need pcf2123_time_valid(). -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756858AbbLAVEZ (ORCPT ); Tue, 1 Dec 2015 16:04:25 -0500 Received: from down.free-electrons.com ([37.187.137.238]:47652 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756437AbbLAVET (ORCPT ); Tue, 1 Dec 2015 16:04:19 -0500 Date: Tue, 1 Dec 2015 22:04:17 +0100 From: Alexandre Belloni To: Joshua Clayton Cc: Alessandro Zummo , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/9] rtc-pcf2123: avoid resetting the clock if possible Message-ID: <20151201210417.GA22136@piout.net> References: <20151124232512.GG3950@piout.net> <20151201122351.27e3f542@jclayton-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151201122351.27e3f542@jclayton-pc> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/12/2015 at 12:23:51 -0800, Joshua Clayton wrote : > On Wed, 25 Nov 2015 00:25:12 +0100 > Alexandre Belloni wrote: > > > On 04/11/2015 at 07:36:37 -0800, Joshua Clayton wrote : > > > + ret = pcf2123_rtc_read_time(dev, &tm); > > > + if (ret < 0) > > > + return false; > > > + > > > + if (rtc_valid_tm(&tm) < 0) { > > > + dev_err(dev, "retrieved date/time is not > > > valid.\n"); > > > + return false; > > > + } > > > + > > > > I would remove that test as basically, the date/time will only be > > valid when OSC_HAS_STOPPED is not set. > > > OSC_HAS_STOPPED really only protects us in case everything else > looks good, but we've lost power. > There are other reasons to check for a valid time. > Specifically, if there is no communication with the device, the spi > operation will succeed and return all zeros or all ones. > Since either of these results in an invalid time, it is a nice way > to probe whether we really have a pcf2123 compatible device. > > I don't think I should remove this test, but I can add a comment OK but then pcf2123_rtc_read_time actually returns rtc_valid_tm(tm) ;) The proper course of action is probably to do the OSC_HAS_STOPPED check in pcf2123_rtc_read_time then you don't even need pcf2123_time_valid(). -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com