From patchwork Wed Apr 15 09:20:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 47165 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 58DA120553 for ; Wed, 15 Apr 2015 09:21:55 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf8248436wgt.1 for ; Wed, 15 Apr 2015 02:21:54 -0700 (PDT) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=nPqQe9EOUPyJWGG95gIYOXTLZiyXpu8ANgperAmK/4A=; b=HaU/CffHgkLA0j7laLRcGh9qK0Vs1Ze5C9HGV1EbMTJ2StbcD+EoPoESRq7VuQZ2B0 kEz+rvE2kCP5MWqf5b5Pa77ALrFJoRpn1IclcoctvfZfoz9YP+vLn2ea7PZi9yf6/5Cn VFSsu56IZCgaeSpY3VVXQVgyM7Pt9SZhBNX/9f5Hmu1rlQJ7fcy+R7OaCq5MRttSZUrt icRXwSdVXyW/oJfxgFZtgFdVyFMadNxt6x7PunGHGb5scVDH4EAOxZwKZKISuSkmGaRa JxTxn8sZJoCs5kDh07POT5Qz53THiBwx26gDRvVPpUctZpsgDRGPXyYR26UBcJoTiIXn bfCQ== X-Gm-Message-State: ALoCoQl00nrHpP8yEwNfVKAUtuTDnVA2k9kXKJ+4dE6Yd9mve2GdotOvcebMLd+5lNaE+TVC0hCG X-Received: by 10.180.101.39 with SMTP id fd7mr4344444wib.0.1429089714689; Wed, 15 Apr 2015 02:21:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.225 with SMTP id z1ls163662lad.109.gmail; Wed, 15 Apr 2015 02:21:54 -0700 (PDT) X-Received: by 10.113.11.12 with SMTP id ee12mr22680155lbd.5.1429089714371; Wed, 15 Apr 2015 02:21:54 -0700 (PDT) Received: from mail-la0-x235.google.com (mail-la0-x235.google.com. [2a00:1450:4010:c03::235]) by mx.google.com with ESMTPS id f3si3389971lam.36.2015.04.15.02.21.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2015 02:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::235 as permitted sender) client-ip=2a00:1450:4010:c03::235; Received: by labbd9 with SMTP id bd9so27984798lab.2 for ; Wed, 15 Apr 2015 02:21:54 -0700 (PDT) X-Received: by 10.112.160.227 with SMTP id xn3mr22468248lbb.112.1429089713950; Wed, 15 Apr 2015 02:21:53 -0700 (PDT) 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.67.65 with SMTP id l1csp2383175lbt; Wed, 15 Apr 2015 02:21:53 -0700 (PDT) X-Received: by 10.68.138.230 with SMTP id qt6mr44960606pbb.66.1429089712041; Wed, 15 Apr 2015 02:21:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id eo2si6117157pbc.117.2015.04.15.02.21.50; Wed, 15 Apr 2015 02:21:52 -0700 (PDT) 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 S1754616AbbDOJVj (ORCPT + 27 others); Wed, 15 Apr 2015 05:21:39 -0400 Received: from m15-111.126.com ([220.181.15.111]:45082 "EHLO m15-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752981AbbDOJVR (ORCPT ); Wed, 15 Apr 2015 05:21:17 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp1 (Coremail) with SMTP id C8mowEDJuURQLS5VuDFEAA--.7421S4; Wed, 15 Apr 2015 17:20:28 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , John Stultz , Arnd Bergmann , Xunlei Pang , Carlo Caione Subject: [PATCH 3/5] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time() Date: Wed, 15 Apr 2015 17:20:09 +0800 Message-Id: <1429089611-29776-3-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429089611-29776-1-git-send-email-xlpang@126.com> References: <1429089611-29776-1-git-send-email-xlpang@126.com> X-CM-TRANSID: C8mowEDJuURQLS5VuDFEAA--.7421S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7WF45Kr1xurW3tFyfXr4fKrg_yoW5Jr48pF 43ta43XrWqqryagryxArs3ZFy5W3WUJ3yxtwsIq3yF9an8JFn8JF1kCrykKry5JFykAay3 JFWrJa45Wa4UKw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jdvtAUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiWxvcv1PM78qp8wABsC Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com 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: , From: Xunlei Pang sunxi_rtc_setalarm() uses deprecated rtc_tm_to_time(), which will overflow in year 2106 on 32-bit machines. This patch solves this by: - Replacing rtc_tm_to_time() with rtc_tm_to_time64() Also remove the unnecessary initial zeroing of some local variables in sunxi_rtc_setalarm(). Cc: Carlo Caione Signed-off-by: Xunlei Pang --- drivers/rtc/rtc-sunxi.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c index 6e678fa..7f22753 100644 --- a/drivers/rtc/rtc-sunxi.c +++ b/drivers/rtc/rtc-sunxi.c @@ -269,14 +269,13 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm) struct sunxi_rtc_dev *chip = dev_get_drvdata(dev); struct rtc_time *alrm_tm = &wkalrm->time; struct rtc_time tm_now; - u32 alrm = 0; - unsigned long time_now = 0; - unsigned long time_set = 0; - unsigned long time_gap = 0; - unsigned long time_gap_day = 0; - unsigned long time_gap_hour = 0; - unsigned long time_gap_min = 0; - int ret = 0; + u32 alrm; + time64_t time_set, time_now; + unsigned long time_gap; + unsigned long time_gap_day; + unsigned long time_gap_hour; + unsigned long time_gap_min; + int ret; ret = sunxi_rtc_gettime(dev, &tm_now); if (ret < 0) { @@ -284,13 +283,18 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm) return -EINVAL; } - rtc_tm_to_time(alrm_tm, &time_set); - rtc_tm_to_time(&tm_now, &time_now); + time_set = rtc_tm_to_time64(alrm_tm); + time_now = rtc_tm_to_time64(&tm_now); if (time_set <= time_now) { dev_err(dev, "Date to set in the past\n"); return -EINVAL; } + if (time_set > time_now + 255 * SEC_IN_DAY) { + dev_err(dev, "Day must be in the range 0 - 255\n"); + return -EINVAL; + } + time_gap = time_set - time_now; time_gap_day = time_gap / SEC_IN_DAY; time_gap -= time_gap_day * SEC_IN_DAY; @@ -299,11 +303,6 @@ static int sunxi_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm) time_gap_min = time_gap / SEC_IN_MIN; time_gap -= time_gap_min * SEC_IN_MIN; - if (time_gap_day > 255) { - dev_err(dev, "Day must be in the range 0 - 255\n"); - return -EINVAL; - } - sunxi_rtc_setaie(0, chip); writel(0, chip->base + SUNXI_ALRM_DHMS); usleep_range(100, 300);