From patchwork Wed Jul 12 08:04:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 107467 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp607343obm; Wed, 12 Jul 2017 01:13:13 -0700 (PDT) X-Received: by 10.84.129.106 with SMTP id 97mr2771874plb.246.1499847193816; Wed, 12 Jul 2017 01:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499847193; cv=none; d=google.com; s=arc-20160816; b=wkBKT3mg28Qt1oxTpJA+3JV+9yD+nth/fkycYk/cW2YLZG4Nr51nnYlYTLkJP7ZoZA DgTHCEWbPSiRwhPHDC56C7nJiNpmFcUCRoIhrZ0Oc3lACzrfGI1r1+47dz/EO0p7p3lr lWCzTEt6yeUk6il3M7J6tEpNOXUbAYdm5X0VcyR4mkrQwus9vhfBvp91F5EKQQvBzOaP 8sPPzpDtLtLE0EDmx+jTQvrq5xE5oIoTl4A0z28vZjyb3E3ao8ty5b0xmn1X1YS0XXvS uy+pPIK20l1AtT5WY0v9vZIxP8m/X72QgUq264nosFj/JDdIPzNUAG1rZUNs8bFkTeQo DAzQ== 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=UR6J7sJF7kRQPXONmmHnu3IbCBG3e1GTdTzr/jWs6Hk=; b=pNiVrZWNVKw/mthnDpqwgrUapYd39SKB0Q+QIN/hgHoxAp5x8ic0uLi9aoClnJuBr4 i3WNRaZiP969fSVhiLVGuG1Od4RcAjbx7eooc0HIMVEYSJjl6AWB2ksk/5BMexMHvcNQ fesCCyDeCmUq0Zr1xnJME9fcmY8L4jFa30LZiOPdMQ2lLJd2bs3Hv5VMrpA/zB8+YLM3 YSdqgHmUdyThAvhoNsI7mTSEuPovA1ob14qkBtc/r5xzjJjYPoQcf6l2jXhvAin3nSrc Xm08JZyxGx+wDdSLq9dWFbjyJGiuTNuezR4qJHyrLe6Z+3gFIIlcg9lPY5W+3w5VZoy/ fRxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=cKTXu8vv; 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 u91si1454738plb.334.2017.07.12.01.13.13; Wed, 12 Jul 2017 01:13:13 -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=cKTXu8vv; 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 S933842AbdGLIMz (ORCPT + 25 others); Wed, 12 Jul 2017 04:12:55 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:35744 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757003AbdGLIFT (ORCPT ); Wed, 12 Jul 2017 04:05:19 -0400 Received: by mail-wr0-f171.google.com with SMTP id k67so22363582wrc.2 for ; Wed, 12 Jul 2017 01:05:19 -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=UR6J7sJF7kRQPXONmmHnu3IbCBG3e1GTdTzr/jWs6Hk=; b=cKTXu8vvkC9mSVgebRGHmHuBTAkDOyy65PWkmvjz0F1PjiaVf4Ll7rwVKDCHFc9O39 +q/wqH/UXv/BPRcuNE4xdsbSnyLk0Q5qeXrpvrk8wW2zZkfwCeDLXbZ9a4TSNnLQZO0e 192dGYrq0jBjNNNi6OQRwktcDKITvhK8myQPo= 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=UR6J7sJF7kRQPXONmmHnu3IbCBG3e1GTdTzr/jWs6Hk=; b=l74vA3Yc0iQ/c0QhCUXj72Jf7Xwc9etKJ092dgD/R5nHNSLYr/DCYkjlaAfXUy+BGV aN8oNhBv1ySkF/L3EIg0ghR2ge0JlMEj2e8UTzK7KI/GhetHJkyPT4pTHqkiraInz/mE IVLUWgmc9+p41hI70a7CohhiPkIR4UbKd2kePxrKUJskIyZk2sUIRjD/STRGgYnpYYxk iBb3X7bHxO0+h88PRLGAcX6JWtPQjJuvRISp5RRK/90Cc69dTB2tagcJDUNghLKKCnnE LL6OkHayaTy82u4ysDj/Dygp+bJjDkbA7N4Ydy7Ef+VhMD8yeEFdeJMW/b0rQnxF3zGA HUZg== X-Gm-Message-State: AIVw111uoK7LrYfZ5Wa22mJrNTNqUTE+39A3m8vYXOgplwMKxLBH/LAO XZD5oyqa6qqWM2kF X-Received: by 10.223.128.80 with SMTP id 74mr2259266wrk.9.1499846718301; Wed, 12 Jul 2017 01:05:18 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 01:05:17 -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 06/22] rtc: cpcap: stop using rtc deprecated functions Date: Wed, 12 Jul 2017 10:04:26 +0200 Message-Id: <1499846682-14093-7-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-cpcap.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c index 3a0333e..e92b346 100644 --- a/drivers/rtc/rtc-cpcap.c +++ b/drivers/rtc/rtc-cpcap.c @@ -58,24 +58,23 @@ struct cpcap_rtc { static void cpcap2rtc_time(struct rtc_time *rtc, struct cpcap_time *cpcap) { unsigned long int tod; - unsigned long int time; + unsigned long long time; tod = (cpcap->tod1 & TOD1_MASK) | ((cpcap->tod2 & TOD2_MASK) << 8); time = tod + ((cpcap->day & DAY_MASK) * SECS_PER_DAY); - rtc_time_to_tm(time, rtc); + rtc_time64_to_tm(time, rtc); } static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc) { - unsigned long time; + unsigned long long time, tod; - rtc_tm_to_time(rtc, &time); - - cpcap->day = time / SECS_PER_DAY; - time %= SECS_PER_DAY; - cpcap->tod2 = (time >> 8) & TOD2_MASK; - cpcap->tod1 = time & TOD1_MASK; + time = rtc_tm_to_time64(rtc); + tod = do_div(time, SECS_PER_DAY); + cpcap->day = time; + cpcap->tod2 = (tod >> 8) & TOD2_MASK; + cpcap->tod1 = tod & TOD1_MASK; } static int cpcap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)