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;