From patchwork Mon Jun 19 09:36:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 105813 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp786841qgd; Mon, 19 Jun 2017 02:37:18 -0700 (PDT) X-Received: by 10.98.198.201 with SMTP id x70mr21566691pfk.232.1497865037982; Mon, 19 Jun 2017 02:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497865037; cv=none; d=google.com; s=arc-20160816; b=II0GbeDvcprrJMNx7eXLliCsKXgTjPNGGn5Ubu2MbhkFMPjo2saVgi9eySYeHQEu6Y wFTGqV4zq728WSEhQZjZIEI+sr5blQfAq2UjWUDPPc4UWKIC1B86oMRuXa6NR5G7jhKs euGtnRszdNWFDM9k/G1lxL9PZQ8Ybm+Cehj7MdAENRQtJqgBYtUEIPkY3BziluNZ27X9 AUJRLhIWr+2NrdN6xWamb6LqsJgtOHYhKuEutiOye6PqDUjH5V009Hrx0g14VIEqnw+N BtySYS9t8sgIDwz7oFLdswJMCyn1Ucokns/ufM4A3MD893QDmnlgTcCVClkHYoiVm6di PYRA== 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=F/N9eNsJZr2+7DPpKTbXLtBvEtQ7sHqQMh9idFnIQbQ=; b=KS9VWAdlrScgozUuKDnW6TTr1hHMUJsW1piEFI9MICAPjeixRbyPINJkKSWXUFhMA3 gLvew2BQX2mVqpCxH5hPqaSMW5iHORmll/ywriV8H9YRwg6MxIFQ1cJ4+HpHTTgl/cId FBaPm+9ii6kQ6jesR1L9H2XagjeYcXBGOHpdvNznE8yLNDoHdTTZfEPk7MeTbB+q1osx YERUNUryaHBpNeHMnLmYxbOjSgJx8HE/XEXh4Tc2aAyshRw/wbNO7OzwZnnigwUKQyfK A8yvBDPScmS/lgGPMSWjcRXQldBFUBALcfyc9aep8Kkva53lgy9KXj6BLLyvkgohLjp0 cSQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Ngm4UyNc; 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 b24si6937568pfh.9.2017.06.19.02.37.17; Mon, 19 Jun 2017 02:37:17 -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=Ngm4UyNc; 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 S1753952AbdFSJhM (ORCPT + 25 others); Mon, 19 Jun 2017 05:37:12 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37220 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753735AbdFSJhK (ORCPT ); Mon, 19 Jun 2017 05:37:10 -0400 Received: by mail-wm0-f47.google.com with SMTP id d73so68221958wma.0 for ; Mon, 19 Jun 2017 02:37:00 -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=F/N9eNsJZr2+7DPpKTbXLtBvEtQ7sHqQMh9idFnIQbQ=; b=Ngm4UyNcUo3CerdtKtpWTMmFHkCrcc03iQitey690RPW7OyKZazYrnzYl7muCA4wSo gbeOGKVZ7r4knPjJhUxSX5McYF36EUaLklaXV7KdU2xnCEeHAzbonvMq497XA8imr0g0 3aFlHU3BOrsBRtqXlRyj7q5JmxaJxMptnx6p8= 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=F/N9eNsJZr2+7DPpKTbXLtBvEtQ7sHqQMh9idFnIQbQ=; b=JPyKW7RSvzjAmlUT1mqGK8fe58y7/fsC5per94L28EaACriaozr8E+4uSluphV+rht UNQdGmJsMwJUvKdTtu49AZF52oldvZhvEjRDEPJgvmtwXxynVmpmPcbBrgUtFSwL5sO0 zwtDXsHIyW8kz7vHRVxc07uvlLAnJ/btEMeMyFFmEXzfvUFMQmuBPE7TkLxjQhYseiRE 4FAVAzAGfypOFWQkGhuLJIbjnI6/MU6a5ETtwSJyOom2eZT0uVGZacqJqLvWcnmH1LKW AOSDV/+20mA9VzsyXbNjkB4pOiABToOqvyeRmVIgeLd+sHnKVaLNY2nwNHz+0o2v/ICF AU/A== X-Gm-Message-State: AKS2vOw2nyiZaYhsX1/O2pyIzxb6IDI0j3oAde/W37glwbmB2p8jKGA/ numB676+nNvX2D0o X-Received: by 10.28.126.67 with SMTP id z64mr4340008wmc.65.1497865019445; Mon, 19 Jun 2017 02:36:59 -0700 (PDT) Received: from lmenx321.st.com. ([80.215.35.135]) by smtp.gmail.com with ESMTPSA id y2sm11037024wme.12.2017.06.19.02.36.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jun 2017 02:36:59 -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 v2 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Date: Mon, 19 Jun 2017 11:36:22 +0200 Message-Id: <1497864982-29284-4-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497864982-29284-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497864982-29284-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 Acked-by: Patrice Chotard --- drivers/rtc/rtc-st-lpc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 1.9.1 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)