From patchwork Thu Nov 27 12:02:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 41614 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D6DBA244C2 for ; Thu, 27 Nov 2014 12:03:31 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf2964333lab.0 for ; Thu, 27 Nov 2014 04:03:30 -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=1+xCy1mihvwgklbn9Bhr1eR92vVDhBZAxbQqd+ALoa8=; b=eX0UGEU2cqo/PtgborKu3ACouqcyXgD0EXV+a8WKpOmcgtdDzhNU8up+R650Xe+DbG eStLbjKn5v++vIrsOF4b6e/dPNajdHbxjy8KQzJvRY7kH7h3SFU7TQ0TtDjWToneeWiq phI8565vJ+0OH+4xLeiq04F97PkBGetSsAccvbh9gliutbly5O9MF5D7hwwe75i7nrjm 1+kKPgO+L8PYNuCjtgEyd9Gwd6GBOrIFatdnMVRdGZ+wRxTOxp904SqlBW9GtKW2a5sk eLFRlzyIGd8iM4ifxW+ZTSfkPjI2yhrp6mC3Dyx+2GaCyzONNxeOvEYLuMVECm0tg0LM XG6g== X-Gm-Message-State: ALoCoQmKkKHXMSy1xY2c1dsHQMJMNquZrVxXpxd9zA1QLMYYKtnr4rMY/ZP599BeaxS4Ush7m/JF X-Received: by 10.112.142.36 with SMTP id rt4mr10558393lbb.3.1417089810496; Thu, 27 Nov 2014 04:03:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.9 with SMTP id w9ls851468law.1.gmail; Thu, 27 Nov 2014 04:03:30 -0800 (PST) X-Received: by 10.152.120.73 with SMTP id la9mr39071986lab.23.1417089810112; Thu, 27 Nov 2014 04:03:30 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id r10si7062875lbc.100.2014.11.27.04.03.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 04:03:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id p9so4116520lbv.35 for ; Thu, 27 Nov 2014 04:03:30 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr38124623laj.67.1417089809997; Thu, 27 Nov 2014 04:03:29 -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.184.201 with SMTP id ew9csp786877lbc; Thu, 27 Nov 2014 04:03:29 -0800 (PST) X-Received: by 10.66.232.70 with SMTP id tm6mr63883655pac.120.1417089808236; Thu, 27 Nov 2014 04:03:28 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ig1si11277181pad.111.2014.11.27.04.03.27 for ; Thu, 27 Nov 2014 04:03:28 -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 S1754826AbaK0MDY (ORCPT + 26 others); Thu, 27 Nov 2014 07:03:24 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:62969 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754120AbaK0MDU (ORCPT ); Thu, 27 Nov 2014 07:03:20 -0500 Received: by mail-pa0-f53.google.com with SMTP id kq14so4911723pab.12 for ; Thu, 27 Nov 2014 04:03:20 -0800 (PST) X-Received: by 10.70.137.68 with SMTP id qg4mr62976004pdb.150.1417089800455; Thu, 27 Nov 2014 04:03:20 -0800 (PST) Received: from wangdeqiang.com ([210.21.223.3]) by mx.google.com with ESMTPSA id cf12sm6955128pdb.77.2014.11.27.04.03.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 04:03:19 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , Sven Schnelle , Xunlei Pang , John Stultz , Arnd Bergmann Subject: [RFC PATCH 1/4] rtc/mxc: Convert get_alarm_or_time()/set_alarm_or_time() to use time64_t Date: Thu, 27 Nov 2014 20:02:37 +0800 Message-Id: <1417089760-26848-2-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1417089760-26848-1-git-send-email-pang.xunlei@linaro.org> References: <1417089760-26848-1-git-send-email-pang.xunlei@linaro.org> 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.176 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: , We want to convert y2038 unsafe rtc_class_ops.set_mmss() and all its users to use time64_t. mxc_rtc_set_mmss() in "mxc" driver is one of its users, but it uses get_alarm_or_time()/set_alarm_or_time() internal interfaces which are also y2038 unsafe. So here as a separate patch, it converts these two internal interfaces of "mxc" to use safe time64_t first, so as to make some preparations for the rtc_class_ops.set_mmss() conversion. Currently, "mxc" is the only driver with such issue. Cc: John Stultz Cc: Arnd Bergmann Signed-off-by: Xunlei Pang --- drivers/rtc/rtc-mxc.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 419874f..07bff34 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; @@ -176,20 +175,20 @@ static void set_alarm_or_time(struct device *dev, int time_alarm, u32 time) static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm) { struct rtc_time alarm_tm, now_tm; - unsigned long now, time; + time64_t now, time; struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; now = get_alarm_or_time(dev, MXC_RTC_TIME); - rtc_time_to_tm(now, &now_tm); + rtc_time64_to_tm(now, &now_tm); alarm_tm.tm_year = now_tm.tm_year; alarm_tm.tm_mon = now_tm.tm_mon; alarm_tm.tm_mday = now_tm.tm_mday; alarm_tm.tm_hour = alrm->tm_hour; alarm_tm.tm_min = alrm->tm_min; alarm_tm.tm_sec = alrm->tm_sec; - rtc_tm_to_time(&alarm_tm, &time); + time = rtc_tm_to_time64(&alarm_tm); /* clear all the interrupt status bits */ writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR); @@ -283,14 +282,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; } @@ -333,7 +332,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;