From patchwork Tue Jan 20 16:21:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43414 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 6D34F2034D for ; Tue, 20 Jan 2015 16:24:17 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf6529413wev.0 for ; Tue, 20 Jan 2015 08:24: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: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=pWyK15tKGYw2XUuBqawQaVxVVMvpstLxa6NZHm0IdcA=; b=kaeIpCu8BedH2w0xUhwEIfGvOEXFPIy2veoucRjx3xk9gMqcVDlYRzHKP+nExi7KzQ ckNFUs1uj2qxAVNjSCf7VJPapBTw1ww7Uh0MZ+yY2kYCIZ7b/dBlJuw9qD4unLZ6F/+u ogTP2Quw884JszzqDqeGqpZxR/4oFn9BWHOEMp4/kmIyVu3Dnz0HYEmuDiaIykeekOOV 6IqONju9ren1CuODcvbMyjT9sZzwxF3mOxABC8IYs9m9nEZgcqsjQHx/OSRviiXw/wgp v9ykGT3VGKOznrZt4E32Nh/tObZYi56J0dcs/hD2iuqjnCSn0EbAyzUmclZaNgvXHSqN fEtQ== X-Gm-Message-State: ALoCoQkGySCLUVAIPfzm9jkXOK0+PcGue62WGlASsV7XP0lBjZPKtxeQn27DXvKRwFZgcMJ8equv X-Received: by 10.113.5.170 with SMTP id cn10mr23955lbd.21.1421771056673; Tue, 20 Jan 2015 08:24:16 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.205 with SMTP id q13ls236408lal.85.gmail; Tue, 20 Jan 2015 08:24:16 -0800 (PST) X-Received: by 10.152.228.133 with SMTP id si5mr9373299lac.96.1421771056441; Tue, 20 Jan 2015 08:24:16 -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 as5si7656765lac.38.2015.01.20.08.24.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 08:24:16 -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 z12so13805995lbi.7 for ; Tue, 20 Jan 2015 08:24:16 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr38818879lbc.23.1421771056287; Tue, 20 Jan 2015 08:24:16 -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 c8csp1473607lbb; Tue, 20 Jan 2015 08:24:15 -0800 (PST) X-Received: by 10.66.120.47 with SMTP id kz15mr55133349pab.71.1421771054421; Tue, 20 Jan 2015 08:24:14 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rm3si4979997pbc.142.2015.01.20.08.24.13; Tue, 20 Jan 2015 08:24:14 -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 S1754241AbbATQYK (ORCPT + 28 others); Tue, 20 Jan 2015 11:24:10 -0500 Received: from mail-qa0-f52.google.com ([209.85.216.52]:39394 "EHLO mail-qa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752180AbbATQWT (ORCPT ); Tue, 20 Jan 2015 11:22:19 -0500 Received: by mail-qa0-f52.google.com with SMTP id x12so28768258qac.11 for ; Tue, 20 Jan 2015 08:22:18 -0800 (PST) X-Received: by 10.224.89.2 with SMTP id c2mr58853875qam.75.1421770938357; Tue, 20 Jan 2015 08:22:18 -0800 (PST) Received: from ip-10-181-65-231.ec2.internal ([54.235.93.228]) by mx.google.com with ESMTPSA id o34sm15633515qge.29.2015.01.20.08.22.17 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 08:22:17 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , Richard Henderson , Uwe Kleine-Koenig , Linus Walleij , Fabio Estevam , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [RFC PATCH v3 1/8] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Date: Tue, 20 Jan 2015 16:21:32 +0000 Message-Id: <1421770899-4136-2-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1421770899-4136-1-git-send-email-pang.xunlei@linaro.org> References: <1421770899-4136-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: , Currently the rtc_class_op's set_mmss() function takes a 32bit second value (on 32bit systems), which is problematic for dates past y2038. This patch provides a safe version named set_mmss64() using y2038 safe time64_t. After this patch, set_mmss() is deprecated and all its users will be fixed to use set_mmss64(), it can be removed when having no users. Signed-off-by: Xunlei Pang --- drivers/rtc/interface.c | 7 ++++++- drivers/rtc/systohc.c | 5 ++++- include/linux/rtc.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 45bfc28ee..db44df8 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -72,7 +72,10 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) err = -ENODEV; else if (rtc->ops->set_time) err = rtc->ops->set_time(rtc->dev.parent, tm); - else if (rtc->ops->set_mmss) { + else if (rtc->ops->set_mmss64) { + 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) @@ -98,6 +101,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) if (!rtc->ops) err = -ENODEV; + else if (rtc->ops->set_mmss64) + err = rtc->ops->set_mmss64(rtc->dev.parent, secs); else if (rtc->ops->set_mmss) err = rtc->ops->set_mmss(rtc->dev.parent, secs); else if (rtc->ops->read_time && rtc->ops->set_time) { diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index bf3e242..e34a07b 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -35,7 +35,10 @@ int rtc_set_ntp_time(struct timespec now) if (rtc) { /* rtc_hctosys exclusively uses UTC, so we call set_time here, * not set_mmss. */ - if (rtc->ops && (rtc->ops->set_time || rtc->ops->set_mmss)) + if (rtc->ops && + (rtc->ops->set_time || + rtc->ops->set_mmss64 || + rtc->ops->set_mmss)) err = rtc_set_time(rtc, &tm); rtc_class_close(rtc); } diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 6d6be09..29093da 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -77,6 +77,7 @@ struct rtc_class_ops { int (*read_alarm)(struct device *, struct rtc_wkalrm *); int (*set_alarm)(struct device *, struct rtc_wkalrm *); int (*proc)(struct device *, struct seq_file *); + int (*set_mmss64)(struct device *, time64_t secs); int (*set_mmss)(struct device *, unsigned long secs); int (*read_callback)(struct device *, int data); int (*alarm_irq_enable)(struct device *, unsigned int enabled);