From patchwork Tue Jun 20 09:35:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 105990 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1281070qgd; Tue, 20 Jun 2017 02:58:00 -0700 (PDT) X-Received: by 10.84.231.134 with SMTP id g6mr34568712plk.86.1497952679898; Tue, 20 Jun 2017 02:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497952679; cv=none; d=google.com; s=arc-20160816; b=YLQDBvIUQk4GKb31FTEBA+ufMcdN/k/cTT5V/roZ+tLDuufG3j9gPNwO0KhZSv3lCx DYZZu7/qFmZcwjvhQMgZHIVwhmUbU4AwnwhaQleZJ5ln9tr/mBANN0RJsLMLBv9XTLVf c5icsmK8SqolzMIsL+majExcVIxgLbgNmuPjsjXtS65UHmOhxbQuBEDcjrtAhbahO70C iN/OHxEuUV0AiMFRAruBAOvcx7paqI4y95z6HN6v5Eb3dVR4V0Ti61VLwMoHbclBGq09 1FZtsup8zRSiTCqB85qG4x68CpXb0jrjzGaFnK4Sq8zXlwvskXKRx5+VJ2vyhZ28e+wA spFQ== 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=knrXV4XWozqmvDOGcatTWVg+/U3qFeoVrOrvDZ6fKdc=; b=0MafvGYKUSwvNziiSCKhMVmbih2EgwVRCEvwZs0j3SdZ1eomRJVRWKQ/Yg7PAXNaYE OOKi0w8a5Dx57A8A0zHoLb6oR7vEW85LB4urziIdu0uK6pStBlKiCdhLDy7xPcHUmDfy zr+0LtTX8c4gxuBcduA+QF9G5EYQiIe/UJQwCGrqRrk2SHP83Y3/LqdgngcVV2WyRLhw O9l2v4MNn1atJ4UBcqd2GLXE8aaFAswu85fdNvMD4hyrEcfnX5hQ2XLJykkk62XJC4uI 3gRrDKDTIViK/2yAduebar/HwkuFymRjO/dlmVFIc5FbY+q9HL3faeqillSeEaXJl+Kf gUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Fq5gfj4J; 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 m63si8163098pld.547.2017.06.20.02.57.59; Tue, 20 Jun 2017 02:57:59 -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=Fq5gfj4J; 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 S1752772AbdFTJ5u (ORCPT + 25 others); Tue, 20 Jun 2017 05:57:50 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:36676 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752648AbdFTJhJ (ORCPT ); Tue, 20 Jun 2017 05:37:09 -0400 Received: by mail-wr0-f172.google.com with SMTP id c11so32941081wrc.3 for ; Tue, 20 Jun 2017 02:37:09 -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=knrXV4XWozqmvDOGcatTWVg+/U3qFeoVrOrvDZ6fKdc=; b=Fq5gfj4JwXW5jy9oMpaG1UO+nIdYjNcOgUt33kQS/Q9WoO07ThHDYfK7a/Cc5ihKvi yCq/fKo69TdVTzcYbmVdU6sZhtes0/VSbxCYgpBooIqCbCbRhMB23dVwcgZcmOP0vO+Y TsV9BCIHu74oDssflyI3K+poPUmIBRAlkToeE= 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=knrXV4XWozqmvDOGcatTWVg+/U3qFeoVrOrvDZ6fKdc=; b=m1Ww3/Sw2hA+wU3vnA6PNvqjJvaHgNqOHt0suInKgW40b7cZitRQgCG3oHNUqq3B8D 6YteVTHlf3Kxok9ojZewEUzxxgpn1Vp/vDrRdGfDcIHC45O2eZWlZfKUCJCkz2sg6stm Ha6u8U5Tq4ZYBn0c7SiurYeTo7zTeS4Rrc6RthyRDRPZMQDZinwCTYYlo8xAj0FY5lde GbvtGInMrEtTXBffUUB3JjqEBK8+VrvkeiKTSnJr/jN5J4QZZDYGi1zEa5KluisvgYe9 zxmuy0iMfOoptTBqzBB5jK8dWsv+gHKH+LQ+AgJWfPZcfP5SXmk+/5aFpgWbADArHIlO gcDw== X-Gm-Message-State: AKS2vOwFV9KEn/yIjrNcvYR2bMR0s6mEJA9935MWBik6AjhDt3KGg0gX +6ln5Ae3gjp7jha5SqN3PQ== X-Received: by 10.223.169.203 with SMTP id b69mr21478898wrd.1.1497951428438; Tue, 20 Jun 2017 02:37:08 -0700 (PDT) Received: from lmenx321.st.com. ([80.215.93.217]) by smtp.gmail.com with ESMTPSA id e24sm4482318wrc.35.2017.06.20.02.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 02:37:08 -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 06/51] rtc: ab-b5ze-s3: stop using rtc deprecated functions Date: Tue, 20 Jun 2017 11:35:14 +0200 Message-Id: <1497951359-13334-7-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497951359-13334-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497951359-13334-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. 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-ab-b5ze-s3.c | 45 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) -- 1.9.1 diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c index a319bf1..ce37997 100644 --- a/drivers/rtc/rtc-ab-b5ze-s3.c +++ b/drivers/rtc/rtc-ab-b5ze-s3.c @@ -328,7 +328,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time rtc_tm, *alarm_tm = &alarm->time; u8 regs[ABB5ZES3_TIMA_SEC_LEN + 1]; - unsigned long rtc_secs; + unsigned long long rtc_secs; unsigned int reg; u8 timer_secs; int ret; @@ -352,9 +352,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, goto err; /* ... convert to seconds ... */ - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); /* ... add remaining timer A time ... */ ret = sec_from_timer_a(&timer_secs, regs[1], regs[2]); @@ -362,7 +360,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev, goto err; /* ... and convert back. */ - rtc_time_to_tm(rtc_secs + timer_secs, alarm_tm); + rtc_time64_to_tm(rtc_secs + timer_secs, alarm_tm); ret = regmap_read(data->regmap, ABB5ZES3_REG_CTRL2, ®); if (ret) { @@ -383,7 +381,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time rtc_tm, *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; u8 regs[ABB5ZES3_ALRM_SEC_LEN]; unsigned int reg; int ret; @@ -414,13 +412,8 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev, alarm_tm->tm_year = rtc_tm.tm_year; alarm_tm->tm_mon = rtc_tm.tm_mon; - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm); if (alarm_secs < rtc_secs) { if (alarm_tm->tm_mon == 11) { @@ -477,7 +470,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; u8 regs[ABB5ZES3_ALRM_SEC_LEN]; struct rtc_time rtc_tm; int ret, enable = 1; @@ -486,13 +479,8 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (ret) goto err; - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm); /* If alarm time is before current time, disable the alarm */ if (!alarm->enabled || alarm_secs <= rtc_secs) { @@ -511,9 +499,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) rtc_tm.tm_mon += 1; } - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); if (alarm_secs > rtc_secs) { dev_err(dev, "%s: alarm maximum is one month in the " @@ -597,7 +583,7 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct abb5zes3_rtc_data *data = dev_get_drvdata(dev); struct rtc_time *alarm_tm = &alarm->time; - unsigned long rtc_secs, alarm_secs; + unsigned long long rtc_secs, alarm_secs; struct rtc_time rtc_tm; int ret; @@ -606,13 +592,8 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (ret) goto err; - ret = rtc_tm_to_time(&rtc_tm, &rtc_secs); - if (ret) - goto err; - - ret = rtc_tm_to_time(alarm_tm, &alarm_secs); - if (ret) - goto err; + rtc_secs = rtc_tm_to_time64(&rtc_tm); + alarm_secs = rtc_tm_to_time64(alarm_tm); /* Let's first disable both the alarm and the timer interrupts */ ret = _abb5zes3_rtc_update_alarm(dev, false);