From patchwork Wed Jul 12 08:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 107469 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp608096obm; Wed, 12 Jul 2017 01:14:09 -0700 (PDT) X-Received: by 10.84.217.29 with SMTP id o29mr2801485pli.117.1499847248922; Wed, 12 Jul 2017 01:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499847248; cv=none; d=google.com; s=arc-20160816; b=HssITv4ua6n3qJUDtQKeTO+mMQTKx1vns3qqGsTF4Ox3ajRSYprSr5vkk/2ig19cYK t/oC3PkLnYjh6LnRpULlurkXHOyZK1YbhztYd7VmJFErDrr9xzjv5S0gkf8zVrjx8Gc4 VrlMJn/EkpPM/IZOC2yDUMDNLJRW1sErfjG8a9FeCuulC0ewxkVFBQL+A1S1pITu8T01 cbJT3kyCIQByEpqZgkMGcyubGtncKIXYSfp4Mm0szUyF8gv3IT2O1osXS27rRLjz59Xm UFwKqeSHQt3N7zOrC7yNv0PtstmsMc0A97mBAUeUN7PV6g4ZppFJRGN3/0IFMdDZgvnS 1BRg== 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=S1WL4RbTmtqB1qq2uqNCWE5fvEvvLf8muGm4PmLe+uV4YSsvxtqof/FJUPq5GQVImV P+6N5vAE6ecMdG6z23sT4WZLIOp1Ai4vKG+wNOsXzAwnxCm1BnPNmnJ9o/AFbeJC9NpC VVH3okEnZAc/JyU+6WB/QpyqEG8W+A2fNIXPrI5Q/QdV+OTwk0KbGfd0ukQXUndo4XLv X5yhq4be5CGNLk4G+OevszWbQ/w1lH7gfXYDXqLG2Av/kDliRThl6++mVVpJ41pDjG8J eW+FZCVpoFeA6n+QaDV8KVWWEzIvsB69vOiHQNWDhh9LQxEpFsHF3gH4nfjbxRVPYHot /YYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=PWjvSbwY; 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 s134si1429359pgs.503.2017.07.12.01.14.08; Wed, 12 Jul 2017 01:14:08 -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=PWjvSbwY; 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 S933882AbdGLINk (ORCPT + 25 others); Wed, 12 Jul 2017 04:13:40 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:35692 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756982AbdGLIFQ (ORCPT ); Wed, 12 Jul 2017 04:05:16 -0400 Received: by mail-wr0-f175.google.com with SMTP id k67so22361222wrc.2 for ; Wed, 12 Jul 2017 01:05:15 -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=PWjvSbwYTzWXcL//fsCYtCspIhUWtTijQrImeMD8rv+o1eWVB6J9KF5ffftQgqdKiW l3mdqhmkOihcFpBavdjFDj0cR0tGECRbvBBGK9bVpw+v53Ch+0aJYICPEKzG3dSL47sm i3H5sVE367SndT3PVEjXB2LONzHWknT4343Rk= 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=NTx9xONQWXZqUYWA2yPE+Bu8d/YyXjHL+ZADgAQSZWoJt9/J25qXjNVoeVXH21plQF 12bLsf5xfahNVDGJK0di+Ps5gSL7q4WAuPJnGUtcqLnQMsh3y/3+xrIsbCrmYZs3cigH 97Ol/hN5lSf26363/y0ndTSKGz2FCRCANMVzYETFbq0wSx4esBQjkZn2fb9BN9pCdp1/ 8rcjiaS56I2PHVqX+EDlFOtje/I8XoIsJ7eIT2eHwf4xBcmquaaiJ7TxJTWGZA0UXvYy Pg3+sQlVvKaJZ/d4aFyfjaH6PidSpmDkOE7wStaVCjjvEcxmSJSTn01BIbl/9c/8gaBy 0vCA== X-Gm-Message-State: AIVw111ux/XRsfiZAroegWtF1q5KQXWecdhx4HWUK+RflLTtWnAwZTJe o4nYLzuKj+ML6mUV X-Received: by 10.28.127.14 with SMTP id a14mr1574684wmd.91.1499846714473; Wed, 12 Jul 2017 01:05:14 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 01:05:13 -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 04/22] rtc: ab-b5ze-s3: stop using rtc deprecated functions Date: Wed, 12 Jul 2017 10:04:24 +0200 Message-Id: <1499846682-14093-5-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. 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);