Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1670603 > unrolled thread

[PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

Started byBenjamin Gaignard <benjamin.gaignard@linaro.org>
First post2017-06-20 12:00 +0200
Last post2017-06-20 16:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions Benjamin Gaignard <benjamin.gaignard@linaro.org> - 2017-06-20 12:00 +0200
    RE: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions Steve Twiss <stwiss.opensource@diasemi.com> - 2017-06-20 15:50 +0200
      Re: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions Benjamin Gaignard <benjamin.gaignard@linaro.org> - 2017-06-20 16:20 +0200

#1670603 — [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

FromBenjamin Gaignard <benjamin.gaignard@linaro.org>
Date2017-06-20 12:00 +0200
Subject[PATCH 14/51] rtc: da9063: stop using rtc deprecated functions
Message-ID<tUo70-6Xh-17@gated-at.bofh.it>
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 <benjamin.gaignard@linaro.org>
CC: Support Opensource <support.opensource@diasemi.com>
CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@free-electrons.com>
CC: rtc-linux@googlegroups.com
CC: linux-kernel@vger.kernel.org
---
 drivers/rtc/rtc-da9052.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index 4273377..99a0489 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -104,17 +104,15 @@ static int da9052_read_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
 static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
 {
 	struct da9052 *da9052 = rtc->da9052;
-	unsigned long alm_time;
+	unsigned long long alm_time;
 	int ret;
 	uint8_t v[3];
 
-	ret = rtc_tm_to_time(rtc_tm, &alm_time);
-	if (ret != 0)
-		return ret;
+	alm_time = rtc_tm_to_time64(rtc_tm);
 
 	if (rtc_tm->tm_sec > 0) {
 		alm_time += 60 - rtc_tm->tm_sec;
-		rtc_time_to_tm(alm_time, rtc_tm);
+		rtc_time64_to_tm(alm_time, rtc_tm);
 	}
 	BUG_ON(rtc_tm->tm_sec); /* it will cause repeated irqs if not zero */
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1670783

FromSteve Twiss <stwiss.opensource@diasemi.com>
Date2017-06-20 15:50 +0200
Message-ID<tUrHB-Q2-37@gated-at.bofh.it>
In reply to#1670603
Hi Benjamin,

On 20 June 2017 10:35, Benjamin Gaignard wrote:

> Subject: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions

Probably this subject should be "rtc: da9052" not 63.

> 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.
> 
[...]

> ---
>  drivers/rtc/rtc-da9052.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
> index 4273377..99a0489 100644
> --- a/drivers/rtc/rtc-da9052.c
> +++ b/drivers/rtc/rtc-da9052.c
> @@ -104,17 +104,15 @@ static int da9052_read_alarm(struct da9052_rtc
> *rtc, struct rtc_time *rtc_tm)
>  static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
>  {
>  	struct da9052 *da9052 = rtc->da9052;
> -	unsigned long alm_time;
> +	unsigned long long alm_time;
>  	int ret;
>  	uint8_t v[3];
> 
> -	ret = rtc_tm_to_time(rtc_tm, &alm_time);
> -	if (ret != 0)
> -		return ret;
> +	alm_time = rtc_tm_to_time64(rtc_tm);

But they kind of use the same functions anyway.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/rtc.h?h=v4.12-rc6#n35
And I think they they are abstracted on purpose.

The DA9052/53 hardware can only handle alarms up to the end of 2063.

Regards,
Steve

[toc] | [prev] | [next] | [standalone]


#1670820

FromBenjamin Gaignard <benjamin.gaignard@linaro.org>
Date2017-06-20 16:20 +0200
Message-ID<tUsaD-1fq-29@gated-at.bofh.it>
In reply to#1670783
2017-06-20 15:41 GMT+02:00 Steve Twiss <stwiss.opensource@diasemi.com>:
> Hi Benjamin,
>
> On 20 June 2017 10:35, Benjamin Gaignard wrote:
>
>> Subject: [PATCH 14/51] rtc: da9063: stop using rtc deprecated functions
>
> Probably this subject should be "rtc: da9052" not 63.

yes you are right this patch is for da9052

>
>> 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.
>>
> [...]
>
>> ---
>>  drivers/rtc/rtc-da9052.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
>> index 4273377..99a0489 100644
>> --- a/drivers/rtc/rtc-da9052.c
>> +++ b/drivers/rtc/rtc-da9052.c
>> @@ -104,17 +104,15 @@ static int da9052_read_alarm(struct da9052_rtc
>> *rtc, struct rtc_time *rtc_tm)
>>  static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm)
>>  {
>>       struct da9052 *da9052 = rtc->da9052;
>> -     unsigned long alm_time;
>> +     unsigned long long alm_time;
>>       int ret;
>>       uint8_t v[3];
>>
>> -     ret = rtc_tm_to_time(rtc_tm, &alm_time);
>> -     if (ret != 0)
>> -             return ret;
>> +     alm_time = rtc_tm_to_time64(rtc_tm);
>
> But they kind of use the same functions anyway.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/rtc.h?h=v4.12-rc6#n35
> And I think they they are abstracted on purpose.
>
> The DA9052/53 hardware can only handle alarms up to the end of 2063.

That is the hardware limits but I don't know if we should align
framework functions to
for each driver limitation or use 64 bits functions everywhere.
but this discussion is on going on another thread...
>
> Regards,
> Steve
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web