From patchwork Mon Apr 23 08:36:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133986 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp731777lji; Mon, 23 Apr 2018 01:38:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx49IThdH73AfmhBST+l/xE9K4Bt3FWjGenWVnnXx84MEa3FBk0i5oiNXTuv58KnxZi+mqkWj X-Received: by 2002:a17:902:a5c2:: with SMTP id t2-v6mr20111206plq.360.1524472707443; Mon, 23 Apr 2018 01:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524472707; cv=none; d=google.com; s=arc-20160816; b=lgR/bIrd17n2EjN/rvAUR4/bZdah3iwv1PTameK5TYn3L6ESxIUcL8ty6v4r7JrKPt W4jqV2rRYDrRam662XZBjBxkJ2hq01/ay+TVNEtZzOhZWgTqRNRsPxLHlRWdpsAdxJ13 NVmdWye7Uyp/FxMMYcVcV8zxyYDvYJdakYv9w71iHJvGAE24IsUr7EUNWvJZPSprloEX xlG5XBunIos4Zp0R9q2mAlmtbHWMNolnV1NkXeoAMbdB8twQ9ITxXDXgcZlGQwEJPzzj K7U4uBm0D46LWpLroagLpxJqvFs7XRROljh6uNl90qM2MorSv0MCMVmodlRCwSIbVCOh uMVA== 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=0PT03Qil/xC2nhDVD7Uf7fGtyL4Ezv2ItjCRVpsgqLXEVHxrwZRIKiXLvULZhZi7Z/ xFZYs/I0gDXA4wIXC7L4gnvSwpyw7XnS/R2KwRoHimP0HumCeHxK5+DR9WH+6UliuJk+ Mo3k/Rpn29qvZCKnx0uGJgayCA2NsJ0CfeIH3qqizVFg0hguopTIgC69G4PkJ1GHyzQF yravNP/XHO3UOPhKC14BDCWYCALXoYYg41ITUAWjehVYOi98jbuGcG3/ayqPwla0VkGA 2umYJBNWB05mrJZ7fS+0GjGDW9poVZu9XdXJV5cddp/2Py509OfKjXn+5v8BU5zd+A2x xV5Q== 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 n71si10919505pfk.277.2018.04.23.01.38.27; Mon, 23 Apr 2018 01:38:27 -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 S1754699AbeDWIiY (ORCPT + 29 others); Mon, 23 Apr 2018 04:38:24 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:40907 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754594AbeDWIhM (ORCPT ); Mon, 23 Apr 2018 04:37:12 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0M8opw-1fG3nh0Eay-00C6Rk; Mon, 23 Apr 2018 10:36:57 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH 1/5] powerpc: always enable RTC_LIB Date: Mon, 23 Apr 2018 10:36:38 +0200 Message-Id: <20180423083642.2608886-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:zWvL38seKXvP56XrNeY+SIJ3zKyG1Pbqt5VEep1gY3DXFLKqyeK EXHINLugZb6isRtvYVOUvAEFpX6yyRLaMVZrVx1tgY+zbTynqhtsJVlDqOHdvNR/wdLC9vC p7lVZTBtCgf3Glnbp28T6XYzskc7pelhzP5hJ8ZRvFSNWZCnf5Jv8XEXiF31UO0PRvmTcIc J4yIARrcNuU4sXDW+IEDw== X-UI-Out-Filterresults: notjunk:1; V01:K0:NUv5yRseWb4=:UJDT8Mw5NiSYLjWnRIgAPM 6bfCBb7SSzDj1dDqyL8H9Sb+713n650iQrdWl8wkXG0merynvDrQquy1HVQmU/U/UJfHjhBQF c+c8L45MJxdE9PgU/X8IN9jpAMw//WHuNvoYrnmxDaqcAa+dNH8/elMcxiKnwjjMI943jsDDT DjPD/8RMPMyC112G4itCVt8Z4/B4hT78is9TYENlhUgQYbrbqCefQ+WDounNotdtAICsDALKM 7gA6GY84pDHku38D0Sus82b7mXntv7VJ0UZWMozYtS+/e2cRuBOsjD2f4bYr93BfgrnLlf5mq keLZt24sOOQ/ap4gbbjvLZudwmc/8NV0wVNrNOnmbn/jCXmbmA7KiH6IKK+9IH8GGGGLdmHUI aePaK2kHNvtxy/HAatHzdOcNSKn4OSpDG+/Q71/P1npA4yyVmMHM513/yO88yagWRtMelhlsb 2bxRW1nL8gwI9iLXrCVA+TGUhRuMOePg6U4LwfH9I1UmwTEr0+ss94KTCRrgjqw0ld0HDhZSG Ji/dMo4OmSPnDbSYtGNCHGBUfK9y7wvU1vak0b5iPrZtFa6wwus6NQJJplk+wFCTeZAV0PV36 IODVHSpI8bbyILxtASEOD3ul37D8UXdxlw0DvDBSfd1OrmSeP1IWGyQLF2s6ioreGwXXqdVRv AvJkBnGJWkUqNLcvih6H+YwfCDz5mwZB8NnaQU9gXsW9zupXsQxdKSdDpNdlSQwcdTMdDElGV 5rkSt2htKeGbCa1HgAfOqi7pH3Fue+kSes7TvQ== 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:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133987 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp732133lji; Mon, 23 Apr 2018 01:38:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48uAE5UZpMk6z9llr1vNLse9o2tRbs4yyU1ipvAX03YL2t91LLSB0bXTJbrdTwgztit7J17 X-Received: by 10.99.109.7 with SMTP id i7mr16062884pgc.174.1524472736515; Mon, 23 Apr 2018 01:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524472736; cv=none; d=google.com; s=arc-20160816; b=USOblcy78q/KsppYASX6TVltE8us+5PLOgWTGnYGsTd7MMSBw1O+JdqLk9meyHrBb8 M/ygvj4mYOl1iP7sMqq9pqI9lD+E3MdOn30OBKIEpoM0Bc1ULogTxIJ1B96KjMNhPUIZ zD4/AqQYAQW4sGUtnBRBY1EJ+dlgCHoN61iRrz0RXqOgVbqS1rKjqqUCO3VMTtZI9alW 7/LWCz+Idvw3Vtpp/w4s6BXgvLuAJH+nCoZVoV6edGbz0dR0OzUIQXaoEpCnzCitUkLk 18bllQlD1jyjYEPyu8fxM/96yD+l6rw9ktYQPSYsqErAmDrG9ka6/ZDFLuxad/OOQX5q 1WQA== 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=e7UiHBvNhG8+BtaWDc6cUh/T07yY2RElLE2qqHNNl5Q=; b=kRk7S8yMGwOW33BvUXktFta1HDkv/ROssdIJZCIVLNqb9hF/Wnl4BCqVyUeDmA87jc PWIapeldnHK4wuJECFCUpyeE80f6U8LuLg/ybt5b74alWM+ZmZZMzyJ/6KJv7qwQainE CjMGcN76gdCxZGiv+1NPz7CQU6darb/LL4j4nCObV+hbphNOJKaas+Ovl7re6lKQ736s C8l7P7SUV7gQdfSmWkzSatjUkHO0QzRuKN5TbujzrVccJq/6Da5o89/JZKlcoIxrR9/g 876spzZZL308l2ZwGwQ3oXPcVzZHd2EiGA+nP9eK9PYl0AwSk5BSXApHk7GHWEoMDeAk bpUA== 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 n71si10919505pfk.277.2018.04.23.01.38.56; Mon, 23 Apr 2018 01:38:56 -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 S1754704AbeDWIiy (ORCPT + 29 others); Mon, 23 Apr 2018 04:38:54 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:39929 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754573AbeDWIhH (ORCPT ); Mon, 23 Apr 2018 04:37:07 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0LnUdS-1eU1Tz1lSY-00hdti; Mon, 23 Apr 2018 10:36:57 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH 2/5] powerpc: rtas: clean up time handling Date: Mon, 23 Apr 2018 10:36:39 +0200 Message-Id: <20180423083642.2608886-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423083642.2608886-1-arnd@arndb.de> References: <20180423083642.2608886-1-arnd@arndb.de> X-Provags-ID: V03:K1:xg6gifUpz3iHQyaagOz/+XeacsBkJfVuUIIR2Trz+8G+K6IlXx2 tCktSwQ9NW7yJppi7VrIqGtz4+ZzdNtL2+K3o7cN6oI45lxkZgJuqGrfCZoDPy4lf+SW5G3 FJ+5EDRI/YllAmPhuz6qUGpdTH5eTnBwDtoBtp74twTmk88l1Eh1voviZcNKbrz8/h1jHQe AkKjIQh51tFdSoBNRJVNQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:JfwvQUd5ijw=:aunA74VsFa1n1pEZOBHTON t2wQUTmJ/K5hFur1B/xT1ukAW8hMWUoDQSw91BfEnYw+4Y7IQSlP48ocbmbVcncbLpkEWyRAa I4v65YER7x6IEBQ39xncH+ecsLm93h3MOQW08/b00Umjpo1HSnJTeniKmGYKCg3qr2IB2FOVb fPDroVf3Yq4g9uu+C2hU18YZi4ZV1bfWFehQn3tYCHdz869A+MBTIVUDE6sgybFYDKEwSDSRf MFu0J4U5Y6rd7HPTmk/CPWyNY1V3/ul75YgmoM6m89PXKdL/7Sx6fUbc3pw/Z3Fu5A9x5abGo izUosoMdLSZQ8nwrVqF0+6Ev9OOXKpSrIja5+OqCpmCY05FhHLiFfMBssK2EMgWWnTiF3P6Tl UF/9JPLalL9EwU0aboThawUFybj/qGF3WCuoq+X4XctdvwV0jBMCVEPxco8dTcATsCr+O0hvn kZ9ghSUA9XiJikebvhPzd4E9WjU+xPWMbYt4g2h+1L6TDsoJRrBy9S/jlRYFUqXjlQhW4vjtE lNUVXK5J7D1APU5Bz2QLmkTuAn06CkQxbU9EKM7D0WhYGkRJvj+1w94r0oR4EfEhwziQv7n2J aDizQ+wVo6kAycxkOh5Ho0hFLZcqFz0sLKrg/BB5X11e+FGaIWWSOh1u12I1+pfQHxb7uNs5B Dnf2WpEips/loK6TSaxsSbvJyUmBWWZCHkt9m1iGd/YDN6eGrBAzUClHCd3Y+WjDIif6LiDyN jcmF9tvkP5cYWRXDNCcbuc/xTvW4P44IG2futQ== 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 --- v2: fix up rtc_time64_to_tm() calling conventions --- 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..815027476600 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, &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, &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:36:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133984 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp730949lji; Mon, 23 Apr 2018 01:37:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Bxf8a+DVoCnnV0fA1v2JSVhFBjoA1woLUcHXJOHXOOj0wia3WoIwjt02GVQbNCpaQMR6u X-Received: by 10.98.59.203 with SMTP id w72mr11555741pfj.129.1524472642163; Mon, 23 Apr 2018 01:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524472642; cv=none; d=google.com; s=arc-20160816; b=tNZIOEVd1tAihmt6wzj7AjI8Ws/CbLZGHWEK9XKqphrNh3ZIe9lKHh6vSJ9CxP03vN AWr0wSey1y7IVSs4JYJ5oxaNkAiNZASqLenUtoLzZYXU4/CS/y/Uhv38Tz6rUh3Cuvoj 5FsW5VKzKzohXJIMXDIMieEwtUDrgZ/hBbEQE4AsumLbRvTgkO2XBr1WtkFSUI/3F2Ki 5WZqNFON6upUVKmLvddBcUEuthuMKLqLCNyZUnkha6L9Mod4+afSb+f1QxZdMcEQ1o7w OXSSnrKWTwS3pkMUoEBmqNm1iOY3e7z/Se6pQfsAMJdxWSG1sDxAT5A+6jbApSCLuuR4 zo/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:arc-authentication-results; bh=v5Pyd3xVbdsUPRYZwD6njzfY6XKPl0Uo8jJi7LPnF8M=; b=NdkxwJ3IyLctOSCfGlrLFPtHIfyXglaFUiGckkHnuu3br5puP1Vbj/A0OU9H5QgcMG Rn0fwLk6Qbbz52NYLdAUpraTTaam6R5JesjzxNXpyPF3nypOHNUYUFyGKZcHOLkQh9qV 0oE7fh8PNZGJhZjDtnasEZHBgyFVNOHsOEi+MEDz/7SdhivYvTsYJck8kanu/lyfIhn3 VIK8K/C9mKiwvap70LgWcshO2XAwALp5lkLC8Iamsa+XFw5+dTRGnnvyysZ1z+P+5/15 VjNq4XrHuBYevMAkZKpTSsbFhz4h2WFu0sU5dx100dWuoG+Uq639QFoB2f0cN8Aph+zp UO5w== 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 68si9550165pgd.511.2018.04.23.01.37.21; Mon, 23 Apr 2018 01:37:22 -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 S1754634AbeDWIhS (ORCPT + 29 others); Mon, 23 Apr 2018 04:37:18 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:34009 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbeDWIhL (ORCPT ); Mon, 23 Apr 2018 04:37:11 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lv94E-1eT3193BWE-010MYQ; Mon, 23 Apr 2018 10:36:57 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH 3/5] powerpc: use time64_t in read_persistent_clock Date: Mon, 23 Apr 2018 10:36:40 +0200 Message-Id: <20180423083642.2608886-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423083642.2608886-1-arnd@arndb.de> References: <20180423083642.2608886-1-arnd@arndb.de> X-Provags-ID: V03:K1:fUUMNx6slM3mkrjSZxz36cZCFnH2Db2qqujtoQwh0stwT9VS4Tl 7k9LoJ/lzLIgFKgiLAcJVoiSKgdsc8wnzOh/82keL4FI+Fc1XZ5A+3PCrG0CjVb9D6E+iyb QjBlCcOcWUs2plHo24K/Zd+F3t3o9P/2ALDdPkJZFxZDlZ+pM0xpfRDCRVOk7S0Z1TmAVam nongbA2ntj1P/IRI4jLSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:PrBG12/YFCs=:TiygOgsF6TFX1sbL+9G7Ae w3dTReBeEU+Ic1QAQ7sZBiR/3YOj71TjLebHYam1noI/85MRkrOPWvC6Ia64h2oToaAAktI0K xvCpfAbEASD4Ghry811aKV5/KqEKilpzBrPDn+1tBnnROiAIA1SQAC7wzk1opeAK1Ha0V9mi1 ISieIKS9AN28AhVOBV1iWAOKrA3Clv/1RTcD8q/krSTWOTteCn0keAi5Ovp1z6q8rmLfgFR2a lXEK1bL9Vj2nW3LM9zJsrAVIhn7RQWpWZUqPENlnVK9wI/lnVnRMAnb0oLB9gs5jyYkHtNmkP ZdI6Vy4ZNmxUpeWxrYGbBaVwVYzaneRvcsQQF5MjtC7fmp6lOcTdxWSemKYpo7Y8gnWqJyU1u qQKBCKIzo8P7NYEzxTgD0wvUz31lt6H0BOHQKSF0fvWbrrok2A3wmkkYhTPxRCfrSYJ7U7e6i mbks030nAApEKVz9+2Xc1ssS2xSNVwY6OIpznDnE6uJkp5bJiBqi0s5KF93DQmyO0TU/AeKvn NjbeRq156HhUgnh8p1PDiLK0eihTMB/J+eo3MWZ3ecszWW5ZNXTer0bVba60ujyzRjBUQi0NL rFWsDDmBmXUhavO5LS9AMz39+0GpBHb5jYnc7dyPrN9NfQ756gIlMpPRVMVOS4QY7o+6vpMSI QO8T91iz4W6MTvuYG9eXO255IbMPgR3nS1ifdQ6SEV4kPomnBk81fOVolSGlll/9S5MrxQm4c k+AOXy2FtVhT6oCR6ZLNr1KjGqE7vHYxks0UzQ== 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 --- v2: fix a typo: rtc_tm_to_time66 -> rtc_tm_to_time64 --- 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..becf2ebf7df5 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_time64(&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:36:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133983 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp730809lji; Mon, 23 Apr 2018 01:37:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+QjdKso2bldu1gqq5+ypChXmHk0ZP0Pje/q32YmHdvMMXO1PCCbOl0W9JBebop8599VRP9 X-Received: by 2002:a17:902:74c3:: with SMTP id f3-v6mr20091370plt.7.1524472631765; Mon, 23 Apr 2018 01:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524472631; cv=none; d=google.com; s=arc-20160816; b=Z8w1vtvKbvNY8bCq+ZSgaLdNHoiBqHA3j1fJ5Q07lGfpRABqctbpqAXTn4LLd4KxML hsG82Lr9wiBFC0kcfO43HWatcVmE02dOaTaT7RoDV7BQGSsIvvYvyPuAhYVWKrfSAoem Q97BE9AjCCwN221hSQ/gn+tzFlErDXpwSZddpKm3LGMGsb5jUwb1IFYYvEhkz1UGuCPl ItsJwIWlInREA7nzFYzrHp02+WxMAbynKFCx/S5CgOCPEE0/pAQS2+jrSMUgeeGTsxOq yYYBSansSl1Q4rkaKidZtO/syX0sdGn86qiiJwqcTP6STg4SQ+Sy8HIfZcYsIDXKFBHL WkcA== 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=UZF2ub3/wq68Bobakx10prQQSKeYP62be1IVvstJAyCUJ7kyC8YTXFpyqs4297jesD b1jIK0wkXG9jY86cfAy59gQLgZupoEmygvYd2iZGg8ySa0Ros2/k6ZPKuoltpj4Nitv4 Ofcv+kwZ36ivEZhz7u33UalJLpy1AI6mPBm4vrQQwHQgNQybv/xIe2d0HZqHsBIKhcNT Jdas8CWdh+916wLOcKydTt/K/K15pW3psYOlitgJGhYUZ7vT2ldxBlzaN/RgvYI47DiG L6lfz6vaqlqjfbkyJZHSxG+MsZGpGWIrYz8WhhcKeBqti4MeKbSM3YIFKWYGW7GRUFNm tL9g== 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 z26si5177259pfd.26.2018.04.23.01.37.11; Mon, 23 Apr 2018 01:37:11 -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 S1754593AbeDWIhJ (ORCPT + 29 others); Mon, 23 Apr 2018 04:37:09 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:44543 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbeDWIhC (ORCPT ); Mon, 23 Apr 2018 04:37:02 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lg6Fn-1edfyz0Ml1-00pZzj; Mon, 23 Apr 2018 10:36:58 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH 4/5] powerpc: use time64_t in update_persistent_clock Date: Mon, 23 Apr 2018 10:36:41 +0200 Message-Id: <20180423083642.2608886-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423083642.2608886-1-arnd@arndb.de> References: <20180423083642.2608886-1-arnd@arndb.de> X-Provags-ID: V03:K1:i63MvfCuZ7Wx+sv739EyVTndhVZT0rXBFW6AebTXY1+jMIVqX0s P7In6PFoMNFMHtsyTbXB/HJKmt7EBUlEi4tM22Fk2SgZnUbK6s/Tx6juHLN4lKHk2CnY2dJ k5xP3B29BBunlGgWof81essBJqC7WrL8qHVQuggLOcieRYilfEGKevOiteVBOADwComZpk0 7A4Vp9pmRovaDdNtCqNeg== X-UI-Out-Filterresults: notjunk:1; V01:K0:bclzS236dUY=:FzqmGPHCBFRqiAuwUlvlu1 7/p9TDxk4pwj/Lj8UC+/tViK1J9Q49liYHw3v7jbSWKiNaDY7h09Lxc+GVE1aQwqSnq0XYKFt pet9lGW8DsNvwi1lQmgQ7DhUn/NUko3M2KdQ/QgW26cX3ej1YgoMqEZ2nJqzz0vlRY+ArokiR ErZzXCsOE2z5q8LD4JAag0XYYbWSztSdABEkJzDRRriqXtG7rdz8Xem9mQQJQK6Q5LpMGlPwr wnw2tmBCHOoH0DXwKyRDr8pCecEUdyt6z1eoZNO2w2qVARi8zXy7gXgpZ8fb/mdmHrpBm6Zsf iji0nGvRFRE6Lb4khLDriB+GeszBpzy9zj6UePjuliKPOwszxP3pVR2NltSGFephJn0K25VkW jTijKSDJqBViM1v7NsjNT0h9KmTLKGoJ/JslgsHsXl6qpnlSNJ/Vnfv2cx2mxCEipomM9Wi5b KTAMTyhyTTFVaZ/8HuSS7Zfp0XVO5HluxFL8H9AORohZGc4U1zgfWZlFbLednVK2b08kuTLcj DZCVzKmUPHKIWj8tkmUcI56t5CckWfDRsvPlbhbwwHZTZdHln/LmscCoC1Ejky5IOJX/HelDg VoKyv/qq1Fxzi408lRdxtHnaUI3WH8ZylqI1KBjutgvzO8RjFHkJ1sq+o/Huu2pBLP11VO5yg t3UzNqEkOca4dpWTbpL8hy3wXMcm/bq4R7TVMhU2kSMMoXpwXSjkCwCkrlLidtXbSHsncvNMt icCvQAroWqWq236UmzoGqFmCrJas/3wXRNh72Q== 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:36:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133985 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp731714lji; Mon, 23 Apr 2018 01:38:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+0+gKZFdaX/dhJC0m3RoHvgGLZH5fJKOeCRRbrh6RsX32EHILUBe59AG7AacsaYLxH2Jj8 X-Received: by 2002:a17:902:be06:: with SMTP id r6-v6mr14215195pls.158.1524472703014; Mon, 23 Apr 2018 01:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524472703; cv=none; d=google.com; s=arc-20160816; b=nyImbxk9dpJngo15w/KaEYED87ArLAlUPHbA4jd6F5UuhEtr7h+dFkljwwVS7QVt9w ZVK3zeCRDimf5oYQUseGR/8E2H4tiz8EYa8cK0cVvAo6KpJBzO2tKlJXKxpGMQwZsita JbbXzQ2HpUQjDaDdn43w39/dGsQuR1Nw+aCEKWzBrkov8VmPj47BTRfRUfJ3ZKBrPHQP 3eQIhvZugNw11Y0METSKEqJSXujMaeII6XrT1YYytZvPSeMxIwNmNsufZvlkfgWfQWaS s9Ky07g6WTay14pIxRBSxE5UzeNJkIatHCykp5fDJGErt15r7Ma+QRhWZIxHlBdtekz5 T7+A== 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=NbUsZBEEl12cZi93SijOSzoFLwfSyICc9ob4xH9HDNUOc8TVRwSPpYQdarhsUNq8e6 jpd1N9ajdFMQrEYYuhBJsz1UPQ0evVsXY+agPifBOnY7RBNWh8SeQHYtUFBcZcazlyUU HA9bEBn3oCZjouW8hKOIQxqALWAZ5s1uIsdev7u40+JZCPdgl3rb8vIqXC7d8rU6/X/i AP0ANdYcKNfe0kmrkNf0qmNg0+Ri24WBh+vENc5p9FHYmmEFncanmDB2GZ/+jLmaqqa3 uoBddvfKv8mxAJJhkyJCGMMVZRpZg0zXQDbmS38s51sqs69aWts9d9CUWDEAkTFkZ8LX HTuA== 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 n71si10919505pfk.277.2018.04.23.01.38.22; Mon, 23 Apr 2018 01:38:23 -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 S1754514AbeDWIiU (ORCPT + 29 others); Mon, 23 Apr 2018 04:38:20 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:58587 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754597AbeDWIhQ (ORCPT ); Mon, 23 Apr 2018 04:37:16 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MNeGY-1f4SA41j5u-007CcQ; Mon, 23 Apr 2018 10:36:58 +0200 From: Arnd Bergmann To: Michael Ellerman Cc: Paul Mackerras , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH 5/5] powerpc: remove unused to_tm() helper Date: Mon, 23 Apr 2018 10:36:42 +0200 Message-Id: <20180423083642.2608886-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180423083642.2608886-1-arnd@arndb.de> References: <20180423083642.2608886-1-arnd@arndb.de> X-Provags-ID: V03:K1:W0hINnDI0ZbdXVpyAdpGvscBey4v4Q8BDN7S+80MT39s8ov6JHi NZBpsdzhzspbCPN1b09xXlI7tg0TeTIxah0t4RJE/6GgaVCCpzbJGS3dma9NXA713fPtqq0 6km3P2/IreMrIo5n1glfRWD43+E7lMukJsvXWTe5rnORFj1Spaai6QNyHvG2LoiXzvXq0Hf jAAeZ0VFw5GoGXSJLStXQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:xroRxFA9f5Y=:KvdlsfBnkbfRH9qeGfFpA5 n0PJK033+/l+9qe/WauCwwtaYqiXDW0zBfEvy/coK70Glm86TpH+QghbjYiwPlN8dtcuKe8wm UpPiCsaPj1DXChSYNOt/+ti0DV9mnzdFPZQmpoKA0Q9rSqweJnOh+OVelAJSZwFJJDcw0UEmw eAagmjU29JvWjZuUNIRbwbkGdsmFmCHNFPlKOURROqrGF+HB/8Y5DXSmG2xSqyKzkZKZJgesB t/o3kRzyuL0AhQwpZsLsfq9xVAYzzRrhIEfP/Jst0SZWncsEj9ong885Hu4tjmHdMXZhAs1/e LEsJ7EbqmHRFCbg2U8hl6/Ud3bHFMs0s7U/m0CGTTCdvJ7xPW7DfE0ESmPukawshKnk44xdO/ y8urCZ0uu/lLIVgRl06va7hShWVh/wYr8ZxhRca2P25bgcqy+HVO/QqML9dMDuTDUvHq7Jhp8 StOpd/CkhidPqzo1MsYzPXffI2+Lgtdncu5AtzjvXfOn7oUHyNstmejZwj2y2kxspwONiSgB9 ieYY6egD2t/n5V80IIThsLw7Cr5/cRC8Xt+DPmeG2RNq3sI5dYy5DC6ZKEAm4fxkc5AWrR1gc GAiHy10lg2ZyhZGj1TjNtkBvNNKU/pFqQcV3MBD4tIQ8oD6HnL3hDxACTAa7FUKslSf0Qb/5G eMZD1cvLZ2B/lSO5GRP06VpS477YxK9Uzj1EnJ9iG9vUM93qOiiLBdYAjIhRQFw6G1XaNSl4s e16t+GvqN4kehHzRopWCszwPIuxuH3uCKhI3bg== 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;