From patchwork Tue Jan 13 15:44:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 43061 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2EE3020DE8 for ; Tue, 13 Jan 2015 15:51:49 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf2126107wes.0 for ; Tue, 13 Jan 2015 07:51:48 -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: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=4SAj1sYAmq7SNwjTPSviU5WpwiLVV6Qtq7z9aU700IU=; b=exsws9PBMk4uHBp6RF/0o054/EcwVJQlEbFRSxdF8H8tAYGgmMoqMDsCBlTPWrm8yL nS88RqA2yzUcyhai1HPzKlXg+WxPOcg5mBPf0evfUmuZ9768dfM6CWWAGWLJ1+o7A82l AcsDY0RXJw+Uekf+FEvVt7q8MlUMJmypgIRRINYjLBlhA8ENyk4Ygmt8pJJJnxmVOIDP aTmCBexHzoG5blRE8olhBsDV00Bp7+Zoxfr4h6M+GcfoEMsWM/fR37gv/d49J72++wY+ hY979LDMSvb+iRPhvkDo2b4H//TqmhTOPTmp9EwwI3QNtzwDz4DIAGh6OVci94jjZce6 s6YQ== X-Gm-Message-State: ALoCoQnNmqNC6gT1J31gQ0XFVnyla8iZKeboZlUyxt1L9vUsNaxG0Lpvoffds4apxXQu/EV1ODBX X-Received: by 10.112.247.69 with SMTP id yc5mr1211851lbc.9.1421164308475; Tue, 13 Jan 2015 07:51:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.10 with SMTP id lc10ls13872lac.22.gmail; Tue, 13 Jan 2015 07:51:48 -0800 (PST) X-Received: by 10.112.204.233 with SMTP id lb9mr43210185lbc.43.1421164308307; Tue, 13 Jan 2015 07:51:48 -0800 (PST) Received: from mail-lb0-x22e.google.com (mail-lb0-x22e.google.com. [2a00:1450:4010:c04::22e]) by mx.google.com with ESMTPS id uh4si24657314lbb.15.2015.01.13.07.51.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 07:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) client-ip=2a00:1450:4010:c04::22e; Received: by mail-lb0-f174.google.com with SMTP id 10so3266419lbg.5 for ; Tue, 13 Jan 2015 07:51:48 -0800 (PST) X-Received: by 10.152.115.146 with SMTP id jo18mr43556537lab.9.1421164308164; Tue, 13 Jan 2015 07:51:48 -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 c8csp1422364lbb; Tue, 13 Jan 2015 07:51:47 -0800 (PST) X-Received: by 10.68.219.231 with SMTP id pr7mr51745795pbc.73.1421164306105; Tue, 13 Jan 2015 07:51:46 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si27592647pap.38.2015.01.13.07.51.45; Tue, 13 Jan 2015 07:51:46 -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 S1753241AbbAMPvi (ORCPT + 27 others); Tue, 13 Jan 2015 10:51:38 -0500 Received: from m15-111.126.com ([220.181.15.111]:38593 "EHLO m15-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbbAMPvf (ORCPT ); Tue, 13 Jan 2015 10:51:35 -0500 Received: from vptest-PC.zte.com.cn (unknown [182.149.91.53]) by smtp1 (Coremail) with SMTP id C8mowEAZEUVxPbVUBIRpDg--.692S10; Tue, 13 Jan 2015 23:45:01 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org, John Stultz , Arnd Bergmann Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , Xunlei Pang Subject: [RFC PATCH v2 7/9] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t Date: Tue, 13 Jan 2015 23:44:55 +0800 Message-Id: <1421163897-8020-8-git-send-email-xlpang@126.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1421163897-8020-1-git-send-email-xlpang@126.com> References: <1421163897-8020-1-git-send-email-xlpang@126.com> X-CM-TRANSID: C8mowEAZEUVxPbVUBIRpDg--.692S10 X-Coremail-Antispam: 1Uf129KBjvJXoWxZFy7ur1UKw4xtw48Wry5twb_yoW5KFW5pF 47GayrtFWktFyagw18Crsrur4rKw18tayIq3Z3J34S9r1rJrykKF95Kry0yrWrKaykG3Zx J3WrZFyFvw4UWF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j-WrXUUUUU= X-Originating-IP: [182.149.91.53] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbirwGAv0X9vn1ScQAAsJ 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:c04::22e 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 We want to convert mxc_rtc_set_mmss() to use rtc_class_ops's set_mmss64(), but it uses get_alarm_or_time()/set_alarm_or_time() internal interfaces which are y2038 unsafe. So here as a separate patch, it converts these two internal interfaces of "mxc" to use safe time64_t to make some preparations. Signed-off-by: Xunlei Pang --- drivers/rtc/rtc-mxc.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index a7b218f..83cba23 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c @@ -106,7 +106,7 @@ static inline int is_imx1_rtc(struct rtc_plat_data *data) * This function is used to obtain the RTC time or the alarm value in * second. */ -static u32 get_alarm_or_time(struct device *dev, int time_alarm) +static time64_t get_alarm_or_time(struct device *dev, int time_alarm) { struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); @@ -129,29 +129,28 @@ static u32 get_alarm_or_time(struct device *dev, int time_alarm) hr = hr_min >> 8; min = hr_min & 0xff; - return (((day * 24 + hr) * 60) + min) * 60 + sec; + return ((((time64_t)day * 24 + hr) * 60) + min) * 60 + sec; } /* * This function sets the RTC alarm value or the time value. */ -static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time) +static void set_alarm_or_time(struct device *dev, int time_alarm, time64_t time) { - u32 day, hr, min, sec, temp; + u32 tod, day, hr, min, sec, temp; struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; - day = time / 86400; - time -= day * 86400; + day = div_s64_rem(time, 86400, &tod); /* time is within a day now */ - hr = time / 3600; - time -= hr * 3600; + hr = tod / 3600; + tod -= hr * 3600; /* time is within an hour now */ - min = time / 60; - sec = time - min * 60; + min = tod / 60; + sec = tod - min * 60; temp = (hr << 8) + min; @@ -175,12 +174,12 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time) */ static void rtc_update_alarm(struct device *dev, struct rtc_time *alrm) { - unsigned long time; + time64_t time; struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; - rtc_tm_to_time(alrm, &time); + time = rtc_tm_to_time64(alrm); /* clear all the interrupt status bits */ writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR); @@ -272,14 +271,14 @@ static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) */ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) { - u32 val; + time64_t val; /* Avoid roll-over from reading the different registers */ do { val = get_alarm_or_time(dev, MXC_RTC_TIME); } while (val != get_alarm_or_time(dev, MXC_RTC_TIME)); - rtc_time_to_tm(val, tm); + rtc_time64_to_tm(val, tm); return 0; } @@ -322,7 +321,7 @@ static int mxc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; - rtc_time_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time); + rtc_time64_to_tm(get_alarm_or_time(dev, MXC_RTC_ALARM), &alrm->time); alrm->pending = ((readw(ioaddr + RTC_RTCISR) & RTC_ALM_BIT)) ? 1 : 0; return 0;