From patchwork Sun Aug 26 02:19:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Fries X-Patchwork-Id: 180021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qc0-f184.google.com (mail-qc0-f184.google.com [209.85.216.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id CF5002C00EB for ; Sun, 26 Aug 2012 12:19:42 +1000 (EST) Received: by qcsv15 with SMTP id v15sf3055918qcs.11 for ; Sat, 25 Aug 2012 19:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:received-spf:date:from:to:cc:subject:message-id :mime-version:user-agent:x-greylist:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type:content-disposition :content-transfer-encoding; bh=AN4f3XMLEf3cjILjRLudfvrljS1eAViH7qYKDGXYfeo=; b=eSI51WxItwLFjhp/HgPSNBQrYeqLGD+mEfb8C56iP2WDEU0QpfdaYGrp/E4afvQ3QN xBxLU/jYsVxiNNqSTQNk1UTmIQ6y7W+B4eqDr5yMh72cFKAs98jkrpf/5/QdNm4ExAOn zS2im/ajUO2ex/7jz1pewTaWi1s+4VTTGc9bEJYI3sHmcVmOwwjSvfSf7DeYmo6JBgTO y9uhGW9CAlzmjfpE7oJKbz+I/N0mLUy/jVXDPsUH2I8lAPZaWH5QZT6fo0TP/fM3n8tI QandRImAiMAZaZOEbDzjTv9AKVCS+8Pb35Aiche7k7bZg6aopVOomAFeahqD3R1xhjQC MM6w== Received: by 10.50.13.230 with SMTP id k6mr1752156igc.0.1345947579056; Sat, 25 Aug 2012 19:19:39 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.231.3.207 with SMTP id 15ls4644750ibo.2.gmail; Sat, 25 Aug 2012 19:19:38 -0700 (PDT) Received: by 10.43.13.137 with SMTP id pm9mr4268167icb.0.1345947578500; Sat, 25 Aug 2012 19:19:38 -0700 (PDT) Received: by 10.43.13.137 with SMTP id pm9mr4268166icb.0.1345947578487; Sat, 25 Aug 2012 19:19:38 -0700 (PDT) Received: from SpacedOut.fries.net ([2001:470:ba1b:210::1]) by gmr-mx.google.com with ESMTPS id xd1si720969igb.1.2012.08.25.19.19.36 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 25 Aug 2012 19:19:37 -0700 (PDT) Received-SPF: pass (google.com: domain of david@fries.net designates 2001:470:ba1b:210::1 as permitted sender) client-ip=2001:470:ba1b:210::1; Received: from SpacedOut.fries.net (david@localhost [127.0.0.1]) by SpacedOut.fries.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q7Q2JYc4020788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 25 Aug 2012 21:19:34 -0500 Received: (from david@localhost) by SpacedOut.fries.net (8.14.3/8.14.3/Submit) id q7Q2JVSH020782; Sat, 25 Aug 2012 21:19:31 -0500 Date: Sat, 25 Aug 2012 21:19:31 -0500 From: David Fries To: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com Cc: Matthew Garrett , Alessandro Zummo , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Andrew Morton Subject: [rtc-linux] [PATCH] rtc_sysfs_show_hctosys 0 if resume failed Message-ID: <20120826021931.GA20620@spacedout.fries.net> MIME-Version: 1.0 User-Agent: Mutt/1.5.20 (2009-06-14) X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.3.7 (SpacedOut.fries.net [127.0.0.1]); Sat, 25 Aug 2012 21:19:34 -0500 (CDT) X-Original-Sender: david@fries.net X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of david@fries.net designates 2001:470:ba1b:210::1 as permitted sender) smtp.mail=david@fries.net Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Disposition: inline The original rtc_sysfs_show_hctosys returnd 1 if this device was the CONFIG_RTC_HCTOSYS_DEVICE device, a later patch checked rtc_hctosys_ret from boot, this verifies boot do_settimeofday succeeded, and sets rtc_hctosys_ret in resume to indicate when adjusting the clock from resume fails. This uses only CONFIG_RTC_HCTOSYS_DEVICE for conditional compilation instead of it and CONFIG_RTC_HCTOSYS. rtc_hctosys_ret was moved to class.c so rtc_hctosys can be removed with just a Kconfig change if boot time setting isn't desired. Signed-off-by: David Fries Cc: Matthew Garrett Cc: Alessandro Zummo Cc: Uwe Kleine-König Cc: Andrew Morton --- drivers/rtc/class.c | 5 ++++- drivers/rtc/hctosys.c | 4 +--- drivers/rtc/rtc-sysfs.c | 6 ++++++ include/linux/rtc.h | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index dc4c274..298f69a 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -39,7 +39,8 @@ static void rtc_device_release(struct device *dev) */ static struct timespec old_rtc, old_system, old_delta; - +/* Result of the last RTC to system clock attempt. */ +int rtc_hctosys_ret = -ENODEV; static int rtc_suspend(struct device *dev, pm_message_t mesg) { @@ -84,6 +85,7 @@ static int rtc_resume(struct device *dev) struct timespec new_system, new_rtc; struct timespec sleep_time; + rtc_hctosys_ret = -ENODEV; if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0) return 0; @@ -117,6 +119,7 @@ static int rtc_resume(struct device *dev) if (sleep_time.tv_sec >= 0) timekeeping_inject_sleeptime(&sleep_time); + rtc_hctosys_ret = 0; return 0; } diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index bc90b09..4aa60d7 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -22,8 +22,6 @@ * the best guess is to add 0.5s. */ -int rtc_hctosys_ret = -ENODEV; - static int __init rtc_hctosys(void) { int err = -ENODEV; @@ -56,7 +54,7 @@ static int __init rtc_hctosys(void) rtc_tm_to_time(&tm, &tv.tv_sec); - do_settimeofday(&tv); + err = do_settimeofday(&tv); dev_info(rtc->dev.parent, "setting system clock to " diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 380083c..b70e2bb 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -102,6 +102,12 @@ rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr, return n; } +/** + * rtc_sysfs_show_hctosys - indicate if the given RTC set the system time + * + * Returns 1 if the system clock was set by this RTC at the last + * boot or resume event. + */ static ssize_t rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index f071b39..20ec4d3 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -276,7 +276,7 @@ static inline bool is_leap_year(unsigned int year) return (!(year % 4) && (year % 100)) || !(year % 400); } -#ifdef CONFIG_RTC_HCTOSYS +#ifdef CONFIG_RTC_HCTOSYS_DEVICE extern int rtc_hctosys_ret; #else #define rtc_hctosys_ret -ENODEV