From patchwork Tue Jun 20 09:35:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 105991 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1281398qgd; Tue, 20 Jun 2017 02:59:07 -0700 (PDT) X-Received: by 10.98.7.204 with SMTP id 73mr29941076pfh.175.1497952747257; Tue, 20 Jun 2017 02:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497952747; cv=none; d=google.com; s=arc-20160816; b=QquR8g7wfMaf0MWRPuw1uTzmJQTiMvsTs2u0COrF5HvkyOPt0WmF7LRX5BgRZWs7Ke UAEtIugbg8LuR+4OXM8u8t4uRiCObJukx/I7kUKLrYOa+1ulI5Shtd1uB1XBS5DhNiij lRYqvzevJ7XPGSdwfNDMHBXl76nvBmCiuhj8jhvZm6v9FQRWTm4DDNLXyJ2xbCNSLauz DQYL+cPEX0m7a8WvKdWtglhmg5dDu5z/TOSKjwxqoSuF2fGSkjwmhOVXHsVHlBVs2a/m Udc9sRjgM2Ou1kA0BC3F6B++/p61TRJiKYItdTp3neDDgEZPmP37F1ujxpVzvgzm/QKz DREQ== 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=wGNV1XIwJ451jYKQCJDCwamKxUc85B6gwDdg3z1bx/c=; b=TnrXpQjV1AdacOqKFiRNHZbEbWWupIRN6u+U5XASO2cX3Mum3pEM5LEe1e9S4b/upV AEvmLN+6icr6zQcJLVagL554JjKp5U0e5nxjiBNbStl0w5PSRtZWzArlHrdz1OFtO/EM jTFOgRyLJcDew+othL7CdhnehxqCh6zxIRWLppjMzLi4L7241ZH4wpOHtUfZODlBTeHZ eqj0gGD4i8P4NRJ8z5rqv3yfSEFuBz4/Ft5PIIT63u7vJS668NNgGC3wHRgosweb9lxI OBB7p3WDzXxhv+eYRBzwz1qMzbWpidJv0sAOG+tic8AYjRlQvdYacLsoz9bsOuCdXGMX ENcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Wg+LkZgs; 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 p23si2770503pli.431.2017.06.20.02.59.06; Tue, 20 Jun 2017 02:59:07 -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=Wg+LkZgs; 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 S1752052AbdFTJ6f (ORCPT + 25 others); Tue, 20 Jun 2017 05:58:35 -0400 Received: from mail-wr0-f173.google.com ([209.85.128.173]:36668 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbdFTJhI (ORCPT ); Tue, 20 Jun 2017 05:37:08 -0400 Received: by mail-wr0-f173.google.com with SMTP id c11so32940735wrc.3 for ; Tue, 20 Jun 2017 02:37:07 -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=wGNV1XIwJ451jYKQCJDCwamKxUc85B6gwDdg3z1bx/c=; b=Wg+LkZgsSffaPTViELQW2uoKUUIqjIFTJaXhidYx7VcgQ9bM69OhZjr8Op+019hz8z U+57xVd9QIbkryeNU2e9/u57iEwFd7O/3oirzdOq8AbGkYGaBBbyb8rl/A3+8YOt5MeC Zosso2WT7WNsln64YmSNRc+SD4XBjeO6D9Uls= 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=wGNV1XIwJ451jYKQCJDCwamKxUc85B6gwDdg3z1bx/c=; b=Uym4ikR8bb4nellbiQwTo4GqIo0UX8snLVTyNhPvhZDxHemfrLptyPAPf1dbnvZ6UY tr6kuFF1bAQZESXbqiz2ooOQiBnUvQq+8+n/4AkRdlecuPWlJqjITuRQ+7GuzrTMGHfZ ogGquJ+6ZFrr/8XSIMhFUJCIh4SyivKxtpAlVeoDwCmRkE6QEtE9nwFAlYRG3QcdOatI 6bgU2E0J5pRcCQCqOm/lg03KuMLU06xYMmqeeHknQTLUDcQCSHkX6ECqmjIxk0uZjxqY Md6hCInYzwjmVubPu+u5z3YddUHuIdAxdjDdhBbF91ryWgYsFupFwgfPRAHo/Qm/w8FV TETg== X-Gm-Message-State: AKS2vOyJt8nFQZay535fqlwtcWuizTWqOm/gwLZTt+R60y+FSXmlzsAr A1I+roBX0RDYw+RiPEpKiQ== X-Received: by 10.223.170.7 with SMTP id p7mr21052009wrd.72.1497951426936; Tue, 20 Jun 2017 02:37:06 -0700 (PDT) Received: from lmenx321.st.com. ([80.215.93.217]) by smtp.gmail.com with ESMTPSA id e24sm4482318wrc.35.2017.06.20.02.37.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 02:37:06 -0700 (PDT) From: Benjamin Gaignard To: benjamin.gaignard@linaro.org Cc: linaro-kernel@lists.linaro.org, Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH 05/51] rtc: 88pm860x: stop using rtc deprecated functions Date: Tue, 20 Jun 2017 11:35:13 +0200 Message-Id: <1497951359-13334-6-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497951359-13334-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497951359-13334-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 rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones. Signed-off-by: Benjamin Gaignard CC: Alessandro Zummo CC: Alexandre Belloni CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-88pm860x.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) -- 1.9.1 diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index 19e53b3..0d20ede 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c @@ -86,8 +86,8 @@ static int pm860x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm) { - unsigned long next_time; - unsigned long now_time; + unsigned long long next_time; + unsigned long long now_time; next->tm_year = now->tm_year; next->tm_mon = now->tm_mon; @@ -96,13 +96,13 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, next->tm_min = alrm->tm_min; next->tm_sec = alrm->tm_sec; - rtc_tm_to_time(now, &now_time); - rtc_tm_to_time(next, &next_time); + now_time = rtc_tm_to_time64(now); + next_time = rtc_tm_to_time64(next); if (next_time < now_time) { /* Advance one day */ next_time += 60 * 60 * 24; - rtc_time_to_tm(next_time, next); + rtc_time64_to_tm(next_time, next); } } @@ -110,7 +110,7 @@ static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct pm860x_rtc_info *info = dev_get_drvdata(dev); unsigned char buf[8]; - unsigned long ticks, base, data; + unsigned long long ticks, base, data; pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1], @@ -121,10 +121,10 @@ static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm) pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ticks = base + data; - dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n", base, data, ticks); - rtc_time_to_tm(ticks, tm); + rtc_time64_to_tm(ticks, tm); return 0; } @@ -133,7 +133,7 @@ static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct pm860x_rtc_info *info = dev_get_drvdata(dev); unsigned char buf[4]; - unsigned long ticks, base, data; + unsigned long long ticks, base, data; if ((tm->tm_year < 70) || (tm->tm_year > 138)) { dev_dbg(info->dev, "Set time %d out of range. " @@ -141,13 +141,13 @@ static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm) 1900 + tm->tm_year); return -EINVAL; } - rtc_tm_to_time(tm, &ticks); + ticks = rtc_tm_to_time64(tm); /* load 32-bit read-only counter */ pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; base = ticks - data; - dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + dev_dbg(info->dev, "set base:0x%llx, RO count:0x%llx, ticks:0x%llx\n", base, data, ticks); pm860x_page_reg_write(info->i2c, REG0_DATA, (base >> 24) & 0xFF); @@ -164,7 +164,7 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct pm860x_rtc_info *info = dev_get_drvdata(dev); unsigned char buf[8]; - unsigned long ticks, base, data; + unsigned long long ticks, base, data; int ret; pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); @@ -175,10 +175,10 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf); data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ticks = base + data; - dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n", base, data, ticks); - rtc_time_to_tm(ticks, &alrm->time); + rtc_time64_to_tm(ticks, &alrm->time); ret = pm860x_reg_read(info->i2c, PM8607_RTC1); alrm->enabled = (ret & ALARM_EN) ? 1 : 0; alrm->pending = (ret & (ALARM | ALARM_WAKEUP)) ? 1 : 0; @@ -189,7 +189,7 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct pm860x_rtc_info *info = dev_get_drvdata(dev); struct rtc_time now_tm, alarm_tm; - unsigned long ticks, base, data; + unsigned long long ticks, base, data; unsigned char buf[8]; int mask; @@ -204,13 +204,13 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ticks = base + data; - dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + dev_dbg(info->dev, "get base:0x%llx, RO count:0x%llx, ticks:0x%llx\n", base, data, ticks); - rtc_time_to_tm(ticks, &now_tm); + rtc_time64_to_tm(ticks, &now_tm); rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time); /* get new ticks for alarm in 24 hours */ - rtc_tm_to_time(&alarm_tm, &ticks); + ticks = rtc_tm_to_time64(&alarm_tm); data = ticks - base; buf[0] = data & 0xff; @@ -314,7 +314,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev) struct pm860x_rtc_pdata *pdata = NULL; struct pm860x_rtc_info *info; struct rtc_time tm; - unsigned long ticks = 0; + unsigned long long ticks = 0; int ret; pdata = dev_get_platdata(&pdev->dev); @@ -367,7 +367,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev) return ret; } } - rtc_tm_to_time(&tm, &ticks); + ticks = rtc_tm_to_time64(&tm); if (pm860x_rtc_dt_init(pdev, info)) { if (pdata && pdata->sync) { pdata->sync(ticks);