From patchwork Fri Jun 16 14:03:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 105748 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1321315qgd; Fri, 16 Jun 2017 07:05:23 -0700 (PDT) X-Received: by 10.84.231.194 with SMTP id g2mr13031679pln.34.1497621923534; Fri, 16 Jun 2017 07:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497621923; cv=none; d=google.com; s=arc-20160816; b=EQ9sxHASEMknhe/IU9zBD14UlOu/EXA62eBxlKc0+mGCXrS9lzrIJPkNMmfUPN7S0d ErkglKPROQ4S6J8FL8zOtVIYi27p7H7oEFdXuI7xCnBagUe3CkGwMOc/KS+TIarmHk6S tZM9A/I05CUtFOs0yCUpXi+2KgeyuJrs5KhY9TeZu2rpKfcWCWU59jTZ9Fm6N3N35MzP f/0S0ZibJ7LSaRlZJBTo9O+hKL2dHAVtpyuFecbnYJe5Sdt6ag/vliqTV3YityhqTMbC E5u7RC/HugJNUcqNbpea7BbjRxIoHgpgCpS7qLglkgoT8aJBvxv775BLTQwVL2zbuntq jTfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Pmp86WE71VCG0xAL+4P23X8e6KOwOfaABNMuBuupcYc=; b=BNUzhj7t8/Xq1DjAOif+N2EM+vE8vwLfffgAd0SAeaByv3sTS6WrmtJrQHi4YmRPoQ AjAaqdwaUewb0m0m8cmb+JPmVVCEIswpG0y+K0Ugf8OQ+kVO9tj+gU1z85ib4XWPAfyM j5+9MbsZZbK5ySRolUAdpSZa5+yTBYkXfiMfGr2eSZJB/n6yY4D6yvZ+HNW8KLvV0JHK yfGfXfFYd2biVy06Amz4QbIc0/to/bSAzkVEJuJ90lVGp2W+9/knxUaJid1vwY2vvnDe FVFn7KD97HcPmtKIEYXHfEg2ewc81h2Pjbqu/kzuOrkAa7LJoGawR3eVwMyhe6A3jkT7 8q/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=OZ3jR2eY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f192si2049730pgc.179.2017.06.16.07.05.23; Fri, 16 Jun 2017 07:05:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=OZ3jR2eY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754048AbdFPOFI (ORCPT + 25 others); Fri, 16 Jun 2017 10:05:08 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35376 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753891AbdFPOFG (ORCPT ); Fri, 16 Jun 2017 10:05:06 -0400 Received: by mail-wm0-f51.google.com with SMTP id x70so27003092wme.0 for ; Fri, 16 Jun 2017 07:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pmp86WE71VCG0xAL+4P23X8e6KOwOfaABNMuBuupcYc=; b=OZ3jR2eYEtsrW7RAs/1/beU8SmUz3iA7p9hQ6KRVXMp0/pV3n/Pe12PZvEeNVIDHQn 2MHNJlCVEu+pbZimX/u/CFkvnaucJzsQOEvJATQ1ifOrBfeK8iDO3Ki+bQM4uS8dnUAb VTtSFP2TtrsAubmMoCEcuaxWd+zc1fuPBaEOw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pmp86WE71VCG0xAL+4P23X8e6KOwOfaABNMuBuupcYc=; b=RyeH/5QolGGRX7uaSZgO8qIEfrcJ6Ul6UFCJ4pQIWLIgXLCAsKxtjkBU+vx0IPHj2N h9PATy6qzRyPtdTf0u8wJ6JG2SYetR9hdD766it4F2GTNpomcBIEdgD4VtiWVxI8t0kL 1VzJeDmYqd3weoCwP0hwMhcf5CW2+Uyi0saK6eOGoPWLjZwSStxD6HtooKP5fth/+Mfu 0dVmNM6COiZVt21weyaTSMVxbjd6NzOYVlGlTPXjrcCv+0IbbhEn8Gxxe5pB0YPHFt5Q g1vh965NKq2i/7NPDdc4JwwO/GBs+xQmCOlohuh6FmYeCZVW1Wm3Ybr2vwQGUGv3a1lc GWhA== X-Gm-Message-State: AKS2vOz9LUjAYw6xEj0Wyd3ZWlEO/rp4s8ZpyNb7rCyjQLAVBRLClr2b K6e9Mtq1l0gP9Zhk X-Received: by 10.28.23.4 with SMTP id 4mr7663744wmx.119.1497621894966; Fri, 16 Jun 2017 07:04:54 -0700 (PDT) Received: from lmenx321.st.com. ([80.214.78.131]) by smtp.gmail.com with ESMTPSA id h12sm1883277wrc.43.2017.06.16.07.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 07:04:54 -0700 (PDT) From: Benjamin Gaignard To: john.stultz@linaro.org, tglx@linutronix.de, sboyd@codeaurora.org, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, patrice.chotard@st.com, a.zummo@towertech.it, alexandre.belloni@free-electrons.com, linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com Cc: linaro-kernel@lists.linaro.org, Benjamin Gaignard Subject: [PATCH 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Date: Fri, 16 Jun 2017 16:03:53 +0200 Message-Id: <1497621833-9942-4-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497621833-9942-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497621833-9942-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make driver use u64 variables and functions to be sure that it will support dates after year 2038. Signed-off-by: Benjamin Gaignard --- drivers/rtc/rtc-st-lpc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 1.9.1 Acked-by: Patrice Chotard diff --git a/drivers/rtc/rtc-st-lpc.c b/drivers/rtc/rtc-st-lpc.c index 74c0a33..82b0af1 100644 --- a/drivers/rtc/rtc-st-lpc.c +++ b/drivers/rtc/rtc-st-lpc.c @@ -99,7 +99,7 @@ static int st_rtc_read_time(struct device *dev, struct rtc_time *tm) lpt = ((unsigned long long)lpt_msb << 32) | lpt_lsb; do_div(lpt, rtc->clkrate); - rtc_time_to_tm(lpt, tm); + rtc_time64_to_tm(lpt, tm); return 0; } @@ -107,13 +107,10 @@ static int st_rtc_read_time(struct device *dev, struct rtc_time *tm) static int st_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct st_rtc *rtc = dev_get_drvdata(dev); - unsigned long long lpt; - unsigned long secs, flags; - int ret; + unsigned long long lpt, secs; + unsigned long flags; - ret = rtc_tm_to_time(tm, &secs); - if (ret) - return ret; + secs = rtc_tm_to_time64(tm); lpt = (unsigned long long)secs * rtc->clkrate; @@ -161,13 +158,13 @@ static int st_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) { struct st_rtc *rtc = dev_get_drvdata(dev); struct rtc_time now; - unsigned long now_secs; - unsigned long alarm_secs; + unsigned long long now_secs; + unsigned long long alarm_secs; unsigned long long lpa; st_rtc_read_time(dev, &now); - rtc_tm_to_time(&now, &now_secs); - rtc_tm_to_time(&t->time, &alarm_secs); + now_secs = rtc_tm_to_time64(&now); + alarm_secs = rtc_tm_to_time64(&t->time); /* Invalid alarm time */ if (now_secs > alarm_secs)