From patchwork Fri May 29 15:04:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49225 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 622BC22B38 for ; Fri, 29 May 2015 15:07:06 +0000 (UTC) Received: by lbbti3 with SMTP id ti3sf19880173lbb.1 for ; Fri, 29 May 2015 08:07:05 -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=MegCAI2JgwwV1zPxoHJRRuVrgY0Yz02h62u/0WbXfxGHOLGxl0F53TNGN8HRmEMb0n lLidGPUs7RS/TcY1deuB+shAeqxK9JOCWl2zWiu4iADJJzdky9e9DU3yJlZaHjrVV1Wl gwaSG1mZFZxHaodHYppxLEsn2XXy7NmoPGRFOLv+jaHHaWkmOZejBNmF1EgmwTI7k0Yn cT0oIdQ3sU3sck5mNj/fR8S4WJy3Ttlb0GiBL5iee3Iq+5PTiHRWYprmiz0PUKS884k2 am1ykbT8NpdQ0h3cGqL1KhQ7Wkbo6eT66I7uPQtnuO9xdCEKwToGKZ2ZUGuh5h7MIg2u IgvQ== X-Gm-Message-State: ALoCoQn5pro3B0KSJOdo7+kB5RXBTjj3mw+8hjWnd1W/sAwpPgWorxalwH1KskFm2vHd3nmywSM8 X-Received: by 10.112.138.2 with SMTP id qm2mr7610084lbb.19.1432912024071; Fri, 29 May 2015 08:07:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.65 with SMTP id yg1ls324667lab.26.gmail; Fri, 29 May 2015 08:07:03 -0700 (PDT) X-Received: by 10.112.150.130 with SMTP id ui2mr8499986lbb.116.1432912023896; Fri, 29 May 2015 08:07:03 -0700 (PDT) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com. [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id y8si4879008laj.161.2015.05.29.08.07.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 08:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by laat2 with SMTP id t2so58005520laa.1 for ; Fri, 29 May 2015 08:07:03 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr8338494lbb.29.1432912023522; Fri, 29 May 2015 08:07:03 -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.108.230 with SMTP id hn6csp408021lbb; Fri, 29 May 2015 08:07:02 -0700 (PDT) X-Received: by 10.68.167.66 with SMTP id zm2mr15892585pbb.164.1432912021671; Fri, 29 May 2015 08:07:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id br5si6926835pdb.256.2015.05.29.08.07.00; Fri, 29 May 2015 08:07:01 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756657AbbE2PGx (ORCPT + 28 others); Fri, 29 May 2015 11:06:53 -0400 Received: from m50-111.126.com ([123.125.50.111]:33435 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756224AbbE2PGS (ORCPT ); Fri, 29 May 2015 11:06:18 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowAAHBg8LgGhVo1v_AA--.164S4; Fri, 29 May 2015 23:04:52 +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 RESEND 3/3] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time() Date: Fri, 29 May 2015 23:04:37 +0800 Message-Id: <1432911877-607-3-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432911877-607-1-git-send-email-xlpang@126.com> References: <1432911877-607-1-git-send-email-xlpang@126.com> X-CM-TRANSID: jtKowAAHBg8LgGhVo1v_AA--.164S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7WF45Kr1xurW3tFyfXr4fKrg_yoW5Jr48pF 43ta43XrWqqryagryxArs3ZFy5W3WUJ3yxtwsIq3yF9an8JFn8JF1kCrykKry5JFykAay3 JFWrJa45Wa4UKw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jdvtAUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiXBQJv1R0WZTr0wAAsr 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::229 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);