From patchwork Wed Jul 12 08:04:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 107455 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp601700obm; Wed, 12 Jul 2017 01:06:19 -0700 (PDT) X-Received: by 10.98.82.87 with SMTP id g84mr54105730pfb.232.1499846779076; Wed, 12 Jul 2017 01:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499846779; cv=none; d=google.com; s=arc-20160816; b=xPAWqH6DhRAo6SSnr9eIlV7FCeCtQh7y48ZMJeNXSCI2qNRe98p0MPMO9sbLLglVFj IEYCnGRVxsZTMncoLMRQ8zigJS6c+tcF58gCsIJ67QJk/nynEdgQzsI3q4ch0TaIMk9o /4vA4eW88rnSB0z+0eWkaI+ktodvRpK1z1Fx36xI5O/L4kJUJUasbvw6Idad3iTLhn4p dA2FJWfvQ9nSA1sECXR5SCeKznS9sPEMU7iPDhEfg5c5rJkXaWGWsV6ct9FpVjw8H8cK By0OZbUQXn61KQg9aGZFwapJg393cBy1m9j5z5tLn2zjaFP+biUL9t5qkhDvorUgqBhG nnxw== 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=nXSvKHZC0uw7fNls4d/gmz382B6CA2g17RyXA6IvGFg=; b=FxWyxHwEn4jgU9+ZywIBPMteM/Zq7/AOyu1T/6aKvXGyvgZ+IVR9IOjSXT3JZEHw8w JoR9qJpnLNzOEIM6lx3NELvhJsGnMU6ZaMZG+W+giqMfieR8cdcwnHo3kZVYcJNOTMZ3 aOWDXATx2K66KI1oI/5ljXPM0ZzjkJgHWq1EX+QBbGh2MbmjwHJh950pJHXBXwB+kbJC D2vetF4ZPYVnBIjLn9zAf8efhpjoKvlQXbiclbvWOZ2KvOKp+T8TeJL8bAG11Bx6uAhq Lnoyv9DkC9IE3dejB/7V1c9ysXOAY0ttdozes6XvXSjPKwIQ8NaF4RQgYW2f4HAdAOgK DyAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=PfavbCMR; 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 v10si1482343plk.122.2017.07.12.01.06.18; Wed, 12 Jul 2017 01:06:19 -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=PfavbCMR; 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 S1757130AbdGLIF5 (ORCPT + 25 others); Wed, 12 Jul 2017 04:05:57 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:33204 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757081AbdGLIFo (ORCPT ); Wed, 12 Jul 2017 04:05:44 -0400 Received: by mail-wr0-f182.google.com with SMTP id r103so22518707wrb.0 for ; Wed, 12 Jul 2017 01:05:43 -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=nXSvKHZC0uw7fNls4d/gmz382B6CA2g17RyXA6IvGFg=; b=PfavbCMRMa64KSLaYmdw+e1tX2FUr3WfFpaOFSx1Qz94sNdQATdtU3IRgGGD70wEAU tikfnMUu0yUFRVJey7yooa3Z8t/eLKvCKhYsvnG0hDWyCJpbtYzB05+2qY9RyuAuGYbG DkxZZvQMERFy7HWcCOr7QmRzEOFLsrWdmlNx0= 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=nXSvKHZC0uw7fNls4d/gmz382B6CA2g17RyXA6IvGFg=; b=OHBjeYft7yIU/xDjpfB9002+nFGEbmrxXlLUTZAiJ7Xh4NVgY8fGgMMGkA+0la6E70 qu/WlQaiImxHY3lnfdApQMph19uB3/DJaVJZIvfcPgwgg6VZr8OvRIkOx4IJkKFYsXLx 7RjePsXq1d2EkmU1ffCD2bYNMxa1W/NB915TMZ1nkCuXT7rmXgqslFDepnuXdDDVO//4 hlZEgFK63qk+oAdh7B5CMMUnCedgI5cvTIOWOtQci5idIiOboDBhlDHDrXVBatYuNYBz CfQEdoK68IG32LJmsrJnHq07kqWtd+qNJL0CVjoeaQh30x84sYGX3w6rm4Sys6U2Zvue 7Y/A== X-Gm-Message-State: AIVw111rQsfI3YJhHUJO77Ce0rnfIQo+RgAUoN3QqrqzEVkQj1VHIucF kl0zIhU4djlEFUGR X-Received: by 10.223.149.99 with SMTP id 90mr2253453wrs.46.1499846743153; Wed, 12 Jul 2017 01:05:43 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 01:05:42 -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 20/22] rtc: sysfs: stop using rtc deprecated functions Date: Wed, 12 Jul 2017 10:04:40 +0200 Message-Id: <1499846682-14093-21-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-sysfs.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index e364550..8b97def 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -72,9 +72,10 @@ retval = rtc_read_time(to_rtc_device(dev), &tm); if (retval == 0) { - unsigned long time; - rtc_tm_to_time(&tm, &time); - retval = sprintf(buf, "%lu\n", time); + unsigned long long time; + + time = rtc_tm_to_time64(&tm); + retval = sprintf(buf, "%llu\n", time); } return retval; @@ -132,7 +133,7 @@ wakealarm_show(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t retval; - unsigned long alarm; + unsigned long long alarm; struct rtc_wkalrm alm; /* Don't show disabled alarms. For uniformity, RTC alarms are @@ -145,8 +146,8 @@ */ retval = rtc_read_alarm(to_rtc_device(dev), &alm); if (retval == 0 && alm.enabled) { - rtc_tm_to_time(&alm.time, &alarm); - retval = sprintf(buf, "%lu\n", alarm); + alarm = rtc_tm_to_time64(&alm.time); + retval = sprintf(buf, "%llu\n", alarm); } return retval; @@ -157,8 +158,8 @@ const char *buf, size_t n) { ssize_t retval; - unsigned long now, alarm; - unsigned long push = 0; + unsigned long long now, alarm; + unsigned long long push = 0; struct rtc_wkalrm alm; struct rtc_device *rtc = to_rtc_device(dev); const char *buf_ptr; @@ -170,7 +171,7 @@ retval = rtc_read_time(rtc, &alm.time); if (retval < 0) return retval; - rtc_tm_to_time(&alm.time, &now); + now = rtc_tm_to_time64(&alm.time); buf_ptr = buf; if (*buf_ptr == '+') { @@ -181,7 +182,7 @@ } else adjust = 1; } - retval = kstrtoul(buf_ptr, 0, &alarm); + retval = kstrtoull(buf_ptr, 0, &alarm); if (retval) return retval; if (adjust) { @@ -197,7 +198,7 @@ return retval; if (alm.enabled) { if (push) { - rtc_tm_to_time(&alm.time, &push); + push = rtc_tm_to_time64(&alm.time); alarm += push; } else return -EBUSY; @@ -212,7 +213,7 @@ */ alarm = now + 300; } - rtc_time_to_tm(alarm, &alm.time); + rtc_time64_to_tm(alarm, &alm.time); retval = rtc_set_alarm(rtc, &alm); return (retval < 0) ? retval : n;