From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FCD0C3A59D for ; Thu, 22 Aug 2019 09:02:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FA33214DA for ; Thu, 22 Aug 2019 09:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730648AbfHVJCR (ORCPT ); Thu, 22 Aug 2019 05:02:17 -0400 Received: from mga09.intel.com ([134.134.136.24]:18156 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729272AbfHVJCQ (ORCPT ); Thu, 22 Aug 2019 05:02:16 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 02:02:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,416,1559545200"; d="scan'208";a="208072412" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.145]) by fmsmga002.fm.intel.com with ESMTP; 22 Aug 2019 02:02:11 -0700 Received: from andy by smile with local (Exim 4.92.1) (envelope-from ) id 1i0iyu-0006TO-GR; Thu, 22 Aug 2019 12:02:08 +0300 Date: Thu, 22 Aug 2019 12:02:08 +0300 From: Andy Shevchenko To: Rahul Tanwar Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, tony.luck@intel.com, x86@kernel.org, a.zummo@towertech.it, alexandre.belloni@bootlin.com, robh+dt@kernel.org, mark.rutland@arm.com, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, alan@linux.intel.com, linux-kernel@vger.kernel.org, qi-ming.wu@intel.com, cheol.yong.kim@intel.com, rahul.tanwar@intel.com Subject: Re: [PATCH v1 1/2] x86/rtc: Add option to skip using RTC Message-ID: <20190822090208.GJ30120@smile.fi.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org On Thu, Aug 22, 2019 at 03:44:03PM +0800, Rahul Tanwar wrote: > Use a newly introduced optional "status" property of "motorola,mc146818" > compatible DT node to determine if RTC is supported. Skip read/write from > RTC device only when this node is present and status is "disabled". In all > other cases, proceed as before. Can't we rather update ->get_wallclock() and ->set_wallclock() based on this? > Suggested-by: Alan Cox > Signed-off-by: Rahul Tanwar > --- > arch/x86/kernel/rtc.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c > index 586f718b8e95..f9f760a8e76a 100644 > --- a/arch/x86/kernel/rtc.c > +++ b/arch/x86/kernel/rtc.c > @@ -32,6 +32,11 @@ EXPORT_SYMBOL(cmos_lock); > DEFINE_SPINLOCK(rtc_lock); > EXPORT_SYMBOL(rtc_lock); > > +static const struct of_device_id of_cmos_match[] = { > + { .compatible = "motorola,mc146818" }, > + {} > +}; > + > /* > * In order to set the CMOS clock precisely, set_rtc_mmss has to be > * called 500 ms after the second nowtime has started, because when > @@ -42,9 +47,14 @@ EXPORT_SYMBOL(rtc_lock); > int mach_set_rtc_mmss(const struct timespec64 *now) > { > unsigned long long nowtime = now->tv_sec; > + struct device_node *node; > struct rtc_time tm; > int retval = 0; > > + node = of_find_matching_node(NULL, of_cmos_match); > + if (node && !of_device_is_available(node)) > + return -EINVAL; > + > rtc_time64_to_tm(nowtime, &tm); > if (!rtc_valid_tm(&tm)) { > retval = mc146818_set_time(&tm); > @@ -63,8 +73,15 @@ int mach_set_rtc_mmss(const struct timespec64 *now) > void mach_get_cmos_time(struct timespec64 *now) > { > unsigned int status, year, mon, day, hour, min, sec, century = 0; > + struct device_node *node; > unsigned long flags; > > + node = of_find_matching_node(NULL, of_cmos_match); > + if (node && !of_device_is_available(node)) { > + now->tv_sec = now->tv_nsec = 0; > + return; > + } > + > /* > * If pm_trace abused the RTC as storage, set the timespec to 0, > * which tells the caller that this RTC value is unusable. > -- > 2.11.0 > -- With Best Regards, Andy Shevchenko