From patchwork Tue Jan 13 15:44:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 43060 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8FB1820DE8 for ; Tue, 13 Jan 2015 15:51:37 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf2379000wiw.0 for ; Tue, 13 Jan 2015 07:51:36 -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=VZl9Nv1i+RMmwqV55VIvvaqGD0I8wl5dH+Vyflyw0RA=; b=WMF94Vqs41WM/ngJzu2W08LsVCGUiWqXl8vSAVjTAD0S89Xs8/HWbaXMgtKTA2Z0Y2 SJUHIrSG69lPomAZe4cxEaCGkURN1Xzpr16Do1UIxVu8apo++hL0NarGmk9tDDcWhFcI k0/T/m/ocKyvEhC+tl1wqkTiHHx7DikxqeTJsL/EoB8Ksq1Rr9ScyVKCh7IPgI+4ZShb d1tjBKjl43cot4mJ2qM4kWqXpFmaSyqIF5LKTAJDhwHSdEvrDcxcqc8mi9R90ki5bf44 nXeImpe57B1px/XGww36JhNd734Uga/5WZPxDIiDkFYN6guw6P78/yxW4SVTYydIoyoE WPHA== X-Gm-Message-State: ALoCoQlt0RqE70AJqqPbk5Csy+8tXgKmT/3iIpRVC7qMJfJT4EIcACMQil9nFYFKmRV0wdOh9p2J X-Received: by 10.113.5.170 with SMTP id cn10mr142206lbd.21.1421164296758; Tue, 13 Jan 2015 07:51:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.11.163 with SMTP id ej3ls8340lad.94.gmail; Tue, 13 Jan 2015 07:51:36 -0800 (PST) X-Received: by 10.152.205.104 with SMTP id lf8mr37433490lac.94.1421164296546; Tue, 13 Jan 2015 07:51:36 -0800 (PST) Received: from mail-la0-x22c.google.com (mail-la0-x22c.google.com. [2a00:1450:4010:c03::22c]) by mx.google.com with ESMTPS id y9si3331667lag.8.2015.01.13.07.51.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 07:51:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22c as permitted sender) client-ip=2a00:1450:4010:c03::22c; Received: by mail-la0-f44.google.com with SMTP id gd6so3366435lab.3 for ; Tue, 13 Jan 2015 07:51:36 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr42346834lbc.23.1421164296445; Tue, 13 Jan 2015 07:51:36 -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 c8csp1422301lbb; Tue, 13 Jan 2015 07:51:35 -0800 (PST) X-Received: by 10.68.130.225 with SMTP id oh1mr52124895pbb.157.1421164294681; Tue, 13 Jan 2015 07:51:34 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ng6si27393638pdb.179.2015.01.13.07.51.33; Tue, 13 Jan 2015 07:51:34 -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 S1753224AbbAMPvc (ORCPT + 27 others); Tue, 13 Jan 2015 10:51:32 -0500 Received: from m15-111.126.com ([220.181.15.111]:38550 "EHLO m15-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbbAMPv3 (ORCPT ); Tue, 13 Jan 2015 10:51:29 -0500 Received: from vptest-PC.zte.com.cn (unknown [182.149.91.53]) by smtp1 (Coremail) with SMTP id C8mowEAZEUVxPbVUBIRpDg--.692S4; Tue, 13 Jan 2015 23:44:57 +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 1/9] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Date: Tue, 13 Jan 2015 23:44:49 +0800 Message-Id: <1421163897-8020-2-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--.692S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxZryktr1rCFyDZw13ur1fXrb_yoW5WFy3pF 47CFyjkrW7KrWfKa1kGw1kuF4rKry8Ja47KryrKa4S9r1FqF15KFn7Ar1UtF15GF97CF43 XF4Fk345uw1DG3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jyxRDUUUUU= X-Originating-IP: [182.149.91.53] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbimRiAv00vL4USOQAAsd 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::22c 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 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. Cc: John Stultz Cc: Arnd Bergmann Signed-off-by: Xunlei Pang --- drivers/rtc/interface.c | 9 ++++++++- drivers/rtc/systohc.c | 5 ++++- include/linux/rtc.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 45bfc28ee..fca7882 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -72,7 +72,12 @@ 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; + + 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 +103,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);