From patchwork Thu Nov 9 07:09:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 118382 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6243881qgn; Wed, 8 Nov 2017 23:09:49 -0800 (PST) X-Google-Smtp-Source: ABhQp+R8SDP1r42cuxMw8KSlecddfg99Zxj6oXFszJ2CgIPb60SgUgs5tmnXwyUUrpykD8YD9Is4 X-Received: by 10.84.195.36 with SMTP id i33mr3034073pld.38.1510211389555; Wed, 08 Nov 2017 23:09:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510211389; cv=none; d=google.com; s=arc-20160816; b=OkYOpTIkbnCRpLDkwy6nz+KdKt4meEItPqabhPHohhxnhiHFI9WmTsabHEeIJsHAAH IIwoSzRNt6MP8txC/7z9yPQrAaFLTmxaygivvB/auUuN2Vs1Phz5jMbFR3yQaDx9KKuh 1+4ownxyHAFNv16nz8M38zYdF5INPksojo4M7rx7QhSCBHSqX9pvsS5njRsoST7buXU0 fGlc5WvQGaVVt1tGJkPwda5A5bWaixTkcTR/wB5VsKvqrS154vBeLLlu7kUnJFE3mz8/ S36bdJxk11UKpjiI3Be9kTt27a6/22lrGuHOWrFhKWOujiXiFHbzPwfjkvMa3d59KBOi IJRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XNuCxCsMp6LG/Xl2LcOCsRLJgQOKImZ+NyjaBErsEOA=; b=P0JEo7VdbemY/JuLPzHhym7ArOI8E1T72xJVKnJ8CHL7BMBqqrmPM0MB0Pw2FlIm3m uJqFfc9JjPK9oC2sNYnOBrCHzSVZAWTqqBzfjK9YC6x4t7rKMIU1eiMZvX3VuexP5KSu A6WN501wd2ins2U7ETgGG7taOgrT84nFrA9SAESIfPftQFYCGTn/CF/l/ZxFG+SsKUC/ 5nwKOYN3seey0Wsm7fFnjfgMoYaSRdC712gPywmCSpYlGofzezT84PGwPRlgW5w+/rw7 Xgkc//wjBWvM0+k2hyLR+2CyWtsUEXro5Fp0mtHg0YZMuDBBXRKRoDO+GlQ2ARZ4X/EL OhGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eu/fCazj; 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 1si5476759plx.498.2017.11.08.23.09.49; Wed, 08 Nov 2017 23:09:49 -0800 (PST) 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.s=google header.b=eu/fCazj; 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 S1752713AbdKIHJr (ORCPT + 24 others); Thu, 9 Nov 2017 02:09:47 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:56869 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbdKIHJo (ORCPT ); Thu, 9 Nov 2017 02:09:44 -0500 Received: by mail-pg0-f65.google.com with SMTP id m18so3979260pgd.13 for ; Wed, 08 Nov 2017 23:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=XNuCxCsMp6LG/Xl2LcOCsRLJgQOKImZ+NyjaBErsEOA=; b=eu/fCazjpg+IxtOX68VPdw2Vyy/9ocWdekNX2YpsqWGWpudFZ0ZSurp4vGvlOJQaPu RUZFnjqL6SLL2EXXsNYQgUs1G33IXSouOidw5EfWpB8kGl/0p0m99PnyAmtwcfjj3ZDS 40IaivQbOAFv3iyio7USdzjBVOXURVDGkLlAs= 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; bh=XNuCxCsMp6LG/Xl2LcOCsRLJgQOKImZ+NyjaBErsEOA=; b=I/5+aqqydS2bx2N+g99e4b2xIeDK6Uqlu0EnzlU6AXdOxxkcUc9Lh+AhIjdHPbjg5C FmT682OvRO7hV7yFikKNChOKaiSpKAFoi3SuqTJY5U6cOWKmXhbRoJ/g1rlfG3ZWFRzJ Uxgbz1vNEm69J0RKt4TtwJrHtbU3xkvZjZfGDy9SivtsQK8/meBonlvQrYlyzXo3S7vP /MinQ7eEmV4pSPX5HQDmrTvHvyNdQjzZaM6z2Te7fErqHH3U52j0wJy6w2QlxwXYrjVa yj4SSd3/UgdQVfO1TKMEJw5VhB3+mHJuCGVjd7dRznSIBQtsFmh0Bp7Hi3MbB9L4Y79q rntw== X-Gm-Message-State: AJaThX4f3zGbWGWX4WbGJmUbwLH8h/2N1yHjwttRDE2VeN9l/uwUkkeI mOphhvEzq5tI3eFUGZAehmlWog== X-Received: by 10.101.65.75 with SMTP id x11mr2940018pgp.388.1510211383928; Wed, 08 Nov 2017 23:09:43 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id g80sm2211524pfd.87.2017.11.08.23.09.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 23:09:43 -0800 (PST) From: Baolin Wang To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH] rtc: Use time64_t variables to set time/alarm from sysfs Date: Thu, 9 Nov 2017 15:09:20 +0800 Message-Id: <672d468478f3f67ef22e027460c59918dc581818.1510211132.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use time64_t variables and related APIs for sysfs interfaces to support setting time or alarm after the year 2038 on 32-bit system. Signed-off-by: Baolin Wang --- drivers/rtc/rtc-sysfs.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) -- 1.7.9.5 Reviewed-by: Arnd Bergmann diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index e364550..92ff2ed 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); + time64_t time; + + time = rtc_tm_to_time64(&tm); + retval = sprintf(buf, "%lld\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; + time64_t 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, "%lld\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; + time64_t now, alarm; + time64_t 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 = kstrtos64(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;