From patchwork Thu Apr 2 03:34:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46683 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0987216D1 for ; Thu, 2 Apr 2015 03:35:16 +0000 (UTC) Received: by wgtj4 with SMTP id j4sf14307066wgt.0 for ; Wed, 01 Apr 2015 20:35:16 -0700 (PDT) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=pDggtv9ynkEtvvl8ukycRhQbNgcpBb+VsV5LbrXfbZs=; b=O+3iOnk865RX3QMqQurpcpfPvOYY2GbJX6YFT9xU8UuELp0c1sim9d9misYIvghU9Z 0zafHW3K11xTkfJHVPODDgUO3nDjOZqh9MvuJpUada2HZgn0sINW85ExcUWc6dUKa4Qg Eav4g63UQrlqX1ZaYWBGwf3/1+jFLUtGRt52oX0xyGuhdRrQDX5M0gbKd64OaFt3HhGb W39yK7iBxWGxu+WHYFYsNyHb4Rz5Y/sUkgBAxzf513gP7EWXILHmjnn4oHv0AHKSYP3T PAB+GGBxdbijEmkP24saeutjehTO6BY6j3+SpF5sUGt6Ax/XfCuSn8p7AXSdmlNP4JYH 2d8w== X-Gm-Message-State: ALoCoQkTMAOAjKgx0x4UJAz6xexhQP0KDQX4VcYQj62Yav0MWj/MAxR3kevevi0Rv19t5u1kfdtB X-Received: by 10.112.138.233 with SMTP id qt9mr4141376lbb.2.1427945716134; Wed, 01 Apr 2015 20:35:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.2 with SMTP id ky2ls164781lab.107.gmail; Wed, 01 Apr 2015 20:35:16 -0700 (PDT) X-Received: by 10.112.8.101 with SMTP id q5mr38875936lba.19.1427945715992; Wed, 01 Apr 2015 20:35:15 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id n5si3114795laj.150.2015.04.01.20.35.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbug6 with SMTP id ug6so50489606lbb.3 for ; Wed, 01 Apr 2015 20:35:15 -0700 (PDT) X-Received: by 10.112.150.39 with SMTP id uf7mr38039215lbb.72.1427945715889; Wed, 01 Apr 2015 20:35:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1063242lbq; Wed, 1 Apr 2015 20:35:14 -0700 (PDT) X-Received: by 10.70.34.129 with SMTP id z1mr81888240pdi.113.1427945696131; Wed, 01 Apr 2015 20:34:56 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com. [209.85.220.44]) by mx.google.com with ESMTPS id ny12si5518630pab.202.2015.04.01.20.34.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.44 as permitted sender) client-ip=209.85.220.44; Received: by patj18 with SMTP id j18so71303437pat.2 for ; Wed, 01 Apr 2015 20:34:55 -0700 (PDT) X-Received: by 10.68.109.197 with SMTP id hu5mr82931150pbb.126.1427945695232; Wed, 01 Apr 2015 20:34:55 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id da10sm3572603pac.42.2015.04.01.20.34.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:34:54 -0700 (PDT) From: John Stultz To: lkml Cc: Xunlei Pang , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 07/21] rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement Date: Wed, 1 Apr 2015 20:34:27 -0700 Message-Id: <1427945681-29972-8-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> References: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@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.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Acked-by: Alessandro Zummo Signed-off-by: Xunlei Pang [jstultz: Add whitespace fix for checkpatch] Signed-off-by: John Stultz --- drivers/rtc/interface.c | 8 +++++++- drivers/rtc/systohc.c | 5 ++++- include/linux/rtc.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 37215cf..d43ee40 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -72,7 +72,11 @@ 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) { time64_t secs64 = rtc_tm_to_time64(tm); err = rtc->ops->set_mmss(rtc->dev.parent, secs64); } else @@ -96,6 +100,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 ef3c07a..7728d5e 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -35,7 +35,10 @@ int rtc_set_ntp_time(struct timespec64 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 dcad7ee..8dcf682 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);