From patchwork Mon Apr 23 08:10:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133977 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp712097lji; Mon, 23 Apr 2018 01:11:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/jOX7X3BBwcCBKLc3FFJ98RHQMX3tkTbG3wykcB/3tvGuHy5mRTkPvF+KITU3theltk3gp X-Received: by 2002:a17:902:830b:: with SMTP id bd11-v6mr19765059plb.13.1524471094342; Mon, 23 Apr 2018 01:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524471094; cv=none; d=google.com; s=arc-20160816; b=lvEOdh2toA63vtzZ01Pu8Qtelc850qZgTvU1bo7rIG14mZCJ9QZF1BVyAGyMmupseh +e0kn2CwqbW8Pg/O5o1nWKnmbLDefdgau1QJJuLxIPLicJXQOfFiXg3bd/9t6Hv7R9z2 9LbF5fPhFcjKmyA3CjXur341HDXLLAqWPoiWdLtVvrOHL29/HxJcu0bIKRP0yEQqJE8j I9uyu/hnxkw2IfGbZ1/6wKJ6oa0vlsiakLfTAzNU1qMBaHWfQLI4+VEUbiN5+gKQuI4I JJA7X1yH9CfAVY5of/IZ86Z8walOCebDZSqkZjflN/xnoAzIBdMH86K+N4V5r9fazEOH 6hSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=d2ms9k8Y9mM6hATgFZ5uXo3J/8p2b/hYi5KZ41y97l0=; b=BuPvY0RAkzbC0sfEs6Z0oXNgMW6KpKrzxBpvuRTpMkpVlwkX12pgWGsKyhIWc0du9Y hQXZDVoqI5X+vFKtbn1LXy7AxKamBqK+rAHJu2z72OJ0R8NnkoJiH5p1iAXdQNbHtwut GHZezIW/bmTV+O0sRqPaJPQN9g5Aod/sK/W9gHGBAGPr+hAWdAAwcBqhqSf7WHU9y3Rg 8+DVnnRYlq8E/EI/uCqIm4/RhDQu1VrwuTjelNTdyPMNTIFhd6ksMpOFP2MFLbU1bnZZ 1BifaZBR89aAvuZsMlarVcxnWBo3xAngCyixOUJKqxLgKKgjbvY2hLRJUHUTHMBrijB+ Swpw== 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 d125si10504191pfa.263.2018.04.23.01.11.34; Mon, 23 Apr 2018 01:11:34 -0700 (PDT) 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 S1754290AbeDWILc (ORCPT + 29 others); Mon, 23 Apr 2018 04:11:32 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:33711 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754198AbeDWIL3 (ORCPT ); Mon, 23 Apr 2018 04:11:29 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Mc5pe-1esRU03yUg-00JHBN; Mon, 23 Apr 2018 10:11:19 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] powerpc: always enable RTC_LIB Date: Mon, 23 Apr 2018 10:10:25 +0200 Message-Id: <20180423081114.1813726-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:zHC5cDvJ4I0YEcbUZTRFCgoXtCwXB1uIyBYT/fjUYm5JgsYfV28 WbVlciXx6YZBE75jhoWJ47JMuSiWI3Rg0WwZTgDHA7XYNaUWKohmd8DWk9NRHwv9fqKk1Xi qlJiW6xHLz+JeY0vm6doM0kGCc1ZeHZ0a822JCDu8ZrIwpn1mjSPH/tq+QO18ibPhgPdJFr h/C8ANmaVfGQnGPlNKRMg== X-UI-Out-Filterresults: notjunk:1; V01:K0:8Xb52kNxDeg=:WkLx3KFEZMwKUTQtAwvD3u LVYdIErgaSsMk4ytvGlPGxTmBhJuJGf++LpLviEpeVQsjq9cp6j701OLX9QE1UOrKvk6awNV5 1Of21RoDreY5YA/eegHM4WGdLRYB/lGmcTDVvUOoW8pcywSOb5JsOX8Tv6hqfiq4/6oUjBOFM ezjw5QPrhpoMZqf0Qz/KvpMCuRZA+CxVZW7vrlVZYQFvf9OPqvW55ROnlZBXzpm5RnxqhALRM 1KHSHaEQKzM2qS5JLf5juv14ppbDPINBh3rrXMaDGzwzr/tVTLZ50uypsZpuTiOj6+Brn9vA1 p/7N9Sfmbi14CpTHWemEIV7sGR5hJ2pzTPRhZCu21i7oWVo45W/rIL7r9BHZ0J1nTSkI44wuo Gfrfu7u9bEq10KX3OIQTvFTMoWV1wfWFqRFFmcOoXjUTqKJ9DUugtrwl3wOeWNOTHkA8R0o9h 06B08hVxTdCczPT6I4YhIhuIlr3Q+JRR0kYVYj6wrNJQBZe1j6jOzULaLPrn97SSpuoaYqSj6 wg/UkAAUA46Ot8f7o0FBJbwg7MDwE/zjxGY656V/AERypsfSJaCtWojgpLGYTsaqP/z14vHca STChZ88QTZJmVJXJyj32gm17aBz8m/Nw3iSmmkUooWUA04ee8j4fI8IkxtFcSHdWOqpmTw6bj y/lHQVqn85dRv83YLKzkX/4weqj9YtJOFQ/Tp5WQYUBRWoEJiRYBlInKBWiQHGhHXLykC2CQ9 u4Dq8rnxallYXnTGD7N+Iqy9F8oCUsBEv3/PcA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use the rtc_tm_to_time64() and rtc_time64_to_tm() helper functions in later patches, we have to ensure that CONFIG_RTC_LIB is always built-in. Note that this symbol only controls a couple of helper functions, not the actual RTC subsystem, which remains optional and is enabled with CONFIG_RTC_CLASS. Signed-off-by: Arnd Bergmann --- arch/powerpc/Kconfig | 1 + 1 file changed, 1 insertion(+) -- 2.9.0 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index c32a181a7cbb..de2cda320fdd 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -232,6 +232,7 @@ config PPC select OF_RESERVED_MEM select OLD_SIGACTION if PPC32 select OLD_SIGSUSPEND + select RTC_LIB select SPARSE_IRQ select SYSCTL_EXCEPTION_TRACE select VIRT_TO_BUS if !PPC64 From patchwork Mon Apr 23 08:10:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133978 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp712402lji; Mon, 23 Apr 2018 01:11:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/G4dEKX1DLQDHveY5vBixZZVQHjqrIWcREc/YBrZg48w6SrXKtLK/bp7IJAom2ft4h5QPC X-Received: by 10.101.100.132 with SMTP id e4mr11070710pgv.102.1524471117621; Mon, 23 Apr 2018 01:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524471117; cv=none; d=google.com; s=arc-20160816; b=G8NDy/Cqbtgo7IBAG2RLD4y8W688a2wl9Y/1lYbo+sskUbA0qWR2d5g5od3cLt3BVh apkby7icLu10lsaWDZdXPrpUxoIugMh8BCkAK6tIDsNRwTYy3f8QtxLpPl343aOcqO5v tpVh902vOkwBJH1ngMjMCuwqy3gUN1qdPxwINxBa9MlXMqEghvFuZOeOfjeV38LNzIBI Ajpy7IAWqqYNqSwr6cU4LmnxCG2Zz2jGZ6CJYaubynT4+o5RdcILGg2vcgb7j8t3x1ve CAHrAGDw3RXC+apXXUaQS7qdfx6cqgVd5jzJb6RwqMRyC5q7oWzEoYyRpIplMQTe8SqW sshg== 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:arc-authentication-results; bh=iDjPUI+zsNuBzeN4qZn57VJB2En3jmd2ZLwRWUgjhFc=; b=fwJ20LQFGE1O62Gy4ZMk6z20xz5KWqiPzbmiS6oj4T4i0COcjwNuHo6qBK9fH3ErKA VGk01RCYoY5cYcfE4Ns8/BREUHc5qqw85Ki5/FXjWqhiUUbzzzy32Wq2j4kfu8AehoJv IqGQqHBAjrQ/WXQt+QnAtWy6XGzVTu5lwWVjUpLlY/TSVg0vSwN/u1FRNqfxjELGG6Ve ukfUsfx83TyavAODlEznygizdUIQ6KuWnIl934n4u5cDLMD7MzYwSQSOAJ4IxTOJgvS5 Rup8CpkKZtLb+5KQiFwsJ/oZ2wIZ3L2FRSUbS9G+DMWfjt/MnGkbPqvGKy3ENINC3MlA mbEw== 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 g8-v6si10532361plt.254.2018.04.23.01.11.57; Mon, 23 Apr 2018 01:11:57 -0700 (PDT) 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 S1754393AbeDWILy (ORCPT + 29 others); Mon, 23 Apr 2018 04:11:54 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:50841 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754345AbeDWILu (ORCPT ); Mon, 23 Apr 2018 04:11:50 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LtzaY-1eRwQU3U2A-011Rgj; Mon, 23 Apr 2018 10:11:40 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] powerpc: rtas: clean up time handling Date: Mon, 23 Apr 2018 10:10:26 +0200 Message-Id: <20180423081114.1813726-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423081114.1813726-1-arnd@arndb.de> References: <20180423081114.1813726-1-arnd@arndb.de> X-Provags-ID: V03:K1:oCKfqueQc3BahMQdSsnDhtmP/NVQMfoZj4fVyZdspBrbMZjxtnF kSUZ3PP2F8cFPYm0x2uY/0Dsb8t9bbkHtkzDA8ZzhIBX43qPEaVsHtp/8KWKSLBUwudC+lV vaGpB0u4N9GMNKz2wJyhjwkdihtEUI6ScjwWtMbolffFmzlgQ6sy7ahKH5sc6At7cNDcw8C /b43GW0Ebgh+OyzLvBuwg== X-UI-Out-Filterresults: notjunk:1; V01:K0:T4pgU5xuv2I=:6UwH8dApn5hiJ3rp+LXcxX VK6ti9OnriFfpSLFliJkyiFB8GFtxQedBkc4b4Mjm54QuSqSghCAy1YT+g7+rTl12KZgYfkeX kH2UNtyLcCfKlH/QfyyDXjibjcogpzy1095RdQ2OoJ4Ie/UzJoxn+Gu9jX74bI4tIEiVeDLyl MCs6DV2YV77BqFQdb/vPk3cU7e/EHJCCeXVxw0l87NyF0c1EHo69IPaUBARIB5P5xmWPYSiXO LUHW1AUBYb+H5JNTMQok0qeBebBa5MRnNmyDOTDJZR6F3PxGAo7gxHVxrlJsHXpolqSS4vvWQ LZ5nQvrlMK6f+FkgOPQ8b/6V1CuKM54vm7Pl1uCM52muMV4n7aA6MLIUYeiHyOZuQ4I70zb/I SSvqq73p5E27CI3yLln+PKC0nTNPLghsHFtAfAkzg7Vxjq/+eeADZyOiNBVY28MpuxSkQ1mid LTNmNNfz9/QZdkXbjCVkN3INj2dy2URf7RoWRIk03HA/h77x8f6YqVpZMQ0QbPzPFhEYfOkpe UQ8eHx7rZpdgoFsO2lCHQib6/JC4soFvl57UkYb6k2Ta6EOaoznxw1xi7cgmrK4p98LiJ2o5k MIbOY7zkyPj4mS04rAH+htWB7/69ZYVCvUYbBjCr8wenWJZb9O0kSEFEhO1PUCgo0FCzVSiLi A1aCe4S3ps1CD/VQl5f2j5QMrm0YFjbdTLCXZ6wmGhSteKLcWoM37k1CWOpxURRjnVFdawhya nu6BAEggFRqcMFplJPWQzCXRKNoopD1iLdmfZw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The to_tm() helper function operates on a signed integer for the time, so it will suffer from overflow in 2038, even on 64-bit kernels. Rather than fix that function, this replaces its use in the rtas procfs implementation with the standard rtc_time64_to_tm() helper that is very similar but is not affected by the overflow. In order to actually support long times, the parser function gets changed to 64-bit user input and output as well. Note that the tm_mon and tm_year representation is slightly different, so we have to manually add an offset here. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/rtas-proc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.9.0 diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c index fb070d8cad07..80864b787745 100644 --- a/arch/powerpc/kernel/rtas-proc.c +++ b/arch/powerpc/kernel/rtas-proc.c @@ -280,7 +280,7 @@ static int __init proc_rtas_init(void) __initcall(proc_rtas_init); -static int parse_number(const char __user *p, size_t count, unsigned long *val) +static int parse_number(const char __user *p, size_t count, u64 *val) { char buf[40]; char *end; @@ -293,7 +293,7 @@ static int parse_number(const char __user *p, size_t count, unsigned long *val) buf[count] = 0; - *val = simple_strtoul(buf, &end, 10); + *val = simple_strtoull(buf, &end, 10); if (*end && *end != '\n') return -EINVAL; @@ -307,17 +307,17 @@ static ssize_t ppc_rtas_poweron_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct rtc_time tm; - unsigned long nowtime; + time64_t nowtime; int error = parse_number(buf, count, &nowtime); if (error) return error; power_on_time = nowtime; /* save the time */ - to_tm(nowtime, &tm); + rtc_time64_to_tm(nowtime, 0, &tm); error = rtas_call(rtas_token("set-time-for-power-on"), 7, 1, NULL, - tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */); if (error) printk(KERN_WARNING "error: setting poweron time returned: %s\n", @@ -373,14 +373,14 @@ static ssize_t ppc_rtas_clock_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct rtc_time tm; - unsigned long nowtime; + time64_t nowtime; int error = parse_number(buf, count, &nowtime); if (error) return error; - to_tm(nowtime, &tm); + rtc_time64_to_tm(nowtime, 0, &tm); error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL, - tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0); if (error) printk(KERN_WARNING "error: setting the clock returned: %s\n", @@ -401,8 +401,8 @@ static int ppc_rtas_clock_show(struct seq_file *m, void *v) unsigned int year, mon, day, hour, min, sec; year = ret[0]; mon = ret[1]; day = ret[2]; hour = ret[3]; min = ret[4]; sec = ret[5]; - seq_printf(m, "%lu\n", - mktime(year, mon, day, hour, min, sec)); + seq_printf(m, "%lld\n", + mktime64(year, mon, day, hour, min, sec)); } return 0; } @@ -731,7 +731,7 @@ static void get_location_code(struct seq_file *m, struct individual_sensor *s, static ssize_t ppc_rtas_tone_freq_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - unsigned long freq; + u64 freq; int error = parse_number(buf, count, &freq); if (error) return error; @@ -756,7 +756,7 @@ static int ppc_rtas_tone_freq_show(struct seq_file *m, void *v) static ssize_t ppc_rtas_tone_volume_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - unsigned long volume; + u64 volume; int error = parse_number(buf, count, &volume); if (error) return error; From patchwork Mon Apr 23 08:10:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133979 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp713853lji; Mon, 23 Apr 2018 01:13:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Ij6+S8Oa7nj/hIQjqpwmQjJcUQW4xmocuUuC1RsmCSOUZLyySTCZ6/8Rw2t+acJ6FWiX4 X-Received: by 10.167.131.203 with SMTP id j11mr19357304pfn.101.1524471230703; Mon, 23 Apr 2018 01:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524471230; cv=none; d=google.com; s=arc-20160816; b=L3mBuoPzEckmf42iMzCoqcBfkGuGHfgxvvG5WxgPQNjepsgF+AmWpcmjD1iSbKqFuA yIBqmJ7gUdiyLXjSvxx7S8nKzIiazxLPN+t1sGdNqMZn38KXFpahmMrY0IlmtOJJhXkz NdxtfsG7yUAxrWy6tMliMCtPvjS4mUTBRvvw7GgANbrjUWtUEtwriESzi4VkJumL5cvI 4a+DI4X35dUHwtK7Xky4s2zs5tv9XJd5rcNzP+weVv4ru97pbAa5IY2gIelJIMccsygL ZjGj14txO6v8fl5oBeM+LcueYr93ePRupbYdCQav7DKvKaL9LaltyQJMdvVFGdBrrrCI ekJQ== 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:arc-authentication-results; bh=yX31vT6ix9BgzbDnLRyYv2wYYvW48bU7wKBEmWAHQ1s=; b=W/UOtxPzNBaFv8OL9Fyt0lSP1V9orP0q8GBVXtCwTC2gSwKVBPE022ivUTJXhjGiwF KgFqYAi+WepbxlvBJbu9ie+DMZMHu28jbCl9L0I/Fa/yGCSGW4fQDi1d+NbV+2uB788U lrfkM/IapOEE5Ak24A4A7J0duHPX2V4qDrXSUVQ7hY702saAscoB3Ls09ptGCUWucNNA jb7dX1PCRdSI9DE89kj1FHpf4wNDJ2BLw5UHgJixaud9iDhy66wDVcaYYlwfFK2PqJ8K JW7bhX4ULgfIC04k9yjF8i41UaKaYK8Al4v/llm3gF13BXfc7dSvUgGSBJQQS2/HECDm fBEA== 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 h1-v6si11496351pld.539.2018.04.23.01.13.50; Mon, 23 Apr 2018 01:13:50 -0700 (PDT) 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 S1754425AbeDWINs (ORCPT + 29 others); Mon, 23 Apr 2018 04:13:48 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:49979 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754148AbeDWINn (ORCPT ); Mon, 23 Apr 2018 04:13:43 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0M3aUb-1eJNoZ0TYH-00rExG; Mon, 23 Apr 2018 10:13:22 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Arnd Bergmann , Vitaly Bordug , Geoff Levand , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] powerpc: use time64_t in read_persistent_clock Date: Mon, 23 Apr 2018 10:10:27 +0200 Message-Id: <20180423081114.1813726-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423081114.1813726-1-arnd@arndb.de> References: <20180423081114.1813726-1-arnd@arndb.de> X-Provags-ID: V03:K1:LKfPNzdLcSDJmeQ8Px0rB0Kwb+pE4h25L4HpCH9NIttJfe3p9UU A3Ug3f8fjJ0589PW1pmmXEmZNxoX6Ydzqdbi82qm/OVfBd+zGZzfv5tshxkWLvPdJLTYnT6 GUxVzbCnwb/wgOoSTbI3rLIX5m7FnC1Plfm2axdPMe4IsHsucU7Ugtrn4sDhLy937K3R5hj ydH9Jnlnp69c9SMzX5vqw== X-UI-Out-Filterresults: notjunk:1; V01:K0:q2zWNjaqCO8=:NeOQyeQIdnYUWE1SegTHhS 68xt6/9aHxJFF4sJEO0R9f7OX91SwJ3+9eUCcAd6ZPuIZPU6ck1xu6WTbbsa0cxypApbgiX1Y h1nzNLRIh8Ne2bbhD+Gx/GrzePmRDM7PjjA9bBz2334XQj00SV5Ot6e646kHCxAxoYA1YpuTa SLFN8ljv/Jgr20r/mVZcF2LtJ6srZKZxsNMIwyE8+WaAZJcH3ul6vQiuIDzweHBjRSZpPOzay OQP/NtQZpEEIY7V7VFXX1QHJ87wPnCBj1h0+M9uTq15yZ1nSZUqDeAT207sWdK+ONwuu9fqMj To1mEl8EFi/zkmokXD1fS8AzO6hb2VKkppMOZz3KdONdvUfMiV7ohq/kJ6+H8QZiu/7PrBLpJ 24nH4u56YwrZ4pC5ySEAAVewi24QsAoFOoArXEy4wm+fXIo4r2hPuPgHQXLG7UcsasFMoMu0p L2hHm21jf1KPR0fQIGOh9becV2rymdNg96fCwQc29FFGWrobW6P2QQRk4pyPEyrm9Dhl/qWe8 mn8hmsFwjiu6hX5bjcQZtAjBgtff8xMWaDobjOqeY0NHySBnADKj0lxQeR4AR8T7FPv4fMrRF zgO49b4VVn/sw1wal/ktgJszLVK6Ebii1G2o3oQWZ0/Gx5j3NNfG3AKv7CyCpr7aHhVE6LLAt uxNB4nt8lRHPc+dmmYsaxmT92AQZhSoUyZFbiXjb8Es8OWqYqK+gagJ5D/ZEN2e63qVMhYnOE i8xlSbxvGocmi4i7mAVMsMNSmkpsFNpD+55YEw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looking through the remaining users of the deprecated mktime() function, I found the powerpc rtc handlers, which use it in place of rtc_tm_to_time64(). To clean this up, I'm changing over the read_persistent_clock() function to the read_persistent_clock64() variant, and change all the platform specific handlers along with it. Signed-off-by: Arnd Bergmann --- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/include/asm/opal.h | 2 +- arch/powerpc/include/asm/rtas.h | 2 +- arch/powerpc/kernel/rtas-rtc.c | 4 ++-- arch/powerpc/kernel/time.c | 7 +++---- arch/powerpc/platforms/8xx/m8xx_setup.c | 4 +--- arch/powerpc/platforms/maple/maple.h | 2 +- arch/powerpc/platforms/maple/time.c | 5 ++--- arch/powerpc/platforms/pasemi/pasemi.h | 2 +- arch/powerpc/platforms/pasemi/time.c | 4 ++-- arch/powerpc/platforms/powermac/pmac.h | 2 +- arch/powerpc/platforms/powermac/time.c | 31 +++++++++++-------------------- arch/powerpc/platforms/powernv/opal-rtc.c | 5 ++--- arch/powerpc/platforms/ps3/platform.h | 2 +- arch/powerpc/platforms/ps3/time.c | 2 +- 15 files changed, 31 insertions(+), 45 deletions(-) -- 2.9.0 diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index ffe7c71e1132..a47de82fb8e2 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -83,7 +83,7 @@ struct machdep_calls { int (*set_rtc_time)(struct rtc_time *); void (*get_rtc_time)(struct rtc_time *); - unsigned long (*get_boot_time)(void); + time64_t (*get_boot_time)(void); unsigned char (*rtc_read_val)(int addr); void (*rtc_write_val)(int addr, unsigned char val); diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 03e1a920491e..fc211bd98e0f 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -325,7 +325,7 @@ extern int opal_async_wait_response_interruptible(uint64_t token, extern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data); struct rtc_time; -extern unsigned long opal_get_boot_time(void); +extern time64_t opal_get_boot_time(void); extern void opal_nvram_init(void); extern void opal_flash_update_init(void); extern void opal_flash_update_print_message(void); diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index ec9dd79398ee..71e393c46a49 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -361,7 +361,7 @@ extern int rtas_offline_cpus_mask(cpumask_var_t cpus); extern int rtas_ibm_suspend_me(u64 handle); struct rtc_time; -extern unsigned long rtas_get_boot_time(void); +extern time64_t rtas_get_boot_time(void); extern void rtas_get_rtc_time(struct rtc_time *rtc_time); extern int rtas_set_rtc_time(struct rtc_time *rtc_time); diff --git a/arch/powerpc/kernel/rtas-rtc.c b/arch/powerpc/kernel/rtas-rtc.c index 49600985c7ef..a28239b8b0c0 100644 --- a/arch/powerpc/kernel/rtas-rtc.c +++ b/arch/powerpc/kernel/rtas-rtc.c @@ -13,7 +13,7 @@ #define MAX_RTC_WAIT 5000 /* 5 sec */ #define RTAS_CLOCK_BUSY (-2) -unsigned long __init rtas_get_boot_time(void) +time64_t __init rtas_get_boot_time(void) { int ret[8]; int error; @@ -38,7 +38,7 @@ unsigned long __init rtas_get_boot_time(void) return 0; } - return mktime(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]); + return mktime64(ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]); } /* NOTE: get_rtc_time will get an error if executed in interrupt context diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 360e71d455cc..afb27962b396 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -795,7 +795,7 @@ int update_persistent_clock(struct timespec now) return ppc_md.set_rtc_time(&tm); } -static void __read_persistent_clock(struct timespec *ts) +static void __read_persistent_clock(struct timespec64 *ts) { struct rtc_time tm; static int first = 1; @@ -819,11 +819,10 @@ static void __read_persistent_clock(struct timespec *ts) } ppc_md.get_rtc_time(&tm); - ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + ts->tv_sec = rtc_tm_to_time64(&tm); } -void read_persistent_clock(struct timespec *ts) +void read_persistent_clock64(struct timespec64 *ts) { __read_persistent_clock(ts); diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index 2188d691a40f..d76daa90647b 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -192,9 +192,7 @@ void mpc8xx_get_rtc_time(struct rtc_time *tm) /* Get time from the RTC. */ data = in_be32(&sys_tmr->sit_rtc); - to_tm(data, tm); - tm->tm_year -= 1900; - tm->tm_mon -= 1; + rtc_time64_to_tm(data, tm); immr_unmap(sys_tmr); return; } diff --git a/arch/powerpc/platforms/maple/maple.h b/arch/powerpc/platforms/maple/maple.h index d10f4af3a42e..4f358b55c341 100644 --- a/arch/powerpc/platforms/maple/maple.h +++ b/arch/powerpc/platforms/maple/maple.h @@ -6,7 +6,7 @@ */ extern int maple_set_rtc_time(struct rtc_time *tm); extern void maple_get_rtc_time(struct rtc_time *tm); -extern unsigned long maple_get_boot_time(void); +extern time64_t maple_get_boot_time(void); extern void maple_calibrate_decr(void); extern void maple_pci_init(void); extern void maple_pci_irq_fixup(struct pci_dev *dev); diff --git a/arch/powerpc/platforms/maple/time.c b/arch/powerpc/platforms/maple/time.c index cfddc87f81bf..d294617600b0 100644 --- a/arch/powerpc/platforms/maple/time.c +++ b/arch/powerpc/platforms/maple/time.c @@ -137,7 +137,7 @@ static struct resource rtc_iores = { .flags = IORESOURCE_IO | IORESOURCE_BUSY, }; -unsigned long __init maple_get_boot_time(void) +time64_t __init maple_get_boot_time(void) { struct rtc_time tm; struct device_node *rtcs; @@ -170,7 +170,6 @@ unsigned long __init maple_get_boot_time(void) request_resource(&ioport_resource, &rtc_iores); maple_get_rtc_time(&tm); - return mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + return rtc_tm_to_time66(&tm); } diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h index 329d2a619254..70b56048ed1b 100644 --- a/arch/powerpc/platforms/pasemi/pasemi.h +++ b/arch/powerpc/platforms/pasemi/pasemi.h @@ -2,7 +2,7 @@ #ifndef _PASEMI_PASEMI_H #define _PASEMI_PASEMI_H -extern unsigned long pas_get_boot_time(void); +extern time64_t pas_get_boot_time(void); extern void pas_pci_init(void); extern void pas_pci_irq_fixup(struct pci_dev *dev); extern void pas_pci_dma_dev_setup(struct pci_dev *dev); diff --git a/arch/powerpc/platforms/pasemi/time.c b/arch/powerpc/platforms/pasemi/time.c index fa54351ac268..ea815254ee7b 100644 --- a/arch/powerpc/platforms/pasemi/time.c +++ b/arch/powerpc/platforms/pasemi/time.c @@ -21,8 +21,8 @@ #include -unsigned long __init pas_get_boot_time(void) +time64_t __init pas_get_boot_time(void) { /* Let's just return a fake date right now */ - return mktime(2006, 1, 1, 12, 0, 0); + return mktime64(2006, 1, 1, 12, 0, 0); } diff --git a/arch/powerpc/platforms/powermac/pmac.h b/arch/powerpc/platforms/powermac/pmac.h index 6f15b8804e9b..16a52afdb76e 100644 --- a/arch/powerpc/platforms/powermac/pmac.h +++ b/arch/powerpc/platforms/powermac/pmac.h @@ -15,7 +15,7 @@ struct rtc_time; extern int pmac_newworld; extern long pmac_time_init(void); -extern unsigned long pmac_get_boot_time(void); +extern time64_t pmac_get_boot_time(void); extern void pmac_get_rtc_time(struct rtc_time *); extern int pmac_set_rtc_time(struct rtc_time *); extern void pmac_read_rtc_time(void); diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index 274af6fa388e..d5d1c452038e 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c @@ -84,15 +84,6 @@ long __init pmac_time_init(void) return delta; } -#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) -static void to_rtc_time(unsigned long now, struct rtc_time *tm) -{ - to_tm(now, tm); - tm->tm_year -= 1900; - tm->tm_mon -= 1; -} -#endif - #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) || \ defined(CONFIG_PMAC_SMU) static unsigned long from_rtc_time(struct rtc_time *tm) @@ -103,10 +94,10 @@ static unsigned long from_rtc_time(struct rtc_time *tm) #endif #ifdef CONFIG_ADB_CUDA -static unsigned long cuda_get_time(void) +static time64_t cuda_get_time(void) { struct adb_request req; - unsigned int now; + time64_t now; if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0) return 0; @@ -117,10 +108,10 @@ static unsigned long cuda_get_time(void) req.reply_len); now = (req.reply[3] << 24) + (req.reply[4] << 16) + (req.reply[5] << 8) + req.reply[6]; - return ((unsigned long)now) - RTC_OFFSET; + return now - RTC_OFFSET; } -#define cuda_get_rtc_time(tm) to_rtc_time(cuda_get_time(), (tm)) +#define cuda_get_rtc_time(tm) rtc_time64_to_tm(cuda_get_time(), (tm)) static int cuda_set_rtc_time(struct rtc_time *tm) { @@ -147,10 +138,10 @@ static int cuda_set_rtc_time(struct rtc_time *tm) #endif #ifdef CONFIG_ADB_PMU -static unsigned long pmu_get_time(void) +static time64_t pmu_get_time(void) { struct adb_request req; - unsigned int now; + time64_t now; if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) return 0; @@ -160,10 +151,10 @@ static unsigned long pmu_get_time(void) req.reply_len); now = (req.reply[0] << 24) + (req.reply[1] << 16) + (req.reply[2] << 8) + req.reply[3]; - return ((unsigned long)now) - RTC_OFFSET; + return now - RTC_OFFSET; } -#define pmu_get_rtc_time(tm) to_rtc_time(pmu_get_time(), (tm)) +#define pmu_get_rtc_time(tm) rtc_time64_to_tm(pmu_get_time(), (tm)) static int pmu_set_rtc_time(struct rtc_time *tm) { @@ -188,13 +179,13 @@ static int pmu_set_rtc_time(struct rtc_time *tm) #endif #ifdef CONFIG_PMAC_SMU -static unsigned long smu_get_time(void) +static time64_t smu_get_time(void) { struct rtc_time tm; if (smu_get_rtc_time(&tm, 1)) return 0; - return from_rtc_time(&tm); + return rtc_tm_to_time64(&tm); } #else @@ -204,7 +195,7 @@ static unsigned long smu_get_time(void) #endif /* Can't be __init, it's called when suspending and resuming */ -unsigned long pmac_get_boot_time(void) +time64_t pmac_get_boot_time(void) { /* Get the time from the RTC, used only at boot time */ switch (sys_ctrler) { diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c b/arch/powerpc/platforms/powernv/opal-rtc.c index f8868864f373..f515c4a76900 100644 --- a/arch/powerpc/platforms/powernv/opal-rtc.c +++ b/arch/powerpc/platforms/powernv/opal-rtc.c @@ -34,7 +34,7 @@ static void opal_to_tm(u32 y_m_d, u64 h_m_s_ms, struct rtc_time *tm) tm->tm_wday = -1; } -unsigned long __init opal_get_boot_time(void) +time64_t __init opal_get_boot_time(void) { struct rtc_time tm; u32 y_m_d; @@ -59,8 +59,7 @@ unsigned long __init opal_get_boot_time(void) y_m_d = be32_to_cpu(__y_m_d); h_m_s_ms = be64_to_cpu(__h_m_s_ms); opal_to_tm(y_m_d, h_m_s_ms, &tm); - return mktime(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + return rtc_tm_to_time64(&tm); } static __init int opal_time_init(void) diff --git a/arch/powerpc/platforms/ps3/platform.h b/arch/powerpc/platforms/ps3/platform.h index 1809cfc562ee..9bc68f913466 100644 --- a/arch/powerpc/platforms/ps3/platform.h +++ b/arch/powerpc/platforms/ps3/platform.h @@ -57,7 +57,7 @@ static inline void ps3_smp_cleanup_cpu(int cpu) { } /* time */ void __init ps3_calibrate_decr(void); -unsigned long __init ps3_get_boot_time(void); +time64_t __init ps3_get_boot_time(void); void ps3_get_rtc_time(struct rtc_time *time); int ps3_set_rtc_time(struct rtc_time *time); diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c index 11b45b58c81b..9dac125c997e 100644 --- a/arch/powerpc/platforms/ps3/time.c +++ b/arch/powerpc/platforms/ps3/time.c @@ -76,7 +76,7 @@ static u64 read_rtc(void) return rtc_val; } -unsigned long __init ps3_get_boot_time(void) +time64_t __init ps3_get_boot_time(void) { return read_rtc() + ps3_os_area_get_rtc_diff(); } From patchwork Mon Apr 23 08:10:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133980 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp713948lji; Mon, 23 Apr 2018 01:14:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ayviGa6RlJKPdDmoaqizydhwWwJMwSOzLDZRfzGlYO4G0aU5o+1jfoxiF9UXMgkJro3qd X-Received: by 10.99.107.8 with SMTP id g8mr16254055pgc.271.1524471241276; Mon, 23 Apr 2018 01:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524471241; cv=none; d=google.com; s=arc-20160816; b=EbJr3ME6ZEWpnqZWRmGD3n8slBb6px1+ujYDgsCEl6g74sMs39E6q7G2EtL5ELztzd xUH7j6makofu8cx2LxUFnDafaS46SKa9Qq13JObYj92eHV2VjG0paCtNVd4S/CtcL4Om 0Liyola15jn8f9nP+5Y/tLJkk95B87SYUNBicHASBVyR5sF2BzCJ8lf9VIYtyZ03qCsz FZQIB/O1z+9s6BSt9cNewWenJ8VGDubon+PrI2fc9l8tUS8oSUDoiZCZlWYpgaLVkFuv ie3p0VuntQ33ayb+sw0U3SPUIQmPbNH3Aw6tVdUU9vnu17N9pBLPAk7eM8Wr4bTtivgz GTxQ== 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:arc-authentication-results; bh=UURywTtXmZy+qMrvU+YkbFOthh10Pg6G3Wt9sA0LY4E=; b=rNdkp33GA4yvTSb7x3wClot2Hm47H7XQ7rslhp3mxo5S+Jbm/n73vSsUk87pk0oLyo nNgicO13FbUzRJwsuqvPtIaZexEwPo6TzQuAwinFneB9p8wtcifacwf/9xpex+SkotPN QK24+RKF9XJ0728MtyAfZC2QeSlQfZDyyIUX0elcqS0Cd/IFHw8ECwfl/DBciJP3+bof ilcSViUK5Pij5Jnv22IQb5fvbLfboJeU5WAOlMDVMA4sBiDj13YhxuKmLKy16FiXBV1Q MupDzybY4QjLFHcr0ehtvXD1LM1UaKcc2NlMcqVRNRgHUEvP8VLrkvSJaXwRbrzxxI+Y XT+Q== 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 33-v6si11319570pls.491.2018.04.23.01.14.00; Mon, 23 Apr 2018 01:14:01 -0700 (PDT) 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 S1754462AbeDWIN5 (ORCPT + 29 others); Mon, 23 Apr 2018 04:13:57 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:54613 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754428AbeDWINw (ORCPT ); Mon, 23 Apr 2018 04:13:52 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0M3rTW-1eKDAP3fDG-00rW4P; Mon, 23 Apr 2018 10:13:47 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] powerpc: use time64_t in update_persistent_clock Date: Mon, 23 Apr 2018 10:10:28 +0200 Message-Id: <20180423081114.1813726-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423081114.1813726-1-arnd@arndb.de> References: <20180423081114.1813726-1-arnd@arndb.de> X-Provags-ID: V03:K1:EGf12ycxRMVIqNBcezlC3xN2DidntPS5TuCmihuxw3fq3+Fls8Y VgoO2E6OBuzWJAkRggIVp2ygX/g6xWm7FsIFJ2zlyirYXWxQOX11SF4pvu2U/CwqXIIVBGR 7AFLe0mi7lBSV35MyG9sXwA3VHgk9DFIkSsVryFKAi3ntXMUiDuE3VEVQUnHN+PG7GrqvFV 1Fgox+h1rTzYrhP36muRw== X-UI-Out-Filterresults: notjunk:1; V01:K0:3q6KcNwNnCo=:0IKNj796LzMnvhLLCPKsX4 ays3qOmW7dBWccHrrXYcoYAxOS7WQnN5FYdcX8/xuKJ3EiVxbFml2EppEO+2U5Wc12lT7OgMB BsoMRamRwgNBc6M/W2vh6Xie1JxcU2VI0D2fuA45yN9uISrASChMY+w2ubs3tap7c7Otvhbc8 G5dDxpLoWTzRgUNgT4YGWn5Tm5ySEisQpC16PPbx7RGjqQ88PwuJ918bq5k1RqiT1cWTN7sFR SLU7fBj7K9P2ofG+AQOFjV3LG8JIxGK9WnUhMRJ9mMvpb5I985E+fMcdVOMFboDoHN2eNmU4S nTxbIMqXCseniniwiWJL7ywnP+rUB3TY/bqMdMMeZe3Ih4I2DjUeFF44pTiqpU6/hVWbrXg+U 3o4C5e/K3j/cn3Ci6AZXQ2S65+SMTX6HeMTuIJzxwsr6woc4rODcuFfMax0KQwVp/SXPNCdSi c8JwWZikvoLvwfYNrxQ7SilWVs+40+aYsotrCyMz4dmB/TGHLwKylys34pbeECxl4myMhCmJH hfQs0CdcA0TXKtCdlUxabxS90amgwO2vRqI0hNU2eYBDdhykZTn2jytlxJVVQLPHaWm5uS+Pd X9fwtQZJsfxHcB9FGrFeTVhzK0Cg+7PW350GZ8NLNuuqsV5jZOrg8da0up4BpAaqQf2J18Pqy raoUlf53iq9GPKDFXInIvrpvH/z2VY0ZnoE7B3AZqRY9vcsHrW/ycKdusZYyX98XiRSjqCp05 J6sKXpD07CSNh24xKWiOuIZCXf/6BmkTlpQZ7A== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org update_persistent_clock() is deprecated because it suffers from overflow in 2038 on 32-bit architectures. This changes powerpc to use the update_persistent_clock64() replacement, and to pass down 64-bit timestamps consistently. This is now simpler, as we no longer have to worry about the offset numbers in tm_year and tm_mon that are different between the Linux conventions and RTAS. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/time.c | 6 ++---- arch/powerpc/platforms/8xx/m8xx_setup.c | 7 +++---- arch/powerpc/platforms/powermac/time.c | 17 ++++------------- 3 files changed, 9 insertions(+), 21 deletions(-) -- 2.9.0 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index afb27962b396..f9b0baa3fa2b 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -781,16 +781,14 @@ void __init generic_calibrate_decr(void) } } -int update_persistent_clock(struct timespec now) +int update_persistent_clock64(struct timespec64 now) { struct rtc_time tm; if (!ppc_md.set_rtc_time) return -ENODEV; - to_tm(now.tv_sec + 1 + timezone_offset, &tm); - tm.tm_year -= 1900; - tm.tm_mon -= 1; + rtc_time64_to_tm(now.tv_sec + 1 + timezone_offset, &tm); return ppc_md.set_rtc_time(&tm); } diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c index d76daa90647b..027c42d8966c 100644 --- a/arch/powerpc/platforms/8xx/m8xx_setup.c +++ b/arch/powerpc/platforms/8xx/m8xx_setup.c @@ -169,15 +169,14 @@ int mpc8xx_set_rtc_time(struct rtc_time *tm) { sitk8xx_t __iomem *sys_tmr1; sit8xx_t __iomem *sys_tmr2; - int time; + time64_t time; sys_tmr1 = immr_map(im_sitk); sys_tmr2 = immr_map(im_sit); - time = mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + time = rtc_tm_to_time64(tm); out_be32(&sys_tmr1->sitk_rtck, KAPWR_KEY); - out_be32(&sys_tmr2->sit_rtc, time); + out_be32(&sys_tmr2->sit_rtc, (u32)time); out_be32(&sys_tmr1->sitk_rtck, ~KAPWR_KEY); immr_unmap(sys_tmr2); diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index d5d1c452038e..7c968e46736f 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c @@ -84,15 +84,6 @@ long __init pmac_time_init(void) return delta; } -#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) || \ - defined(CONFIG_PMAC_SMU) -static unsigned long from_rtc_time(struct rtc_time *tm) -{ - return mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); -} -#endif - #ifdef CONFIG_ADB_CUDA static time64_t cuda_get_time(void) { @@ -115,10 +106,10 @@ static time64_t cuda_get_time(void) static int cuda_set_rtc_time(struct rtc_time *tm) { - unsigned int nowtime; + time64_t nowtime; struct adb_request req; - nowtime = from_rtc_time(tm) + RTC_OFFSET; + nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0) @@ -158,10 +149,10 @@ static time64_t pmu_get_time(void) static int pmu_set_rtc_time(struct rtc_time *tm) { - unsigned int nowtime; + time64_t nowtime; struct adb_request req; - nowtime = from_rtc_time(tm) + RTC_OFFSET; + nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0) return -ENXIO; From patchwork Mon Apr 23 08:10:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133981 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp714633lji; Mon, 23 Apr 2018 01:14:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx48860w3IEik+H6XwjqX6tQMXfm45bAL3pM8srCpyPABUOik06S8ukxjbkJd7/OVu8keSs8z X-Received: by 10.98.246.25 with SMTP id x25mr19085397pfh.138.1524471294640; Mon, 23 Apr 2018 01:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524471294; cv=none; d=google.com; s=arc-20160816; b=QhQDVawzkgZR3A/LMX3gOfJWVymsS+R+5/4Ci/kWh3MblH4UrhjzzFRzpX6Pg8A6s4 4gOAkvJW7emUvaGoe53kLsEiuRhLciG6ZcxrrtbgENFhE796+vGt6ejeJUT8D06i4spa KpGNbG8zpoPDRICNETp4c8KllXJMHFU5XBMmcs6ueUf73jCZa0U8zvua/E7nhP0j9WzI lR4wriXDRUf4pNKMCoridz1s+iHq4yesH6ND57Sq0JpoISyGFtalnlwLb4DESyDvDjkn Br10rg4dTnUmsbsGFcaNCHUwRokbQD+9BJZlp9meIcguf8/FcgKjMKX+VWAFwNeoFZGE C9yw== 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:arc-authentication-results; bh=/vWXfyVpASXUjXV7NiNcgLyZ19NZD+c3sJYBVHFei88=; b=d6bNmDi9JYZ9CNdPXIFmedgisOBZHP0f+t3scr2gU6uPN23w3+UacDamuV3wydHUeo v3z4N9EG5vQ1FukaCnoI3ZCp0GdpDwb/KrVvuOlPl25SbN+PvIRbTLp/1n1byy8RPvYw 0fGpPuVFwdMycZq8u3Ym1dRNEEHSusoM2N6e4e/VI7lS8OG6uj/96mGWBd9uT8HFlvUb FaWSp2uiP6Iii99K6qAsFsgZu/43Q9I0qZnAcQV2bzD4IQ7qbdAaFgZADDCwL5gp66o0 lg9xkStCUJOFUSrigfO4LlvzV0GHUssV27yg0jcssz5sOgHstM6uh/BAvKsfAF334hHz 4nAA== 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 37-v6si11130148plq.288.2018.04.23.01.14.54; Mon, 23 Apr 2018 01:14:54 -0700 (PDT) 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 S1754510AbeDWIOw (ORCPT + 29 others); Mon, 23 Apr 2018 04:14:52 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:59391 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754131AbeDWIOq (ORCPT ); Mon, 23 Apr 2018 04:14:46 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lcsfw-1ek1U83D6G-00iGdv; Mon, 23 Apr 2018 10:14:24 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Arnd Bergmann , Geoff Levand , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] powerpc: remove unused to_tm() helper Date: Mon, 23 Apr 2018 10:10:29 +0200 Message-Id: <20180423081114.1813726-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423081114.1813726-1-arnd@arndb.de> References: <20180423081114.1813726-1-arnd@arndb.de> X-Provags-ID: V03:K1:ZTkperZmeZEQDDES1bMgdyE3YY2YxPIZl+DADVz4C+S3HI+7NOO HHVz6xV0yiB+d7AQcvoapf6GFelzkCdLJgaJkjnMhjlJOLpAXQAlas1KtIBxUXu84JE0Nqr mNDj+bjg7cROGqHiNT8aGbNlNWU9MwtoWh7vGiIjF9EvrtSDg2lMb9DNMGXhL5yL0qfK7wu 7EuBYh4vmKfTInlcNmR8Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:1mrS97M2bk8=:EX7plqzzHNDcAUbQCebLUN F7ZHr+WqKhxVtmX2mUv6KdnIwQAejN/AI9/VRr9LZMZYdQ/KBu/3k7+CsiqMYaoHTMEdfc430 Jfkb89j+4CeK2b+rcxRUYSnzQAMgUvB67kYAvEnb4OLanf2t+coW/EULwobKV/PDvPhFYAxl9 cPEAtEpnJQ51j+a9ApGa9hCkk102W9JCJCHIcP9eXPqCUTRXjrd/moLGHNnFuuwhakE3zJRhc T1kvG2Bim7AqbZDEN6fDpK9RoUb35TInwnJiP5SueVDAvqeFgH972W3VknXfqw96u1xvUNTi1 tt8rct+5+SH2ZI9SWM6oFh/HcxxB4yx3KjScNkeQrUfosp1Fcfruj4Uu4MshzN+p9Y7QdTTst VzZ8N6k7ouQ2c8KaUe4QxnZ+TLVvdBO+nBAjA+TWo8D0t2d9E5OVqaKsggVACC214QKD4Jwn8 Te4MRmox6HJlllAf8Zt92bGSXWstqHAkCWQu3r3nr1hFm4qpnLwD5izl2Y8GvXshnYrsoTviP 9OrVI7govrkdLLdrQAiC6EYzT6nh38O9VCRbibLig0GX3oQIQTyKW1UeZVB3MUpDO3dNk1nNI /oUyLLICsTdfQ/YmvzL64MSpHgzhT7juTQZb/pplK9GZ3qH8MTRFFNRFABWCTKrJZl1/UvMvT Cv75W2m2l+5QZegDBjpfNHlqgmlc0xUd5+z1d4EDX0bI4mtfRo7xnZlyaU48ipor6Km7p/MtF 8Il5HNw1N2TT4JjWfPgF4YBuvZidH4QNWPNeMA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org to_tm() is now completely unused, the only reference being in the _dump_time() helper that is also unused. This removes both, leaving the rest of the powerpc RTC code y2038 safe to as far as the hardware supports. Signed-off-by: Arnd Bergmann --- arch/powerpc/include/asm/time.h | 2 -- arch/powerpc/kernel/time.c | 50 --------------------------------------- arch/powerpc/platforms/ps3/time.c | 24 ------------------- 3 files changed, 76 deletions(-) -- 2.9.0 diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index db546c034905..79bc9c3e4325 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -26,8 +26,6 @@ extern unsigned long tb_ticks_per_usec; extern unsigned long tb_ticks_per_sec; extern struct clock_event_device decrementer_clockevent; -struct rtc_time; -extern void to_tm(int tim, struct rtc_time * tm); extern void tick_broadcast_ipi_handler(void); extern void generic_calibrate_decr(void); diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index f9b0baa3fa2b..79bdeea85ab4 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -1138,56 +1138,6 @@ void __init time_init(void) #endif } - -#define FEBRUARY 2 -#define STARTOFTIME 1970 -#define SECDAY 86400L -#define SECYR (SECDAY * 365) -#define leapyear(year) ((year) % 4 == 0 && \ - ((year) % 100 != 0 || (year) % 400 == 0)) -#define days_in_year(a) (leapyear(a) ? 366 : 365) -#define days_in_month(a) (month_days[(a) - 1]) - -static int month_days[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -void to_tm(int tim, struct rtc_time * tm) -{ - register int i; - register long hms, day; - - day = tim / SECDAY; - hms = tim % SECDAY; - - /* Hours, minutes, seconds are easy */ - tm->tm_hour = hms / 3600; - tm->tm_min = (hms % 3600) / 60; - tm->tm_sec = (hms % 3600) % 60; - - /* Number of years in days */ - for (i = STARTOFTIME; day >= days_in_year(i); i++) - day -= days_in_year(i); - tm->tm_year = i; - - /* Number of months in days left */ - if (leapyear(tm->tm_year)) - days_in_month(FEBRUARY) = 29; - for (i = 1; day >= days_in_month(i); i++) - day -= days_in_month(i); - days_in_month(FEBRUARY) = 28; - tm->tm_mon = i; - - /* Days are what is left over (+1) from all that. */ - tm->tm_mday = day + 1; - - /* - * No-one uses the day of the week. - */ - tm->tm_wday = -1; -} -EXPORT_SYMBOL(to_tm); - /* * Divide a 128-bit dividend by a 32-bit divisor, leaving a 128 bit * result. diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c index 9dac125c997e..08ca76e23d09 100644 --- a/arch/powerpc/platforms/ps3/time.c +++ b/arch/powerpc/platforms/ps3/time.c @@ -28,30 +28,6 @@ #include "platform.h" -#define dump_tm(_a) _dump_tm(_a, __func__, __LINE__) -static void _dump_tm(const struct rtc_time *tm, const char* func, int line) -{ - pr_debug("%s:%d tm_sec %d\n", func, line, tm->tm_sec); - pr_debug("%s:%d tm_min %d\n", func, line, tm->tm_min); - pr_debug("%s:%d tm_hour %d\n", func, line, tm->tm_hour); - pr_debug("%s:%d tm_mday %d\n", func, line, tm->tm_mday); - pr_debug("%s:%d tm_mon %d\n", func, line, tm->tm_mon); - pr_debug("%s:%d tm_year %d\n", func, line, tm->tm_year); - pr_debug("%s:%d tm_wday %d\n", func, line, tm->tm_wday); -} - -#define dump_time(_a) _dump_time(_a, __func__, __LINE__) -static void __maybe_unused _dump_time(int time, const char *func, - int line) -{ - struct rtc_time tm; - - to_tm(time, &tm); - - pr_debug("%s:%d time %d\n", func, line, time); - _dump_tm(&tm, func, line); -} - void __init ps3_calibrate_decr(void) { int result;