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: 431150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-ig0-x237.google.com (mail-ig0-x237.google.com [IPv6:2607:f8b0:4001:c05::237]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A85BA1402C9 for ; Wed, 21 Jan 2015 03:22:21 +1100 (AEDT) Received: by mail-ig0-f183.google.com with SMTP id hl2sf3682750igb.0 for ; Tue, 20 Jan 2015 08:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:content-type:precedence:mailing-list:list-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe; bh=jBnKS6pfuYLq3OOAq2FIfYD/q9JRYUERtZxelE5GTiU=; b=mg9ku2u1zhRSzBjxudnmK19OTA///6NEYLGOrL6UF8CN2OHr263Qziz+P0HvnzdJvr vHqjpo7+eF9j1GgHgSNagkOEAhEfylSvIyAMn4slihKXWR9IJi0XBmLaSmhYAE94Xhac 9iJcEJWykrToC7PQ4/pVLLp7SyBovo0PrdANsc2lzTvflyEysEwEJD64T+7lobi1lt6i KUrAYBMb1R0fMV/LpDjm2KmjqU2OQwlIIQWvmLwxFTvVnvxVbXJMO9ODOD4zII6Rad45 Bx4bNIrEeAu/Yr1qehcozqWN/mgH0U0uSmy6BSIyY/GJgEleZB3xbYUZLLvG2O9Thiw5 VhiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:content-type:precedence :mailing-list:list-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe; bh=jBnKS6pfuYLq3OOAq2FIfYD/q9JRYUERtZxelE5GTiU=; b=R618BWtWGwtEh/Rw/E7RPf0bInIx3PVOCrPv17iIln5TjBr5LPWpfWxkyxoWwaDDbp wED7inEB4jgG1syUgce2P67W+hTSZnssWu3jiglwxqLQkZf9ZE0nnaYJvZxWy9PcOXI/ sRD4I4n39cdxZw3TItsZUUe6Xx45bN1yZTNhAaOf1hwI0M+yJcy8cuvmKm6SvI73MYAy CAb21MjE1Kl8tr/kBmi/i/vSyg+YaMJIP6K4Ro970taRl59k5ObsIM1DYqZFspIEuszF AeLMJW7gec2CxZnEY4vsJS7VO4O3vJQT9QmZiY6AxAboH25LGdtZq0/k0seb6EgVUBsJ pOiQ== X-Received: by 10.140.28.11 with SMTP id 11mr39324qgy.21.1421770938782; Tue, 20 Jan 2015 08:22:18 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.140.91.34 with SMTP id y31ls2971089qgd.53.gmail; Tue, 20 Jan 2015 08:22:18 -0800 (PST) X-Received: by 10.236.10.101 with SMTP id 65mr27492452yhu.32.1421770938507; Tue, 20 Jan 2015 08:22:18 -0800 (PST) Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com. [209.85.216.175]) by gmr-mx.google.com with ESMTPS id v10si103520qcd.1.2015.01.20.08.22.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 08:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of pang.xunlei@linaro.org designates 209.85.216.175 as permitted sender) client-ip=209.85.216.175; Received: by mail-qc0-f175.google.com with SMTP id c9so9088741qcz.6 for ; Tue, 20 Jan 2015 08:22:18 -0800 (PST) X-Gm-Message-State: ALoCoQmzkVcm36aIWsL0JKPR5oyz2dziq3AMOpb52zjZMEbDqkh257YSbZcCt859xLov92v/JKBY 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: [rtc-linux] [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> X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of pang.xunlei@linaro.org designates 209.85.216.175 as permitted sender) smtp.mail=pang.xunlei@linaro.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 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);