From patchwork Fri Dec 7 13:48:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153153 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521574ljp; Fri, 7 Dec 2018 05:49:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXbpbBAQ2eUNB7vdpt6IdmTn8i6CIm0iDivv4qqXpJ3EGnn6DSTJmN7omUDQNBTKNPOTla X-Received: by 2002:a17:902:42e4:: with SMTP id h91mr2271992pld.18.1544190574237; Fri, 07 Dec 2018 05:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190574; cv=none; d=google.com; s=arc-20160816; b=qN8vO5YIzBqbXyCE3jihHQTSFYeMwk+zicSeuYdJ3i61gek+aAdjAiKuUAhkk0VDlm 9Wl6MXei4hctCieyOcNDEF1RQE6UGQeVsAOuo66N9DJojg9vGndYbEg13fK/TsZ6kpsU M8eoWnDkRmy1VayVAn6XaE1GGu4lg7Ic5OvMWGJJdjQIdDChgde7GG/3Vn6yTOuKa35F wfvZuVGtw0+ZQE2k4O2CsOnnZudXFGeo210bRbGVNVJnaNXPzEabGYIX45vLINeXurtB JN26qPkEU8B50ShiZ2tZAzcZFCsNdqWspSe9/2JriUZ25ye7V+M3CaSwzEfeGRzpAMoS fI4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nXGhvgbtM2MVYnmUcBhRNm1HWv2dEUpncTRfWaB6YNs=; b=kjxKlt/k1sG4Erz+0IhE/KMKnMkxp8DjAeM9B/MGZU4Q3z62tibaBBt9W781s1ulWe O9GvLA/wQm7jxu2E/9LjclY5HxmDWSsoDCqHCETmpSe4nOAiUyZLsZ5zjCgO3qIxvbBU Ezu3SA6cmSJHnSUFHAXo+zqbOGixLyEo1pGOsvMD5tvXPueSWxKCcBhP7wpvIkJK/cjL 7l0zRdLGb+B8O6fB7ZWbvVPyEYY8CDcBSBPLCiZMXZ9+OXKL1uc/9CKEM24fisISgFwf E9cLjWpq62pWKYmaTwRAtgstC6RcgjbUX+HdXQxIina6Tf1e+7KbaQppaJbsbFZrSF9o ZB1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si2980983pla.335.2018.12.07.05.49.33; Fri, 07 Dec 2018 05:49:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726161AbeLGNtc (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:32 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:49273 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbeLGNt2 (ORCPT ); Fri, 7 Dec 2018 08:49:28 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MTRAS-1guSKU31dE-00TkSU; Fri, 07 Dec 2018 14:48:58 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 1/8] sh: dreamcast: rtc: push down rtc class ops into driver Date: Fri, 7 Dec 2018 14:48:17 +0100 Message-Id: <20181207134824.300024-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:iMOMQODGfxdkXkIiy3bpmWxGlvGkMgbchhdvPBw5kYhBgtYI+N1 esf5jxvn10dz8Z/kV6SkBDIvX+rhSPTO9pyF50LC9P6cVdhs8+DZSKMAmhzWMzbRm30dmn2 bWWWmOyFM+pZ8BNnQJvXLHANHYyyypsgvJY2sj1bfE8xx5YQPjcGbbCNLUjJwSTb2Kl1EGP gJ36oGH/SPVze5pFK8ThQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:H5CSwJcgbyU=:/Vk3o9HFH7jmv1Sz9gsGN7 /ekn6jJO7Xc+/R5e/ws3mQJQZw8dnUurIbuMruCvyAuofagfgSPYIg69v1ljQQKHMDswPmklD fqVx4gVQXZIum6ESZC5YY95Xs/ZLoz3GsBGsFc/Fbu8tyKNBfLfclYVj+C1jzu0Vozpid5pTh TKXPZ//TG7BggB4VQs+A7kUrs6G2xgPSXFI50snDkfSXF4z06GiL9oZp3eFZjeKfm/ejvKuZM BNFq5GICebEP+QtcCDYnpMM9m4fpOGKtzswOPWWcb3ncYh1Lwp/qaT/HCwO31rdDE+gItlTWJ +YFyfRgk1h6SauZBH8s4IAdknErOnxoN6MVVbU1cbCEuDzYDlJLmTL7/ufS1xPdJz0IuRmhV4 5VWUUncWpeS5lZYsJDZAzrr2tkWOd8efwgnevT4XrMX42zRyUqrNWdwQtndiCPvy6UkB21aPN 3Y/Cpp0p5x8y+UIlZkRqf8p2vIM+LhN3yg/3NXrkct+l0/YCTe2yT7xLqfrUBX12b0agKkkD1 Q6QQL8/yMb29Ocll7D7fNwr3hL/n0Ak5kU//GNQGC9On3XwDZwq5SeXWJFLUyP51rxjvhyF/Q NV5n0fR5RJuUz5gmJ/FkphoxIGNGLnxGwBIl+pwg4/hxgy14LtF6ohhDmTJGL0ztkaDFmCOSG MI5n27zUCx8eWhh0D9pYGsosHnnItHHq61fgWPk8SezQ0eBOASxUiA5BWe2cb14cNTclxMmBu auiPX+YKGwXry9zXi32DVC2Fz6pxFHzhXSsM6w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dreamcast RTC support has an extra level of indirection to provide either the old read_persistent_clock/update_persistent_clock interface or the rtc-generic device for hctosys/systohc. Both do the same thing here, so we can do away with the abstraction and simply enable the RTC core code to take care of it. Signed-off-by: Arnd Bergmann --- arch/sh/boards/mach-dreamcast/Makefile | 4 +- arch/sh/boards/mach-dreamcast/rtc.c | 39 +++++++++++++------ arch/sh/boards/mach-dreamcast/setup.c | 1 - arch/sh/configs/dreamcast_defconfig | 2 + arch/sh/include/mach-dreamcast/mach/sysasic.h | 1 - 5 files changed, 31 insertions(+), 16 deletions(-) -- 2.18.0 diff --git a/arch/sh/boards/mach-dreamcast/Makefile b/arch/sh/boards/mach-dreamcast/Makefile index 7b97546c7e5f..62b024bc2a3e 100644 --- a/arch/sh/boards/mach-dreamcast/Makefile +++ b/arch/sh/boards/mach-dreamcast/Makefile @@ -2,5 +2,5 @@ # Makefile for the Sega Dreamcast specific parts of the kernel # -obj-y := setup.o irq.o rtc.o - +obj-y := setup.o irq.o +obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o diff --git a/arch/sh/boards/mach-dreamcast/rtc.c b/arch/sh/boards/mach-dreamcast/rtc.c index 061d65714fcc..4f168d8d2951 100644 --- a/arch/sh/boards/mach-dreamcast/rtc.c +++ b/arch/sh/boards/mach-dreamcast/rtc.c @@ -11,8 +11,9 @@ */ #include -#include -#include +#include +#include +#include /* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in seconds) to get the standard Unix Epoch when getting the time, and add @@ -30,9 +31,10 @@ * * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch. */ -static void aica_rtc_gettimeofday(struct timespec *ts) +static int aica_rtc_gettimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; + time64_t t; do { val1 = ((__raw_readl(AICA_RTC_SECS_H) & 0xffff) << 16) | @@ -42,10 +44,12 @@ static void aica_rtc_gettimeofday(struct timespec *ts) (__raw_readl(AICA_RTC_SECS_L) & 0xffff); } while (val1 != val2); - ts->tv_sec = val1 - TWENTY_YEARS; + /* normalize to 1970..2106 time range */ + t = (u32)(val1 - TWENTY_YEARS); - /* Can't get nanoseconds with just a seconds counter. */ - ts->tv_nsec = 0; + rtc_time64_to_tm(t, tm); + + return 0; } /** @@ -54,10 +58,11 @@ static void aica_rtc_gettimeofday(struct timespec *ts) * * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. */ -static int aica_rtc_settimeofday(const time_t secs) +static int aica_rtc_settimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; - unsigned long adj = secs + TWENTY_YEARS; + time64_t secs = rtc_tm_to_time64(tm); + u32 adj = secs + TWENTY_YEARS; do { __raw_writel((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H); @@ -73,9 +78,19 @@ static int aica_rtc_settimeofday(const time_t secs) return 0; } -void aica_time_init(void) +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = aica_rtc_gettimeofday, + .set_time = aica_rtc_settimeofday, +}; + +static int __init aica_time_init(void) { - rtc_sh_get_time = aica_rtc_gettimeofday; - rtc_sh_set_time = aica_rtc_settimeofday; -} + struct platform_device *pdev; + + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + return PTR_ERR_OR_ZERO(pdev); +} +arch_initcall(aica_time_init); diff --git a/arch/sh/boards/mach-dreamcast/setup.c b/arch/sh/boards/mach-dreamcast/setup.c index ad1a4db72e04..672c2ad8f8d5 100644 --- a/arch/sh/boards/mach-dreamcast/setup.c +++ b/arch/sh/boards/mach-dreamcast/setup.c @@ -30,7 +30,6 @@ static void __init dreamcast_setup(char **cmdline_p) { - board_time_init = aica_time_init; } static struct sh_machine_vector mv_dreamcast __initmv = { diff --git a/arch/sh/configs/dreamcast_defconfig b/arch/sh/configs/dreamcast_defconfig index 3f08dc54480b..1d27666c029f 100644 --- a/arch/sh/configs/dreamcast_defconfig +++ b/arch/sh/configs/dreamcast_defconfig @@ -70,3 +70,5 @@ CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_HUGETLBFS=y # CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y diff --git a/arch/sh/include/mach-dreamcast/mach/sysasic.h b/arch/sh/include/mach-dreamcast/mach/sysasic.h index 58f710e1ebc2..59effd1ed3e1 100644 --- a/arch/sh/include/mach-dreamcast/mach/sysasic.h +++ b/arch/sh/include/mach-dreamcast/mach/sysasic.h @@ -42,7 +42,6 @@ /* arch/sh/boards/mach-dreamcast/irq.c */ extern int systemasic_irq_demux(int); extern void systemasic_irq_init(void); -extern void aica_time_init(void); #endif /* __ASM_SH_DREAMCAST_SYSASIC_H */ From patchwork Fri Dec 7 13:48:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153159 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp522131ljp; Fri, 7 Dec 2018 05:50:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/VghQcbzUvkVEeK2qD/0xrvD5TiE/07TJ1TCSv7mt1+3lvGZ8hiCk6MniggPlEoVmcMr5b8 X-Received: by 2002:a17:902:bd46:: with SMTP id b6mr2177137plx.231.1544190610005; Fri, 07 Dec 2018 05:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190609; cv=none; d=google.com; s=arc-20160816; b=joXmvHHkHtkGMMkr1LEdB8+kVQBUivhqZdVMd4jCZ1F9YiRYv9Re0N1LJZRX67hIpL oWpuRB7P2mrl5A2DP+1+dvuWJWbitqkA/7vRBtFncqSUX7SyHs7EyMebXBcrhfOgq4o3 WnYQpnXELnKAzwsM8pUHJNVU6Rg+FwWiju44cbG1tbW2mrJ/Wb5pKsLufzWAMBNXHbS3 E66JMwDrTNJPEypwU5gQ//wf+l/KDUbC8ReJgA2S1W+WVcYTGKlKEeaANgK2nTidhi1T JClYn9nlltdnnOpJBGLhu2eWajrwzlVVhFPEJTH8zZX64tjJW8u2djgwuMbhtqwADAby HCKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=QFtiX/dPbNH5sJ8noK8cQLqDO4F+yvANdQqWBdQZ2sU=; b=FPUQxc6tZk3M6DzhnoOHk1LfEiRbjHnQIinNJryFpfGaNvhfmMdBFTtVjKFqnAJs1K Q8wINfKYHVtvP9cain4OuhSSCfrxNLswLrrxlx2kqHfk3XM4VIvZrlJ/Nx1CQ7pjamHb XKRdTOPsUtgHUAPHWbZw4uULsDAI0POMH9wLQlEINcSkOOjSDCHge4mFrVl1RKqVABgs div2kjIT7M7PTvSJF6XuymEuRWCONwWn3MlEE5ETIRhy1Wl+OBVaGsuXyggHl79cgTgi mdgzgL6N3c2Tdcgf+GYiLhNkufuFyn10b2YxLuScNs5lUAl1Yv5b5txDJgzQ/tTfQ7r1 nGuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si3309264pfw.66.2018.12.07.05.50.09; Fri, 07 Dec 2018 05:50:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726227AbeLGNuH (ORCPT + 31 others); Fri, 7 Dec 2018 08:50:07 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:54789 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MjjOl-1hAsiW0a0R-00lGqH; Fri, 07 Dec 2018 14:48:59 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 2/8] sh: sh03: rtc: push down rtc class ops into driver Date: Fri, 7 Dec 2018 14:48:18 +0100 Message-Id: <20181207134824.300024-3-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:tJmSj16kgzkEh+PiEE6u2e5OJ6CVxUnOP9y0L0ftlO7hoGjRl5J lf/sG53Ec1SwTov/pEjsL3u6qgtvkD1SFhPo6ri7XKDMsj06AsZiJ6YMGrjKwGjNY6OAkJu PxCT6gxO16XV57bdcY3hquOkAr3Noc+zqviCKZ3eU1x1y51X5ZbGMsuYjmsKJeqRj8gt/tR 4YuQQwatbWiqUQGVZQGUA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:WhaprctODx8=:U06puf8uqc/q8hnSWJZQYt ksDyox36bYVHeRLWq3hfejrWhAsKsqFn83jZvOOoK0UYDdvegewkBtRiw8yZOBVrlXV1NPsvO nPrMlTRcoMQjPbXJ1dQtXLdos+t7vj7FhcJl9EpFiHA/eigLqyjBInO1dV8MUqZZKaXLmFrbw nOTWKj/ZMAdoPd4cdRE+7+5cUelk1MqpAnu/pk+QxSgOJITh1Zmt4dkLE0+kAKSn5pj1XGQBI cO9VHYdBKuvkeznpfnVAOrr288FwiMoQPImHO2vW6FcTNpp9Aw372/Kiyndu/tMcNbfySKGep /2v2UPSZc/ESCvgt4csy5m5wJs4vNPLcPaEFuIJIIDiAs+dnvuP/BGrZMwui5md9EIttQkPV/ kjUXPN+25YVmen7ssDz0Q0VVN6xs7kjyu/y0vFqgXnoTVG63yuk0PrGiQpyMbazUEan6AflEM rBOzBH5J3wdaDsVSafBnvWTb1yHY29fGowP0r+2HblwfPTCoOG2h1jpTPOy12ZeHNju8gJhN4 tcdpeHLvJy0uxazyQCd2XzgHTXgWC3NAuLznr/lM5MyAORjOJxhdtQa20gVGQcHzCXTJ8W4Av N5LwEi1PfzdAbDfLeK6/1bbutdOw0N+TWCxBmnK/VAYXSQXkRa+YqcykbUZ/KiscYF+ZNjoRo ycMLhOCAfXv+AFnwmpKoesZZLnM7m4YVgbsWh0U3x1tMwc65Iz+WowYGePr53OBkP3BnC5su7 BH54wpCGHUbbSP0mbHHkUHYlURkud9SgOnM0pA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dreamcast RTC support has an extra level of indirection to provide either the old read_persistent_clock/update_persistent_clock interface or the rtc-generic device for hctosys/systohc. By removing the indirection and always using the RTC_CLASS interface, we can avoid the lossy double conversion between rtc_time and timespec, so we end up supporting the entire range of 'year' values, and clarifying the rtc_set_time callback. I did not change the behavior of sh03_rtc_settimeofday(), which keeps just updating the seconds/minutes by calling set_rtc_mmss(), this could be improved if anyone cares. Also, the file should ideally be moved into drivers/rtc and not use rtc-generic. Signed-off-by: Arnd Bergmann --- arch/sh/boards/mach-sh03/Makefile | 3 +- arch/sh/boards/mach-sh03/rtc.c | 51 +++++++++++++++++++------------ arch/sh/boards/mach-sh03/setup.c | 9 ------ arch/sh/configs/sh03_defconfig | 2 ++ 4 files changed, 35 insertions(+), 30 deletions(-) -- 2.18.0 diff --git a/arch/sh/boards/mach-sh03/Makefile b/arch/sh/boards/mach-sh03/Makefile index 400306a796ec..47007a3a2fc8 100644 --- a/arch/sh/boards/mach-sh03/Makefile +++ b/arch/sh/boards/mach-sh03/Makefile @@ -2,4 +2,5 @@ # Makefile for the Interface (CTP/PCI-SH03) specific parts of the kernel # -obj-y := setup.o rtc.o +obj-y := setup.o +obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o diff --git a/arch/sh/boards/mach-sh03/rtc.c b/arch/sh/boards/mach-sh03/rtc.c index dc3d50e3b7a2..8b23ed7c201c 100644 --- a/arch/sh/boards/mach-sh03/rtc.c +++ b/arch/sh/boards/mach-sh03/rtc.c @@ -13,8 +13,9 @@ #include #include #include -#include -#include +#include +#include +#include #define RTC_BASE 0xb0000000 #define RTC_SEC1 (RTC_BASE + 0) @@ -38,7 +39,7 @@ static DEFINE_SPINLOCK(sh03_rtc_lock); -unsigned long get_cmos_time(void) +static int sh03_rtc_gettimeofday(struct device *dev, struct rtc_time *tm) { unsigned int year, mon, day, hour, min, sec; @@ -75,17 +76,18 @@ unsigned long get_cmos_time(void) } spin_unlock(&sh03_rtc_lock); - return mktime(year, mon, day, hour, min, sec); -} -void sh03_rtc_gettimeofday(struct timespec *tv) -{ + tm->tm_sec = sec; + tm->tm_min = min; + tm->tm_hour = hour; + tm->tm_mday = day; + tm->tm_mon = mon; + tm->tm_year = year - 1900; - tv->tv_sec = get_cmos_time(); - tv->tv_nsec = 0; + return 0; } -static int set_rtc_mmss(unsigned long nowtime) +static int set_rtc_mmss(struct rtc_time *tm) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; @@ -97,8 +99,8 @@ static int set_rtc_mmss(unsigned long nowtime) if (!(__raw_readb(RTC_CTL) & RTC_BUSY)) break; cmos_minutes = (__raw_readb(RTC_MIN1) & 0xf) + (__raw_readb(RTC_MIN10) & 0xf) * 10; - real_seconds = nowtime % 60; - real_minutes = nowtime / 60; + real_seconds = tm->tm_sec; + real_minutes = tm->tm_min; if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) real_minutes += 30; /* correct for half hour time zone */ real_minutes %= 60; @@ -112,22 +114,31 @@ static int set_rtc_mmss(unsigned long nowtime) printk_once(KERN_NOTICE "set_rtc_mmss: can't update from %d to %d\n", cmos_minutes, real_minutes); - retval = -1; + retval = -EINVAL; } spin_unlock(&sh03_rtc_lock); return retval; } -int sh03_rtc_settimeofday(const time_t secs) +int sh03_rtc_settimeofday(struct device *dev, struct rtc_time *tm) { - unsigned long nowtime = secs; - - return set_rtc_mmss(nowtime); + return set_rtc_mmss(tm); } -void sh03_time_init(void) +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = sh03_rtc_gettimeofday, + .set_time = sh03_rtc_settimeofday, +}; + +static int __init sh03_time_init(void) { - rtc_sh_get_time = sh03_rtc_gettimeofday; - rtc_sh_set_time = sh03_rtc_settimeofday; + struct platform_device *pdev; + + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + + return PTR_ERR_OR_ZERO(pdev); } +arch_initcall(sh03_time_init); diff --git a/arch/sh/boards/mach-sh03/setup.c b/arch/sh/boards/mach-sh03/setup.c index 85e7059a77e9..3901b6031ad5 100644 --- a/arch/sh/boards/mach-sh03/setup.c +++ b/arch/sh/boards/mach-sh03/setup.c @@ -22,14 +22,6 @@ static void __init init_sh03_IRQ(void) plat_irq_setup_pins(IRQ_MODE_IRQ); } -/* arch/sh/boards/sh03/rtc.c */ -void sh03_time_init(void); - -static void __init sh03_setup(char **cmdline_p) -{ - board_time_init = sh03_time_init; -} - static struct resource cf_ide_resources[] = { [0] = { .start = 0x1f0, @@ -101,6 +93,5 @@ device_initcall(sh03_devices_setup); static struct sh_machine_vector mv_sh03 __initmv = { .mv_name = "Interface (CTP/PCI-SH03)", - .mv_setup = sh03_setup, .mv_init_irq = init_sh03_IRQ, }; diff --git a/arch/sh/configs/sh03_defconfig b/arch/sh/configs/sh03_defconfig index 2156223405a1..489ffdfb1517 100644 --- a/arch/sh/configs/sh03_defconfig +++ b/arch/sh/configs/sh03_defconfig @@ -130,3 +130,5 @@ CONFIG_CRYPTO_SHA1=y CONFIG_CRYPTO_DEFLATE=y # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_CRC_CCITT=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y From patchwork Fri Dec 7 13:48:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153152 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521530ljp; Fri, 7 Dec 2018 05:49:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/XuEKvThk2zmRRRJE0IoF/aVuyska8HJVye3mVpGGoEIkcEW3Ae3ypHbQUxospW1Yy/4Y9u X-Received: by 2002:a17:902:2e01:: with SMTP id q1mr2141505plb.97.1544190571348; Fri, 07 Dec 2018 05:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190571; cv=none; d=google.com; s=arc-20160816; b=x9TIrQ19/0q/WM6cDCxrUYLVTeETQIAYkFaOTdoKtQu5+ZQrX54LlSeUE0AQh1Z6uL YsOjWBDJk3ViltVzenx/lOT9I8nt4DEA1CK06YDLdwRZICmRQsUQ3j9K8Ug8cX/hR3eL gAlyokQq0WJ3deP+EHWLRHmFymPPo0KM737KXUXVl9m/TUQ0Dr3Rd2w2yNdpjNmdOLzy S/4swBqlAviTCabK5nDTIpVXBk+xJRq0at3zOA9bEXbrbQJzpTNWoKGjPQWNJaf+0ssa idZ97pw92jpUpVHRZEUyAJcDbD1eWYtOWeeEma2Get8GzL4G/BSS/EHmKThYObWS8qrJ MXkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zqvHEMytYhUEIaB0p8C+ZVDsQEV8RXY9eqvEpnkC3bE=; b=UeDZbO8ZNcOlk3agPi8Na16DimS9z0HHEPivLHCNl5GR00v/GP3WHUgiqXAsQ8Rkts Aos1jE2odJtnLGmdOsL3UV237DXv9TM84U1JPXRUqsa7XFHh+0HfdwzaP31ZDZAdOvrb vgAuOZKpiyftT1WQgjNoBxS/dEJuMLujisx6J/gqTiUz37/12f+scXhbeysbVXBYNjnB hluIU+Cqj7FdlcDZMb0IkaqfpLnOuNKFgAF+tHMYgd8p2R9RnFkz7P9LJZWV5+Mmy4b5 PLmz+VHdL++EdU96Sgd3phNcH1vYr+gMZm6EezPPlOM67SlcglBO9Wia7ssBYa6VoeuI AEcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si3170109pfi.228.2018.12.07.05.49.31; Fri, 07 Dec 2018 05:49:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726142AbeLGNt1 (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:27 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:58407 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mv3I0-1hM8AV2JMm-00qw7W; Fri, 07 Dec 2018 14:48:59 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 3/8] sh: remove unused rtc_sh_get/set_time infrastructure Date: Fri, 7 Dec 2018 14:48:19 +0100 Message-Id: <20181207134824.300024-4-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:ptjeVIj9pJisn+HaW1swv5AKqW7dc3s5a8wTDbLUJiUakNelqRd ke1RgFvGLb0EiX1wkfOnuCgToqapBlSI88L8VdFZ+FxT8KcharP3dOVcc02tAegIpebPed5 0IBjHTW6ddjW4q0pixDVb+mWTOd9ae5RXfRJrESAYN0nbaOrdjnLVs4smk/2n8SGHGwK7Cs 4bWAPjvAeXJyC4zHHNk+Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:GFdkd1pRCsM=:LEEf2ULtxxEAm0xDqCjU/n DGGXXO34JScu2d+ApJqTsz715016BvTEdJD7bRsnvZ8oxQnQfJkbmZBpHJXYcj2fnd8pcOpGH /wJ2vK4zya4DaExuK3nnNsz5+Berf5QQ02euOuYXWovFx+1ADg2G2T38e2bxHBovorlT9YDvu lWudnmcmCzKfBeb1w/PjFaRT8Pn47yFSJ8obIH2gQ2hQTwVLMi/A95qrUUl3AMl274sKb6HdF T/hwvWcxVRJiRf1j6+E5Y8mlZIOVSjH9q2Et8K6TymbA6+Z7Uv4SL3fbbc1u6X9jewAQa7yVb mQw3MH0+mlllXqbJ0vcPOQiH1Pnpg0p5BaK/B6owlYxT9bxyJBZ6QRYvUyoYqCw9bfhsU/SOZ swBNae1BDiRzYhlbgR1ty4th5+4AM7GGB8IMnaIE/9J9tKa/xk8uLNgxMk1D6yq/I2GwQkqqr c28swUoLffuRieAly6gksrRrhBuJr8sEpRKwpaDD4UTAPJaU/3DXZERWssn6MwLq4KnKfLud9 LITXUD6m7gbzakwYxWQR8OCiTiyyBrG9ePBpBChl2maKjugdq0TY5D8a7SrTkw2rvPxsUZLmk 2adHkLdjbqKxPvLEt7Xulrh7GJvXf3hXBCEZwDKSmFi/jVnOFNUze9VwV1FtHs0xhTvMcC6+r +UPTBIY/BeMl5jLKCygp5NSNpCsHEJ290h5edYVy3EKVQmdB0G2wz3rf0M1jNQtUBv+jtwx6e f27WiTIRZFJZGmCfApqe5mf+btJsLi18RUV9XA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All platforms are now converted to RTC drivers, so this has become obsolete. The board_time_init() callback still has one caller, but could otherwise also get killed. This removes one more usage of the deprecated timespec structure, which overflows in y2038. Signed-off-by: Arnd Bergmann --- arch/sh/include/asm/rtc.h | 2 -- arch/sh/kernel/time.c | 69 --------------------------------------- 2 files changed, 71 deletions(-) -- 2.18.0 diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index c63555ee1255..fe55fbb181aa 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -4,8 +4,6 @@ void time_init(void); extern void (*board_time_init)(void); -extern void (*rtc_sh_get_time)(struct timespec *); -extern int (*rtc_sh_set_time)(const time_t); #define RTC_CAP_4_DIGIT_YEAR (1 << 0) diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index fcd5e41977d1..eb0a91270499 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -22,75 +22,6 @@ #include #include -/* Dummy RTC ops */ -static void null_rtc_get_time(struct timespec *tv) -{ - tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0); - tv->tv_nsec = 0; -} - -static int null_rtc_set_time(const time_t secs) -{ - return 0; -} - -void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time; -int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time; - -void read_persistent_clock(struct timespec *ts) -{ - rtc_sh_get_time(ts); -} - -#ifdef CONFIG_GENERIC_CMOS_UPDATE -int update_persistent_clock(struct timespec now) -{ - return rtc_sh_set_time(now.tv_sec); -} -#endif - -static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) -{ - struct timespec tv; - - rtc_sh_get_time(&tv); - rtc_time_to_tm(tv.tv_sec, tm); - return 0; -} - -static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) -{ - unsigned long secs; - - rtc_tm_to_time(tm, &secs); - if ((rtc_sh_set_time == null_rtc_set_time) || - (rtc_sh_set_time(secs) < 0)) - return -EOPNOTSUPP; - - return 0; -} - -static const struct rtc_class_ops rtc_generic_ops = { - .read_time = rtc_generic_get_time, - .set_time = rtc_generic_set_time, -}; - -static int __init rtc_generic_init(void) -{ - struct platform_device *pdev; - - if (rtc_sh_get_time == null_rtc_get_time) - return -ENODEV; - - pdev = platform_device_register_data(NULL, "rtc-generic", -1, - &rtc_generic_ops, - sizeof(rtc_generic_ops)); - - - return PTR_ERR_OR_ZERO(pdev); -} -device_initcall(rtc_generic_init); - void (*board_time_init)(void); static void __init sh_late_time_init(void) From patchwork Fri Dec 7 13:48:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153156 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521833ljp; Fri, 7 Dec 2018 05:49:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XTZmAxdWEe4Xu1xEHzlb+IVts4QLXZVg+bR2YZF1uSoNL2G0Gu5GL7XZU5FsPGIH49jtTA X-Received: by 2002:a62:42d4:: with SMTP id h81mr2277701pfd.259.1544190593781; Fri, 07 Dec 2018 05:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190593; cv=none; d=google.com; s=arc-20160816; b=M/jKqcoKmFWpePI0NkgKDKLvEDnwRkmC7LdApoioZuueqbqNow0KQzp0uUvQnUsJQX bXz2XvpTAG5H5C7Sv3xtCvatxQJ3FbVKPRem/WSRH/a2fiQ4UIH8BXsohZqD8L/LsWcu PTfil+wKNxe5qF+G31u8J9qgLG68Tgaz6eVZv/FPznSncseJiyN1ua/Yo0I45h6Ovrpr z0bC1OqMVK02NfBxtEsgeBEBckPSZS2zAgFkBBVKJ9wnpumJb5Bwn14KLGY4r6BAzd2U HGYSJMXOaWO31LLfSM3eOsla2emkZmR1O8LYHq5C2llWlOPqJ4qXZgAMVtRdttZU3LSh T/bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=XyorxIbZZ04OPHbpzCMNj0JOZ2pDLOZ9PuBxTgx/vQU=; b=KfTVjf1Qq/p2RRBC4EKFo50U0z2KhHNTN/AKSjJ6V4G5ocvu71fVMyVs7CizhJt8q7 b9XNyIGZacz2amXxobcUHOllQuAaKe27OFR7YCTnnp153t9IG0HnGo4hrG/BFcQ/l3er +vyHQ0yv3eG+tZmMdoaGvFbpiE7PjsU+Y/Qq6kzr81dd57leW8GL7ZX7bGVj98UNwrW4 J7qIad55dMbO/7sZIkOlvVw//nKrsB01CjkLAcvFN4qzM1xOzQXBUMXFpSpOi2G56s6F 1cNIcNDXf59mwRau1O03eR4ca4S8DrT7ZsUrwLG8i26RQuONcUtYbHu9Gaq56tLLscLf Qrgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si2990579plr.189.2018.12.07.05.49.53; Fri, 07 Dec 2018 05:49:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbeLGNt1 (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:27 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:46707 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N0nvJ-1hRtT448Jx-00wjPT; Fri, 07 Dec 2018 14:49:00 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 4/8] sh: remove board_time_init() callback Date: Fri, 7 Dec 2018 14:48:20 +0100 Message-Id: <20181207134824.300024-5-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:9cuu4JV5QuwVw4x8eeXazgYWnfEJ9oe/85wD/FKz/VcRZRdCSqK ElfJ/ve9XcqBnx8BJyqiIsEB57Wug3fBiIUqBgeyRuMmHae5DKo5CdofMexzR8FsOWhHa/C EjghrLhfcfrp/jtnerIg1AnC9LMoSRmYOqGl3AItOiIUhn15j2w0ZGlQjqMnuJtLEVL/HCN kuxanGlosS2WHSYnKsDOw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:CpuypnIsk1E=:I+aRj2VUC3orR51voR46Pa RhWJBjhLxLzXJNlt9H9QsNLhgskLJotLc/rJIjAZjfrKGmMkFoW9EAuZl0cuvuAhH1R7trSGY qLnr6/vWB1/6p4Xh2tQ2H0nrL4zfX4ioL2KmNhh86rnA81trWUDL1WtSN6diXW9EhYVLZ1x+5 7ThXc0IchLzNHteYA3v5xElRw5DQJCbb5JbBv7Pa0c8l1XqmaZMKHY2rwU78SQ8ADfqs7jMOd QTUYsw7qAp6U2cAoxV+c+VkAQChQghKAM+aEezHE9rq5laNHFUAxpL3q784tB2GocWZmqjckR H60NXiStBaqjSyR4x0jRVJuh4gGpaEhg/mKh8Ww23Ra64OcQqn1kb5y9zt36AjtHdUqfPDLP9 iMMl7WVWnrLLl6sc6jHFtGCNPOlonsl8xRkkLScUCd2xyOE+lAhOGVI7qeu8zWIyEoM9jS6eH NFY6GXpy/aBzoafjUU82psfGvRhVoPyHV8EBuxtkUyn8s3QdtYYom5Rgq3/SoS4A7HVYULBE3 kVphO9KSWozzlz5ooV84BLdhItX+ZoqNK23E2dbOM+KQbAaFPOZJwJiA9TzjIsv+V6cwJtYsB ZxVvahuuDypyVKG3hOMxVa1hxQbR2GxGDoUao1JoyM7goalikGhm8ReJFTsHv0b5mFoisvy5G r89w+y98oEE3gFrVbrOFMPwYwHncgflkhFZN9RP9zW5JcvGi5i9fEFOMd+5K8lu/Hp1PY4MQw z/I2bXsHgiIqjgb5RxBPYY0mDU0o5MGvUmDKag== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only remaining user of board_time_init() is the of-generic machine, and that just calls the global timer_init() function. Calling that one has no effect on non-DT platforms, so we can simply call it unconditionally in place of board_time_init(). Signed-off-by: Arnd Bergmann --- Documentation/sh/new-machine.txt | 8 -------- arch/sh/boards/of-generic.c | 8 -------- arch/sh/include/asm/rtc.h | 1 - arch/sh/kernel/time.c | 5 +---- 4 files changed, 1 insertion(+), 21 deletions(-) -- 2.18.0 diff --git a/Documentation/sh/new-machine.txt b/Documentation/sh/new-machine.txt index f0354164cb0e..e0961a66130b 100644 --- a/Documentation/sh/new-machine.txt +++ b/Documentation/sh/new-machine.txt @@ -116,7 +116,6 @@ might look something like: * arch/sh/boards/vapor/setup.c - Setup code for imaginary board */ #include -#include /* for board_time_init() */ const char *get_system_type(void) { @@ -132,13 +131,6 @@ int __init platform_setup(void) * this board. */ - /* - * Presume all FooTech boards have the same broken timer, - * and also presume that we've defined foo_timer_init to - * do something useful. - */ - board_time_init = foo_timer_init; - /* Start-up imaginary PCI ... */ /* And whatever else ... */ diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index cde370cad4ae..6e9786548ac6 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -117,18 +117,10 @@ static void __init sh_of_mem_reserve(void) early_init_fdt_scan_reserved_mem(); } -static void __init sh_of_time_init(void) -{ - pr_info("SH generic board support: scanning for clocksource devices\n"); - timer_probe(); -} - static void __init sh_of_setup(char **cmdline_p) { struct device_node *root; - board_time_init = sh_of_time_init; - sh_mv.mv_name = "Unknown SH model"; root = of_find_node_by_path("/"); if (root) { diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index fe55fbb181aa..69dbae2949b0 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -3,7 +3,6 @@ #define _ASM_RTC_H void time_init(void); -extern void (*board_time_init)(void); #define RTC_CAP_4_DIGIT_YEAR (1 << 0) diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index eb0a91270499..8a1c6c8ab4ec 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -22,8 +22,6 @@ #include #include -void (*board_time_init)(void); - static void __init sh_late_time_init(void) { /* @@ -41,8 +39,7 @@ static void __init sh_late_time_init(void) void __init time_init(void) { - if (board_time_init) - board_time_init(); + timer_probe(); clk_init(); From patchwork Fri Dec 7 13:48:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153157 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521923ljp; Fri, 7 Dec 2018 05:49:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uf1SeRf/AYL0Qt7f18N3cL5mgUHX6FUXqri2U+bSsOImrlarJuUgfcwVwMnv9ZUqe0oNye X-Received: by 2002:a63:1766:: with SMTP id 38mr1947443pgx.299.1544190598893; Fri, 07 Dec 2018 05:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190598; cv=none; d=google.com; s=arc-20160816; b=Oa4U/Z2BcbvGsCQYwBOk39VcAdWIrzBWheVExH8Dv7Jc+2dxUqiSHyDDjNOI/3+XyP DolzH5rW0E/0Rnw0EdEMnPT3YyXjIWD8vssy92tXgy+iIUSffxWd8Balmfknl35Hf3D2 7uPh3bhZUT8+3s4pEu+uzI4SxyR/wkXgIDaYYoONkR27Ln9nY+i4PVZeeprbaQEYcXW6 IY8t+YwXBk4TYL8S1Jx09N5vlO6JQulkNyi9uKrDzUZDpzNImQcyYg5vQQZfSf4WfPlA pKpuIACpVn/v4Iscz7C12Xafrr3MKCPALnCvMo5GgiraC65ebcaxSZcz30lvcCQOA+QO sBYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=rnkDALge/4W/XnGYJvk/5NhNQN62icBOuqg3uLsaB2k=; b=Y1kKhb7er9qiC7+W9POQrcbdz86QMYc2yyiYBydo7eMSQZ8xzQIvzdh30emnJrZE3W TPxB2do4aZVd6RCe9lnwksvhFkVehBvI6OMmVmfnTZexC118R/ghSMHTHHOOSOB3ldyJ SGwrRfL1sDX5eZd7YwR9JLNIArSq78vVOvbX40+uquCAqi4MwdqOyfXtZJCFxW4xYnLG +97RsyDXs/iaBuyKwRrApa3JV80aUVYgG0MJxmd/8dgyyUjP/1mY22eThwXg9dtSdHLX 6b/Ur9D0tldocTDQQUIpWfG2GPcBhzJmkY8wwHsc+bX4wOBtQzbbUBkF5o2K56+WiVLh AFBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si2874689pls.30.2018.12.07.05.49.58; Fri, 07 Dec 2018 05:49:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726077AbeLGNt4 (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:56 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:55939 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MFbFW-1ggky21jdW-00HBPo; Fri, 07 Dec 2018 14:49:00 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 5/8] timekeeping: remove unused {read, update}_persistent_clock Date: Fri, 7 Dec 2018 14:48:21 +0100 Message-Id: <20181207134824.300024-6-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:OcW1EjK2QvkncvWHyHl+OxmhGy7ZIKUinp3oxKVRHZE3HIC2kDW iOCDasX8geUc44bVIaIVlJa7GQIzVPeXjQ/zACjzeVgWT75LzL9QxQzrFYEuy5V4VEP0LjT 4jDaOZb6zd2Xw7JVbg2BuCIEmiFCUNMtMhXs9qq1ShDabg1TFl83A32PRR/J9iVbEl7Bbf+ 2TybBy312Ym1G1uDYThZA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:OjdzZaaMYb0=:hhn4tt77z/XwUlvehXYcED BQ7aygCmWjIji7cDKTxf6sYxpcjy6Ewxb1rXdkUM8JZcCcdbOp/fY82fN1NMvgXXXRnZ/Ydr3 eiXvXcecwXh2wLP/Af8CfWbyXi7qN4K19mgLMsamvLcf/V41RNoaLHK3oRpKjPqojAw3XMZzu J79lzjLWKn9OehvIjAKcHKvofx4CVoavUbExCCNFj27iaBTeJRXGLb4I6kfuvLmMIK3b3kOZs LFBldss6SchWde1IvoH8PTVhbeWZkdXKS31NvRZQMVAbPGjPqF+GDyyxb2woQwGHL0Lh4JDZT 3Y/PqJT6+s3IpnXI7wAu7sm+xir+mhdBAzVnzpOfbd9lre6F/XDIoAPbyePDOu4E60yeTQPSO 5gG18xlMWw6Y/4nkaqG724NCZulJfgI3Vt10Fs52m+Jw8dGIibY4KP+KpcDaEeFzogDL1ROkO iZTLa1xsYV/W6Z+xPuWQ/6esK0nrlqmCDSteCwlgey8UWOLXEnTmrRa100f17bjNHINb4m4VF PHBIRwIBCeFYgdGYgMKwA7b7kQK1uUWBz+MGc6OtvjNEMsVvezimUnQEHIU0ungyZeEfAZPuG V9auTF3Vk6qSqUlj/5UGB+hXR6ehvBEiDcfGbBb107fMCfwtAhGKeFgrLiuSTEwJ3VkWx24OR aEqSTl+tcZx5c2XA4SeAgVc8ESiW+0fs3IP6ChomTM0gVHSUdkvIr4UXYfTHAIP8WArSaoJMs JgyP82vqq3Ymt9L8RtNxHBCbL2yVulTB2zqNxw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After arch/sh has removed the last reference to these functions, we can remove them completely and just rely on the 64-bit time_t based versions. This cleans up a rather ugly use of __weak functions. Signed-off-by: Arnd Bergmann --- include/linux/timekeeping32.h | 6 ------ kernel/time/ntp.c | 10 +--------- kernel/time/timekeeping.c | 12 ++---------- 3 files changed, 3 insertions(+), 25 deletions(-) -- 2.18.0 Acked-by: John Stultz diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h index a502616f7e1c..0036ff314ac5 100644 --- a/include/linux/timekeeping32.h +++ b/include/linux/timekeeping32.h @@ -52,10 +52,4 @@ static inline void getboottime(struct timespec *ts) *ts = timespec64_to_timespec(ts64); } -/* - * Persistent clock related interfaces - */ -extern void read_persistent_clock(struct timespec *ts); -extern int update_persistent_clock(struct timespec now); - #endif diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index c5e0cba3b39c..e23be418d015 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -555,17 +555,9 @@ static void sync_rtc_clock(void) } #ifdef CONFIG_GENERIC_CMOS_UPDATE -int __weak update_persistent_clock(struct timespec now) -{ - return -ENODEV; -} - int __weak update_persistent_clock64(struct timespec64 now64) { - struct timespec now; - - now = timespec64_to_timespec(now64); - return update_persistent_clock(now); + return -ENODEV; } #endif diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 2d110c948805..eb09be4871b3 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1467,7 +1467,7 @@ u64 timekeeping_max_deferment(void) } /** - * read_persistent_clock - Return time from the persistent clock. + * read_persistent_clock64 - Return time from the persistent clock. * * Weak dummy function for arches that do not yet support it. * Reads the time from the battery backed persistent clock. @@ -1475,20 +1475,12 @@ u64 timekeeping_max_deferment(void) * * XXX - Do be sure to remove it once all arches implement it. */ -void __weak read_persistent_clock(struct timespec *ts) +void __weak read_persistent_clock64(struct timespec64 *ts) { ts->tv_sec = 0; ts->tv_nsec = 0; } -void __weak read_persistent_clock64(struct timespec64 *ts64) -{ - struct timespec ts; - - read_persistent_clock(&ts); - *ts64 = timespec_to_timespec64(ts); -} - /** * read_persistent_wall_and_boot_offset - Read persistent clock, and also offset * from the boot. From patchwork Fri Dec 7 13:48:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153160 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp522316ljp; Fri, 7 Dec 2018 05:50:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/XNkWgZs3UuAFHDMzB241XE7lRAGNsVCHtAmhHiMoR96ez28q4KxuftnMkQ8fWKwr2pdj05 X-Received: by 2002:a63:e348:: with SMTP id o8mr2000752pgj.158.1544190622035; Fri, 07 Dec 2018 05:50:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190622; cv=none; d=google.com; s=arc-20160816; b=ZOdpSWNaW1q8d5X5iyxcjdU0zDgkHUXMHSkOF6WNYk6DsIT8L0/s8+UZKoojfPD/BE IjPu+j+5llfgj36AxlEQZXymrZvepyxfYFUOu+8bd98Dy2AslD1dlzBxe0oHrBYlE3Ja ufsq5C3U7602r9RBvsFduNzoM/+1FkBijgwWw0xdMa/H3CHTWTZSKkm2/RvoAmvEXw5H EF2ZxuzH4RVNIIQ3KgECKjUJezVnJ3wXRd9qPxj29Tn474x0fbyRJJyWeou924ikp6E4 riZoCmHC8NUO5zdmjmT21IIL4JPoxN6X59Jad3sUh/50b2LDWM/41kby68//IqW9tMbl Aabg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=NdbZkoKM0KHtBLh7up/ctbbIkM24ExnsWuorWRjXVlg=; b=p6jBkipaRRfoWxwyDHfZWnEeZ3lkb1A/e/i1/7FDraEn7i7QtP0C5GnickeKQySjZM F2cv/BrwtHov8uVU02Mse2T8VFL0lz2Dys+E192VBOwSt/wbkk2p2/h+EItnyxXSDuAs rd4M4pzbz59C8A9tpsyUoxt4eJgEYNYKW9L/tnh9Fuitsm9dNAZOAGLlANlV/60jbYEy LnrbbhyZOOdjUuLPB+J8cuhSX1/Ytr5bavqrb8cBrGda09ds1ExXO52X+X1H+Ru2jKle xRjR0q7PZGHq94PIGyvkb7Kh+HFCVW9mifgIKHsXAgDJIP/LvR2dzpQZkW8JGwwBA5zG BRSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i90si3026156pli.135.2018.12.07.05.50.21; Fri, 07 Dec 2018 05:50:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbeLGNuT (ORCPT + 31 others); Fri, 7 Dec 2018 08:50:19 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:57529 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MD9jV-1geJ3d3Uqf-009BCl; Fri, 07 Dec 2018 14:49:00 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 6/8] timekeeping: remove timespec_add/timespec_del Date: Fri, 7 Dec 2018 14:48:22 +0100 Message-Id: <20181207134824.300024-7-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:n5iXzgH3nz5j9ExoE7qeuRv71WW7HzR6W7USLlnDWkgVtakGuZV ulpq/wbfp699MXOSqTyLpFkgJOmlJr+/311bmNo4Rs7Ov77JnwLxlftbYWaKDpKvWF3JpAM i1vPFM7N5qyXy33KHSkH0qS0MX0z7ZqWIX+Zfj/otckG+fjKDXQ+ufRbvIMQv8lGfkf7gNQ 2BrMmZoZr9cdVlqAo6Q5A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:NvnXQW6PUSU=:EHXeZBX2RY6J18BcziALTu Vg3NPc6w5qYSOTM5UNR8TNXi6jYQh5ASIupGaqhjkylS/gnpkQrled9WsSDg4W4000gvNbsxl d/HHm42gNV7PeRiQd0edvWA9sE9A8lVLd6aIu6C1850rdIvY6fuKo+y2V6dBp7t1ie36Ie6CS P6Q8aOfNKoFL81No4AVsekuL5MCU1cFv76RC/dziFQgsSoGDem+/oQlyD7W8jU2YxjNNs/jCE HX7KKtV5WCi7OLm91Z7cw9PRoZFQv9i/GCX9AK8OSfzK/3rQx2vIKT4yHky3Mt/hccfLiMFw7 OrOKwPq3MIiPyRrEqO0qLwnTQGKrVHOjaFz003tFE/+IxK8rekpOwcdI1ycMtksnMQ1o33kQY z+ZgELeoOHTCFxp2Gew6kWQ/1MwMWPf2/22mcxLMJYeGcMS2JiOVKvqidjKEARaPfmAEY6CxJ 8EakQk0w5xz/851VDJ1TrCWNC7h19V/7g6sd7uRXsgy+QjB2TbMqqUlLr9zCNzIyHSgg+/xSr AbrtJ3Sewkaj1BmC6BTqzDduU80dNKnbA79AGmSylltyYEI2kcPRY4o3RFKjStUUHSfsDuVES EJys4wmfMdyNDJsttXtKqSb9X93CT426rdJs5QOhjUTW8dVMOHrSToV/WVRdbYG8qIPln5JMm MK5DLI4tqqricrQwL0DsiNaIDYJbPc81ldhY7MFLzOLbt/ETLCk/iJ/p+WDXV1s+FW1NyXl48 s2Qw5bmsr3cNWhJcg0yr/Y+1CG6xpkXOIsHDjw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The last users were removed a while ago since everyone moved to ktime_t, so we can remove the two unused interfaces for old timespec structures. With those two gone, set_normalized_timespec() is also unused, so remove that as well. Signed-off-by: Arnd Bergmann --- include/linux/time32.h | 25 ------------------------- kernel/time/time.c | 36 ------------------------------------ 2 files changed, 61 deletions(-) -- 2.18.0 Acked-by: John Stultz diff --git a/include/linux/time32.h b/include/linux/time32.h index 61904a6c098f..118b9977080c 100644 --- a/include/linux/time32.h +++ b/include/linux/time32.h @@ -96,31 +96,6 @@ static inline int timespec_compare(const struct timespec *lhs, const struct time return lhs->tv_nsec - rhs->tv_nsec; } -extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); - -static inline struct timespec timespec_add(struct timespec lhs, - struct timespec rhs) -{ - struct timespec ts_delta; - - set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec, - lhs.tv_nsec + rhs.tv_nsec); - return ts_delta; -} - -/* - * sub = lhs - rhs, in normalized form - */ -static inline struct timespec timespec_sub(struct timespec lhs, - struct timespec rhs) -{ - struct timespec ts_delta; - - set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec, - lhs.tv_nsec - rhs.tv_nsec); - return ts_delta; -} - /* * Returns true if the timespec is norm, false if denorm: */ diff --git a/kernel/time/time.c b/kernel/time/time.c index ad204cf6d001..532bb560252d 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -386,42 +386,6 @@ time64_t mktime64(const unsigned int year0, const unsigned int mon0, } EXPORT_SYMBOL(mktime64); -/** - * set_normalized_timespec - set timespec sec and nsec parts and normalize - * - * @ts: pointer to timespec variable to be set - * @sec: seconds to set - * @nsec: nanoseconds to set - * - * Set seconds and nanoseconds field of a timespec variable and - * normalize to the timespec storage format - * - * Note: The tv_nsec part is always in the range of - * 0 <= tv_nsec < NSEC_PER_SEC - * For negative values only the tv_sec field is negative ! - */ -void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec) -{ - while (nsec >= NSEC_PER_SEC) { - /* - * The following asm() prevents the compiler from - * optimising this loop into a modulo operation. See - * also __iter_div_u64_rem() in include/linux/time.h - */ - asm("" : "+rm"(nsec)); - nsec -= NSEC_PER_SEC; - ++sec; - } - while (nsec < 0) { - asm("" : "+rm"(nsec)); - nsec += NSEC_PER_SEC; - --sec; - } - ts->tv_sec = sec; - ts->tv_nsec = nsec; -} -EXPORT_SYMBOL(set_normalized_timespec); - /** * ns_to_timespec - Convert nanoseconds to timespec * @nsec: the nanoseconds value to be converted From patchwork Fri Dec 7 13:48:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153155 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521743ljp; Fri, 7 Dec 2018 05:49:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/WTY+TlnOVsPKNT3yFEp4X7UyTtCNdXyB/L0Is5Xp7srbzJrsGoiuSRbaKM/stgeFQwKOzG X-Received: by 2002:a62:e0d8:: with SMTP id d85mr2291457pfm.214.1544190588073; Fri, 07 Dec 2018 05:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190588; cv=none; d=google.com; s=arc-20160816; b=UonkuUKCP7FXN/LIzjyNuQZEaGFM5rczJVgSFKpLZ8W229/cDaLc5sXfmVm/sL/j5H hqt3NEJZZdWR7Iivk2O9Wug248udsR+kNJpSEJhysgoKHhTN5bgxurIJ1iK3viulA9m9 CMroSIRm0HhrVt8OlNI+nK2U6VPFaIromPcnq43xi537r/jUWUDUi7KC3bbwXqK2v0Dn 9mjyAZiOyX7iJZ4wN/WNU49VrEmlHRUdJaOpGGeZe48Fw8j3vzrZSFRguiVPk4iDNCfu acZhez/PJwNOHNIIlUtCqUNWiz1v8Zmw/8/3yHceOydw66ebCugexIqye1D5TzsvBMuw xaKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=h+ZZGgg4G7hoIRH8ukbKBM1p1qbTfAI6lHgga/1Y4Po=; b=PHiABUzh4xsoGMDzJCrxiX6J48ukNklSg3dx7Y9LRwQbNSBnzDDpwotV5IYUsLZDPr bT/VQzXR0e7fKc3ZTQ63d0w22UUG+TwaFHfq0vUmf51tfcaxSUuN7jOB5MU9LTxrVsAy J3wwtYkw0zcUIgKmwJqJVbW6talzkIDjEwMcRIVZWqmujFVH3y7pOmyBQ/MowV9P0Dv0 aGQmowoB5j6ScATtZxlLmaWjssHxOzpZ4Mhv/agiym2myT5zDjR/jVUkI/Fn2S0cakQV PtLeKEd5E/ATZPmZ8OWfpha6anhrhOyFirAe4TKCvWm4fDRasUm0ufPknUODHS5TAo/h J+MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si2883911pgk.169.2018.12.07.05.49.47; Fri, 07 Dec 2018 05:49:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbeLGNtp (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:45 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:46225 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbeLGNt1 (ORCPT ); Fri, 7 Dec 2018 08:49:27 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MJmX3-1gkrXY12oj-00K5H1; Fri, 07 Dec 2018 14:49:01 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 7/8] vfs: replace current_kernel_time64 with ktime equivalent Date: Fri, 7 Dec 2018 14:48:23 +0100 Message-Id: <20181207134824.300024-8-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:/PWWtMTAj7kH3IX8FIHaCh0M4ZVgezPmBZs+fNsTAGU/xKCysp8 dL1kT65HFb01mnt9LbC25fw4I9taGCHDZ7iyww/h0B54yAz+S3XluCxtTq7JwLRpd3eP/Vk dLnCg79x8l7iPHfhhKj2XG91qvOvVX6MQ/Utqc/01ovw3KIOCZDZFDJCMqelq3kCPbHJSby UObdskdXz+J5ViYiPwYvA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:TN0H1/fwOtw=:By9RfTk590MZiC4vntyyQ5 fbOdGN36gwZf/zI0N7orC4+OfgmATkMGOmkFkS2OJLu7O5t7wFxEOYFlmxvffT+P6d9Y0oZNC NF+FfpOD9EsKrDfzRcasCYnHNWdt8dcOjGkNRfoNSuQVSpeAMaHpwPkY/RjMEFTu5PNzwRRgv ZoW1z+8yzUulzNHAn8jBNKY12QpJW/ezW2SrQujLhOdi6WpdCilcYRRFwJf+3wxoBHxcY7VrN dIu/bxnr2Mi+fPxTuIskLui2vx5kInvB7HOdRl2jvJiXKHtHrRUGnZmr9s1AJj4rJXzsya1FL jl3gX8KIBgd814Ioctnf9B954YWyNKFtVNoYdGGBQLAqJ2cjadjEeIbozCci/O8Fc9kzM+dxl Ec3BJq5dwFl8WfmxNuw2szW8x1/y4CQIYR2j0DPPdftEi9tEc8F5A9jaP13c9BFbqZX0nPO04 i2wLI0E9bLyeq3dg2s6+Aj3ocdxrcoovfe3rXmEo7GqYbhTxH1zQ1fVJZzq7IZW0M+MOsRU3N VYbSVh9jCX8OI5gOVOsQvCKSQ2FbZ+LtYSLM03oPtTub0PsGsAlAv6unS5WrvCOvAgr+PbfFe G4XN0tVvFhHtxSXmNPph+5fLUjAT6GMWp5y3mCZwHwVLZmiqTUbw+ftaGm1wlN722YtC/Nt7D VWjzjXIb5B0oWyhUvdIEwM2vfM6s57OxTjKjXKrPoZHz4fx6As958V2BHmggfrb90a97d7AyS SucssamhWShBmaN6UH++D5cPVBdLF3Wfe8cKtw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org current_time is the last remaining caller of current_kernel_time64(), which is a wrapper around ktime_get_coarse_real_ts64(). This calls the latter directly for consistency with the rest of the kernel that is moving to the ktime_get_ family of time accessors, as now documented in Documentation/core-api/timekeeping.rst. An open questions is whether we may want to actually call the more accurate ktime_get_real_ts64() for file systems that save high-resolution timestamps in their on-disk format. This would add a small overhead to each update of the inode stamps but lead to inode timestamps to actually have a usable resolution better than one jiffy (1 to 10 milliseconds normally). Experiments on a variety of hardware platforms show a typical time of around 100 CPU cycles to read the cycle counter and calculate the accurate time from that. On old platforms without a cycle counter, this can be signiciantly higher, up to several microseconds to access a hardware clock, but those have become very rare by now. I traced the original addition of the current_kernel_time() call to set the nanosecond fields back to linux-2.5.48, where Andi Kleen added a patch with subject "nanosecond stat timefields". Andi explains that the motivation was to introduce as little overhead as possible back then. At this time, reading the clock hardware was also more expensive when most architectures did not have a cycle counter. One side effect of having more accurate inode timestamp would be having to write out the inode every time that mtime/ctime/atime get touched on most systems, whereas many file systems today only write it when the timestamps have changed, i.e. at most once per jiffy unless something else changes as well. That change would certainly be noticed in some workloads, which is enough reason to not do it without a good reason, regardless of the cost of reading the time. One thing we could still consider however would be to round the timestamps from current_time() to multiples of NSEC_PER_JIFFY, e.g. full milliseconds rather than having six or seven meaningless but confusing digits at the end of the timestamp. Link: http://lkml.kernel.org/r/20180726130820.4174359-1-arnd@arndb.de Signed-off-by: Arnd Bergmann --- fs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.18.0 diff --git a/fs/inode.c b/fs/inode.c index 9e198f00b64c..73432e64f874 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2146,7 +2146,9 @@ EXPORT_SYMBOL(timespec64_trunc); */ struct timespec64 current_time(struct inode *inode) { - struct timespec64 now = current_kernel_time64(); + struct timespec64 now; + + ktime_get_coarse_real_ts64(&now); if (unlikely(!inode->i_sb)) { WARN(1, "current_time() called with uninitialized super_block in the inode"); From patchwork Fri Dec 7 13:48:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153158 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521991ljp; Fri, 7 Dec 2018 05:50:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/VyJLHuNnxquer7pAqwolbUTY+wht+wlZzWLIfYD9OcHlCG8LPRsyTmuymWN9fQLNGFhRpJ X-Received: by 2002:a62:68c5:: with SMTP id d188mr2405433pfc.194.1544190601994; Fri, 07 Dec 2018 05:50:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190601; cv=none; d=google.com; s=arc-20160816; b=pVHjJnlKrr3LZM1e7fnaUBFmJq6e7b/epuY0EL6GL+ljZhupMk0XWo2u3p3gjHttBe xAUOkJIb4/tDc3lVt/+/HhzT9woFA3vQssA4Xeb6CBaxSqQad+noskEQsd8L1cbkxXtY 9pVBDM/LnH0cPkxgTGBz1qYOmIS4wmUUsIKjzNXjNigch8GsIUuIJFCPZTQr0/a73YUI FB5V5d9qC8QyliPkzfGxcfAg07ETXDYN+Muk1n/cZtWDmuhJjRaz082q7DVnqi84TcS4 OEvyw4rIeqY/E8553UjV0Dy3en5Fax2FxyrvOySyl/zOeM8Bt5dAw6ro7UISiRjaF/y4 l3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zALRb/s+sAgSsHleRHdWk1otOrdxAfnvMWgumqX4trk=; b=oTNML8HKXlTtFL6H3fsJrOVw/Fg8Q/uXJn1iLxwFLiukzT6cJPL25YxS9OPJ0Totsr rnHSwSgmnFw28imgNt8adYI3jxT4Wtqk7X4G+blnlBi3amR9ihjk5pbuQMhud0wW2Dz9 YWo3xAQxpLrFglHc+UhQtxoF8O0Y6AmPHn5xpTTldDNCihD9KGNHqxlW6bQ0pLQAnuSU D8oPkntD9Ibfzviz649jsW7Zv+gkWUspIkFNGJa+0CKdQTq54dOqqLQ4HTRiwPmDvvC5 dZjud3/u2Z898AMxlplX6WOUGJ8LteaXUv9E0F9KNJ1Nhg6aNTecFb8u6LoHMzVHCeil rIyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si2874689pls.30.2018.12.07.05.50.01; Fri, 07 Dec 2018 05:50:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbeLGNtz (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:55 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:53479 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbeLGNt0 (ORCPT ); Fri, 7 Dec 2018 08:49:26 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MNtGq-1goy972j72-00OE8Q; Fri, 07 Dec 2018 14:49:01 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 8/8] timekeeping: remove obsolete time accessors Date: Fri, 7 Dec 2018 14:48:24 +0100 Message-Id: <20181207134824.300024-9-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:4q8hGpFp0fG5EmYuKhTDqJXQLIB2ZrNwqYnzxKG4qaFm5RvWFyl NGBIj/D44nLXSFSYGO9DFv9hUXH+3GzYV2CVw/qHxKSzsZ0vtbf7NEkHbTn42eHwCUDRoPA 4YOEdqvE3d8qnJGRx7hzTpPuXkp2r8z6hzMMDdC76JOLVZjdMRPa/aNxoFjaYQJPgO6IwVC xCVGH01REyEosZhzRplmg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:eDPw5ra8pQk=:j+wBAUu+B10noLnFh/U+Ez wVigcBAnD2/GpGoPJolk4KhTu1dL1TIUiexqQuFS0FTMOodJWIPxmRlqYS9kuAkVJmwzTaUo2 CnmMMkehrO3asT/lPK7tVNHo9cMeciaHYqLy0WHy2gTyvypXaa0HoUo82Hf7DlhqvSe0AhtPi ilVj5ZurhAhSY0dkJroBHR4LHgWppmr5JZORPG19Ud3/O24kmeshUHg9G337GkgdrPrTzBuLI uvPYFJXi+dLcDz9VEVZkVu2Rm+VvDsa9H9F07H1+EpDWmOc0odH46irKlu00F+J+kDf857Jem Hwh8tzkDoiZpdiz/I+uL5VF2djy0alEtzzlxJiVv9UpFWT00CRO6VaacUXkhshpz07qvc8mqH r38Db2iOGJWTXHzWLEAISjQPG3c848sDuTcp+yRCYMZubGHSeQH8jieA0Tb+9SU0sOZ4LKqlc B+NL0DLxH/eku6YmfLNXQ00uoxPF9FI1oja+p9XY1CXhjOZo3nqjnktGBxvI7hLB6rFPth904 isb9B9PofCW2/FuxbY6HO0VrDZztP66k8gakTnOFcKz+0qpUBImMpf9KL7ypDOENUaP6a+Tss wGVbniz52ZyEWek5rSxxVum+1GvJ7c381gtXPcUaPEmVov5gr4choYjri7IEzau2DcLksjJch n02/tAzGF0BgEBrqxS0G89o1d/TQ+M/8wo1O49sdSiGjbH/uQ+k5MCj8emIGyguRVwIaxE1so 3U98EbDn6RgRmLp8pHrGuILA5p1RXEvOrGV9Ow== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no more remaining users of these deprecated wrappers, so let's remove them before new users have a chance to make it in. See Documentation/core-api/timekeeping.rst for replacements when porting old drivers that contain calls to this function. Signed-off-by: Arnd Bergmann --- include/linux/timekeeping.h | 14 -------------- include/linux/timekeeping32.h | 9 --------- 2 files changed, 23 deletions(-) -- 2.18.0 Acked-by: John Stultz diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 29975e93fcb8..a8ab0f143ac4 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -262,18 +262,4 @@ void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock, struct timespec64 *boot_offset); extern int update_persistent_clock64(struct timespec64 now); -/* - * deprecated aliases, don't use in new code - */ -#define getnstimeofday64(ts) ktime_get_real_ts64(ts) - -static inline struct timespec64 current_kernel_time64(void) -{ - struct timespec64 ts; - - ktime_get_coarse_real_ts64(&ts); - - return ts; -} - #endif diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h index 0036ff314ac5..cc59cc9e0e84 100644 --- a/include/linux/timekeeping32.h +++ b/include/linux/timekeeping32.h @@ -6,15 +6,6 @@ * over time so we can remove the file here. */ -static inline void do_gettimeofday(struct timeval *tv) -{ - struct timespec64 now; - - ktime_get_real_ts64(&now); - tv->tv_sec = now.tv_sec; - tv->tv_usec = now.tv_nsec/1000; -} - static inline unsigned long get_seconds(void) { return ktime_get_real_seconds();