From patchwork Thu Jan 22 02:31:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43483 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 34F82240D5 for ; Thu, 22 Jan 2015 02:32:17 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf3248756wgg.0 for ; Wed, 21 Jan 2015 18:32:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=RwXUoO3Rnxrj6R6MX9gutxjeHT9BAEikirMpyg3w25A=; b=OD3821x+8IXjYYsCbyrgFsyoR88HfXHMPUfQU8yu0pXaQsqE1stqOFvwD76gVKEkp+ HANcHAw981tlfDSGaQOxOh5GZD+mdbgNsCZQUgnD+RTnT9T/jzX9zahIbK1pcu2z1O3S 6d/hxATdeIDgqc1i3gpL/NHrHo6yIOQd6jsSQbuXV3sUzLc5xBGV+tWk2KwlIbd7FUy5 PvhBXCWpjWU+Ei6vOUXbTvnEZ6Pz/kMQw/V6KqSyTM6snlV698qBrcvATh5tdlSsyCiv 88GED46yqoLgicmXwx71HxsHcgd5RZHIsaBS4NNzeJ5v6IDQmR/VpuBfU2AULAocez0u XbUQ== X-Gm-Message-State: ALoCoQm5KVcV9VxQ0lsn+ZPPdNjIer3jJdShL60SwPf8sn3besb12G3fiBek2c3Bx3DnPXcz1ik2 X-Received: by 10.152.43.50 with SMTP id t18mr1567350lal.3.1421893936396; Wed, 21 Jan 2015 18:32:16 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.137 with SMTP id 9ls104891lau.26.gmail; Wed, 21 Jan 2015 18:32:16 -0800 (PST) X-Received: by 10.152.44.193 with SMTP id g1mr26509999lam.15.1421893936153; Wed, 21 Jan 2015 18:32:16 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id kw4si147379lac.133.2015.01.21.18.32.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 18:32:15 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so19248538lbv.8 for ; Wed, 21 Jan 2015 18:32:15 -0800 (PST) X-Received: by 10.152.234.35 with SMTP id ub3mr47865238lac.70.1421893935698; Wed, 21 Jan 2015 18:32:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp109856lbb; Wed, 21 Jan 2015 18:32:14 -0800 (PST) X-Received: by 10.68.239.4 with SMTP id vo4mr33640598pbc.14.1421893933841; Wed, 21 Jan 2015 18:32:13 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xq8si10990124pab.11.2015.01.21.18.32.12; Wed, 21 Jan 2015 18:32:13 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754544AbbAVCcK (ORCPT + 28 others); Wed, 21 Jan 2015 21:32:10 -0500 Received: from mail-qc0-f179.google.com ([209.85.216.179]:47035 "EHLO mail-qc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753316AbbAVCcH (ORCPT ); Wed, 21 Jan 2015 21:32:07 -0500 Received: by mail-qc0-f179.google.com with SMTP id w7so18978264qcr.10 for ; Wed, 21 Jan 2015 18:32:06 -0800 (PST) X-Received: by 10.140.94.6 with SMTP id f6mr28116200qge.38.1421893926260; Wed, 21 Jan 2015 18:32:06 -0800 (PST) Received: from ip-10-181-65-231.ec2.internal ([54.235.93.228]) by mx.google.com with ESMTPSA id w9sm5174891qab.18.2015.01.21.18.32.05 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 18:32:05 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [PATCH 1/5] drivers/rtc/interface.c: Update code to use y2038-safe time interfaces Date: Thu, 22 Jan 2015 02:31:51 +0000 Message-Id: <1421893915-19309-1-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently, interface.c uses y2038 problematic rtc_tm_to_time() and rtc_time_to_tm(). So replace them with their corresponding y2038-safe versions: rtc_tm_to_time64() and rtc_time64_to_tm(). Reviewed-by: John Stultz Reviewed-by: Arnd Bergmann Signed-off-by: Xunlei Pang --- drivers/rtc/interface.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index db44df8..c6be2bb 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -76,10 +76,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) time64_t secs64 = rtc_tm_to_time64(tm); err = rtc->ops->set_mmss64(rtc->dev.parent, secs64); } else if (rtc->ops->set_mmss) { - unsigned long secs; - err = rtc_tm_to_time(tm, &secs); - if (err == 0) - err = rtc->ops->set_mmss(rtc->dev.parent, secs); + time64_t secs64 = rtc_tm_to_time64(tm); + err = rtc->ops->set_mmss(rtc->dev.parent, secs64); } else err = -EINVAL; @@ -110,7 +108,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) err = rtc->ops->read_time(rtc->dev.parent, &old); if (err == 0) { - rtc_time_to_tm(secs, &new); + rtc_time64_to_tm(secs, &new); /* * avoid writing when we're going to change the day of @@ -162,7 +160,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) int err; struct rtc_time before, now; int first_time = 1; - unsigned long t_now, t_alm; + time64_t t_now, t_alm; enum { none, day, month, year } missing = none; unsigned days; @@ -263,8 +261,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) } /* with luck, no rollover is needed */ - rtc_tm_to_time(&now, &t_now); - rtc_tm_to_time(&alarm->time, &t_alm); + t_now = rtc_tm_to_time64(&now); + t_alm = rtc_tm_to_time64(&alarm->time); if (t_now < t_alm) goto done; @@ -278,7 +276,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) case day: dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); t_alm += 24 * 60 * 60; - rtc_time_to_tm(t_alm, &alarm->time); + rtc_time64_to_tm(t_alm, &alarm->time); break; /* Month rollover ... if it's the 31th, an alarm on the 3rd will @@ -351,19 +349,19 @@ EXPORT_SYMBOL_GPL(rtc_read_alarm); static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) { struct rtc_time tm; - long now, scheduled; + time64_t now, scheduled; int err; err = rtc_valid_tm(&alarm->time); if (err) return err; - rtc_tm_to_time(&alarm->time, &scheduled); + scheduled = rtc_tm_to_time64(&alarm->time); /* Make sure we're not setting alarms in the past */ err = __rtc_read_time(rtc, &tm); if (err) return err; - rtc_tm_to_time(&tm, &now); + now = rtc_tm_to_time64(&tm); if (scheduled <= now) return -ETIME; /*