From patchwork Wed Jul 12 08:04:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 107462 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp604871obm; Wed, 12 Jul 2017 01:10:06 -0700 (PDT) X-Received: by 10.99.60.28 with SMTP id j28mr2555097pga.18.1499847006437; Wed, 12 Jul 2017 01:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499847006; cv=none; d=google.com; s=arc-20160816; b=Q0/dI089Lzg7lukbyxJ6kWwv2wRRl+Q1rlwKxPiNsxrqDyZkF0s2/SWO3YFHc3Dotm G2X2yNRIpISiZ7jjkqBHWw99HJuIsaUHlgUjKaBKnGw1F3gWlQtwGf/JyjbQmFhFrOQA xbdylVJROaKW+UCv101KVfVTefNZpLbCZDMJiwRfAhvYwBaRheb9grFY18XNvsqHlZSB N4HAZubQ5PwZwUkzbcVuUrTfSaPqpE9g97F+oGqb4YgVkkesaPeRANcwds3KE0dSWzTK auRZekQwS/QIDIn4gzSpOLNdZhSJsLruuY9l3HrdxzXJmymMSFfiQeVlOE8IHIgn3q7K 4tvQ== 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:dkim-signature:arc-authentication-results; bh=Gbqqqpi/ld7LejpxceT76DgIPCsFOhIVfhDvPHgIiYQ=; b=eKCDniQ6jXA2d3qfTzyNv+3UZAtmPtXz9WycbJhOn+O7v7JK8Lia/GbrbYEHTykxsI PdgYY3Ae9KxczE50AYHF1z3AZ7MOFtOAGM+jlyjb8YxdH9VK19VxlihWVzOrICA+CbFn 5k/Top7xLHRuHPiUSZ+FPEV/w5+3sWwLXTc+jiHwOpnzB+jv5JYytAKC3bolOOIOGj5k 459Aiy+1NMU37tUXKjGfbnM64O3vm732uz3ykIaKEDcNgoLnNUzsLShHXYJ3FQEfwT4a Q2Ptow/FACjek81nR/MD/3DgSBu2spvWVqtGtGdc4QYoSidz2RSfg5Tv8bIA5TwI0nM9 0SlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=FPEyWgJM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71si1418278plb.627.2017.07.12.01.10.06; Wed, 12 Jul 2017 01:10:06 -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; dkim=pass header.i=@linaro.org header.b=FPEyWgJM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933667AbdGLIJ1 (ORCPT + 25 others); Wed, 12 Jul 2017 04:09:27 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:33049 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757055AbdGLIFs (ORCPT ); Wed, 12 Jul 2017 04:05:48 -0400 Received: by mail-wr0-f170.google.com with SMTP id r103so22511887wrb.0 for ; Wed, 12 Jul 2017 01:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gbqqqpi/ld7LejpxceT76DgIPCsFOhIVfhDvPHgIiYQ=; b=FPEyWgJMCkZc9VhARmtarRWZ7qK8FlrYkPE7ye+4cBS7BsmrpRW0r5VYuvaJ2xGLft CMCs6PIgwGPxNwNHv6yge/izEXm/ij2dh2xMm6DrYED06b1PIqKKfpWS3PIha67sC449 S3rLLAA9s4hvx2Ms8Bq77eK5jHXlxokCggsDY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gbqqqpi/ld7LejpxceT76DgIPCsFOhIVfhDvPHgIiYQ=; b=IyGY+0Sv5709mFDkGmBEnOHDEA5Eoe3uPPLm7kMX6h+PtpR8iP+5sJP8fvdeKY62iM z6Nf1ktbHxEIf95PUnF6/3whFBI1UwRN/elrf1F+Llsf4BbFP4CWhhi1vDQ10dPIWzDy gHk3c5TijYb1RJtvr2bJblM+sln21zTepy5exdw1xt3OqtEMjXsAZprIF5ybkwFDL8NW KQqWq0rCXHYXmFAU1/lIhSDqeJkECMEKzDMtw8oPuj2reINUvWnhrhc5fi8tzCvgu7uA F9OxUDqPCpuTXkioBjDOhfW/T34k4cKCAXUQLFjV3HNAQnsZNIWx9mCwEk6mr3idqwMe 1GaA== X-Gm-Message-State: AIVw111EB045AcU6PXxRZkW68iRJ5CfOYWv8mfAx7uKbj2ObLxO2xO8N qIIY9oTZx2n2lDCx X-Received: by 10.28.139.145 with SMTP id n139mr1547656wmd.53.1499846732107; Wed, 12 Jul 2017 01:05:32 -0700 (PDT) Received: from lmenx321.st.com. ([80.215.158.26]) by smtp.gmail.com with ESMTPSA id p34sm1430744wrc.66.2017.07.12.01.05.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 01:05:31 -0700 (PDT) From: Benjamin Gaignard To: benjamin.gaignard@linaro.org Cc: linaro-kernel@lists.linaro.org, Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 14/22] rtc: pcap: stop using rtc deprecated functions Date: Wed, 12 Jul 2017 10:04:34 +0200 Message-Id: <1499846682-14093-15-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499846682-14093-1-git-send-email-benjamin.gaignard@linaro.org> References: <1499846682-14093-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones. version 2: - fix compilation issues by using do_div() Signed-off-by: Benjamin Gaignard CC: Alessandro Zummo CC: Alexandre Belloni CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-pcap.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) -- 1.9.1 diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index c443324..65aa6e2 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c @@ -46,7 +46,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; - unsigned long secs; + unsigned long long secs; u32 tod; /* time of day, seconds since midnight */ u32 days; /* days since 1/1/1970 */ @@ -56,7 +56,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days); secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; - rtc_time_to_tm(secs, tm); + rtc_time64_to_tm(secs, tm); return 0; } @@ -66,16 +66,14 @@ static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; - unsigned long secs; - u32 tod, days; + unsigned long long secs; + u32 tod; - rtc_tm_to_time(tm, &secs); + secs = rtc_tm_to_time64(tm); - tod = secs % SEC_PER_DAY; + tod = do_div(secs, SEC_PER_DAY); ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod); - - days = secs / SEC_PER_DAY; - ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, days); + ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, secs); return 0; } @@ -84,7 +82,7 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); - unsigned long secs; + unsigned long long secs; u32 tod, days; ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_TOD, &tod); @@ -93,21 +91,19 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm) ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days); secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; - rtc_time_to_tm(secs, tm); + rtc_time64_to_tm(secs, tm); return rtc_valid_tm(tm); } -static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs) +static int pcap_rtc_set_mmss64(struct device *dev, time64_t secs) { struct platform_device *pdev = to_platform_device(dev); struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev); u32 tod, days; - tod = secs % SEC_PER_DAY; + days = div_s64_rem(secs, SEC_PER_DAY, &tod); ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TOD, tod); - - days = secs / SEC_PER_DAY; ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAY, days); return 0; @@ -135,7 +131,7 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en) .read_time = pcap_rtc_read_time, .read_alarm = pcap_rtc_read_alarm, .set_alarm = pcap_rtc_set_alarm, - .set_mmss = pcap_rtc_set_mmss, + .set_mmss64 = pcap_rtc_set_mmss64, .alarm_irq_enable = pcap_rtc_alarm_irq_enable, };