Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
On Mon, 1 Jun 2015 21:59:09 +0200 Alexandre Belloni wrote: > I feel that we still have a bit of time before having to hurry and find > a proper solution ;) agreed :) -- Best regards, Alessandro Zummo - CEO, Tower Technologies - Torino, Italy http://www.towertech.it -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
On Mon, 1 Jun 2015 21:59:09 +0200 Alexandre Belloni alexandre.bell...@free-electrons.com wrote: I feel that we still have a bit of time before having to hurry and find a proper solution ;) agreed :) -- Best regards, Alessandro Zummo - CEO, Tower Technologies - Torino, Italy http://www.towertech.it -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
Hi, On 01/06/2015 at 21:43:22 +0200, Arnd Bergmann wrote : > Note that Alexandre has stepped up as a new maintainer for RTC now, > so whatever he wants is probably the way it should be done. > I'm still quite new in that position and I didn't make my mind in a lot of different topics ;) > I think the way that your first approach came out was a bit unfortunate, > because we didn't have agreement on how it should really be done. > > IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a > good concept, most importantly so we can easily find where the potential > problems are, but the implementation was a bit too ambitious in trying > to fix the underlying issue. > > If we want to start this over again, I think a better approach would be > to introduce trivial functions at first, like > > time64_t rtc_hw32_to_time64(u32 hwtime) > { > /* >* this is safe until about 2106, when unsigned u32 seconds from the >* 1970 epoch will overflow >*/ > return (u64)hwtime; > } > EXPORT_SYMBOL_GPL(rtc_hw32_to_time64); > > This way, we can fix all the drivers without introducing any possible > ambiguity and later decide how that function should in fact handle the > 2106 overflow. Our grandchildren can take care of that if necessary ;-) > We also have RTCs that can only store the year as an integer between 0 and 99. Some of them will definitively not pass 2099, considering that the can only handle leap days between 2000 and 2099. Also, we have a few drivers assuming that year >= 70 is in the 19s so they will stop working correctly in 2070. I think we also have to consider those while trying to find a solution. I feel that we still have a bit of time before having to hurry and find a proper solution ;) -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
On Saturday 30 May 2015 18:05:10 pang.xun...@zte.com.cn wrote: > PangXunLei10110855/user/zte_ltd wrote 2015-05-29 PM 10:32:15: > > Alexandre Belloni wrote > > 2015-04-30 AM 07:28:24: > > > Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() > > > and rtc_time_to_tm() > > > > > > For the same reason that Russell pointed in patch 4/5, this hides that > > > it doesn't work after 2106-02-07 06:28:16 as the register is still 32 > > > bits. > > > I would prefer that you return an error in that case. > > > > Thanks for the review, I want to leave the ones like this untouched. > > > > To further explain, for the rtc hardware with 32-bit counters, we actually > > had a solution before: https://lkml.org/lkml/2014/11/27/341 > > But seems some guys don't like the solution, so rtc drivers like this one > can't be simply changed to use the new-added y2038-safe interfaces. > > Maybe those drivers will still retain the deprecated interfaces until a > better solution is proposed. Note that Alexandre has stepped up as a new maintainer for RTC now, so whatever he wants is probably the way it should be done. I think the way that your first approach came out was a bit unfortunate, because we didn't have agreement on how it should really be done. IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a good concept, most importantly so we can easily find where the potential problems are, but the implementation was a bit too ambitious in trying to fix the underlying issue. If we want to start this over again, I think a better approach would be to introduce trivial functions at first, like time64_t rtc_hw32_to_time64(u32 hwtime) { /* * this is safe until about 2106, when unsigned u32 seconds from the * 1970 epoch will overflow */ return (u64)hwtime; } EXPORT_SYMBOL_GPL(rtc_hw32_to_time64); This way, we can fix all the drivers without introducing any possible ambiguity and later decide how that function should in fact handle the 2106 overflow. Our grandchildren can take care of that if necessary ;-) Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
On Saturday 30 May 2015 18:05:10 pang.xun...@zte.com.cn wrote: PangXunLei10110855/user/zte_ltd wrote 2015-05-29 PM 10:32:15: Alexandre Belloni alexandre.bell...@free-electrons.com wrote 2015-04-30 AM 07:28:24: Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm() For the same reason that Russell pointed in patch 4/5, this hides that it doesn't work after 2106-02-07 06:28:16 as the register is still 32 bits. I would prefer that you return an error in that case. Thanks for the review, I want to leave the ones like this untouched. To further explain, for the rtc hardware with 32-bit counters, we actually had a solution before: https://lkml.org/lkml/2014/11/27/341 But seems some guys don't like the solution, so rtc drivers like this one can't be simply changed to use the new-added y2038-safe interfaces. Maybe those drivers will still retain the deprecated interfaces until a better solution is proposed. Note that Alexandre has stepped up as a new maintainer for RTC now, so whatever he wants is probably the way it should be done. I think the way that your first approach came out was a bit unfortunate, because we didn't have agreement on how it should really be done. IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a good concept, most importantly so we can easily find where the potential problems are, but the implementation was a bit too ambitious in trying to fix the underlying issue. If we want to start this over again, I think a better approach would be to introduce trivial functions at first, like time64_t rtc_hw32_to_time64(u32 hwtime) { /* * this is safe until about 2106, when unsigned u32 seconds from the * 1970 epoch will overflow */ return (u64)hwtime; } EXPORT_SYMBOL_GPL(rtc_hw32_to_time64); This way, we can fix all the drivers without introducing any possible ambiguity and later decide how that function should in fact handle the 2106 overflow. Our grandchildren can take care of that if necessary ;-) Arnd -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
Hi, On 01/06/2015 at 21:43:22 +0200, Arnd Bergmann wrote : Note that Alexandre has stepped up as a new maintainer for RTC now, so whatever he wants is probably the way it should be done. I'm still quite new in that position and I didn't make my mind in a lot of different topics ;) I think the way that your first approach came out was a bit unfortunate, because we didn't have agreement on how it should really be done. IMHO the rtc_time64_to_hw32 and rtc_hw32_to_time64 interfaces were a good concept, most importantly so we can easily find where the potential problems are, but the implementation was a bit too ambitious in trying to fix the underlying issue. If we want to start this over again, I think a better approach would be to introduce trivial functions at first, like time64_t rtc_hw32_to_time64(u32 hwtime) { /* * this is safe until about 2106, when unsigned u32 seconds from the * 1970 epoch will overflow */ return (u64)hwtime; } EXPORT_SYMBOL_GPL(rtc_hw32_to_time64); This way, we can fix all the drivers without introducing any possible ambiguity and later decide how that function should in fact handle the 2106 overflow. Our grandchildren can take care of that if necessary ;-) We also have RTCs that can only store the year as an integer between 0 and 99. Some of them will definitively not pass 2099, considering that the can only handle leap days between 2000 and 2099. Also, we have a few drivers assuming that year = 70 is in the 19s so they will stop working correctly in 2070. I think we also have to consider those while trying to find a solution. I feel that we still have a bit of time before having to hurry and find a proper solution ;) -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
Hi, On 15/04/2015 at 17:20:11 +0800, Xunlei Pang wrote : > From: Xunlei Pang > > The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(), > which will overflow in year 2106 on 32-bit machines. > > This patch solves this by: > - Replacing rtc_tm_to_time() with rtc_tm_to_time64() > - Replacing rtc_time_to_tm() with rtc_time64_to_tm() > > Cc: CIH > Cc: Nicolas Pitre > Cc: Andrew Christian > Cc: Richard Purdie > Signed-off-by: Xunlei Pang > --- > drivers/rtc/rtc-sa1100.c | 21 + > 1 file changed, 5 insertions(+), 16 deletions(-) > > diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c > index b6e1ca0..625a320 100644 > --- a/drivers/rtc/rtc-sa1100.c > +++ b/drivers/rtc/rtc-sa1100.c > @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device > *dev, unsigned int enabled) > > static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) > { > - rtc_time_to_tm(RCNR, tm); > + rtc_time64_to_tm(RCNR, tm); > return 0; > } > > static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) > { > - unsigned long time; > - int ret; > - > - ret = rtc_tm_to_time(tm, ); > - if (ret == 0) > - RCNR = time; > - return ret; > + RCNR = rtc_tm_to_time64(tm); For the same reason that Russell pointed in patch 4/5, this hides that it doesn't work after 2106-02-07 06:28:16 as the register is still 32 bits. I would prefer that you return an error in that case. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
Hi, On 15/04/2015 at 17:20:11 +0800, Xunlei Pang wrote : From: Xunlei Pang pang.xun...@linaro.org The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(), which will overflow in year 2106 on 32-bit machines. This patch solves this by: - Replacing rtc_tm_to_time() with rtc_tm_to_time64() - Replacing rtc_time_to_tm() with rtc_time64_to_tm() Cc: CIH c...@coventive.com Cc: Nicolas Pitre n...@fluxnic.net Cc: Andrew Christian andrew.christ...@hp.com Cc: Richard Purdie rpur...@rpsys.net Signed-off-by: Xunlei Pang pang.xun...@linaro.org --- drivers/rtc/rtc-sa1100.c | 21 + 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index b6e1ca0..625a320 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) { - rtc_time_to_tm(RCNR, tm); + rtc_time64_to_tm(RCNR, tm); return 0; } static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) { - unsigned long time; - int ret; - - ret = rtc_tm_to_time(tm, time); - if (ret == 0) - RCNR = time; - return ret; + RCNR = rtc_tm_to_time64(tm); For the same reason that Russell pointed in patch 4/5, this hides that it doesn't work after 2106-02-07 06:28:16 as the register is still 32 bits. I would prefer that you return an error in that case. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
From: Xunlei Pang The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(), which will overflow in year 2106 on 32-bit machines. This patch solves this by: - Replacing rtc_tm_to_time() with rtc_tm_to_time64() - Replacing rtc_time_to_tm() with rtc_time64_to_tm() Cc: CIH Cc: Nicolas Pitre Cc: Andrew Christian Cc: Richard Purdie Signed-off-by: Xunlei Pang --- drivers/rtc/rtc-sa1100.c | 21 + 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index b6e1ca0..625a320 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) { - rtc_time_to_tm(RCNR, tm); + rtc_time64_to_tm(RCNR, tm); return 0; } static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) { - unsigned long time; - int ret; - - ret = rtc_tm_to_time(tm, ); - if (ret == 0) - RCNR = time; - return ret; + RCNR = rtc_tm_to_time64(tm); + return 0; } static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -185,23 +180,17 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct sa1100_rtc *info = dev_get_drvdata(dev); - unsigned long time; - int ret; spin_lock_irq(>lock); - ret = rtc_tm_to_time(>time, ); - if (ret != 0) - goto out; RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); - RTAR = time; + RTAR = rtc_tm_to_time64(>time); if (alrm->enabled) RTSR |= RTSR_ALE; else RTSR &= ~RTSR_ALE; -out: spin_unlock_irq(>lock); - return ret; + return 0; } static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] drivers/rtc/sa1100: Replace deprecated rtc_tm_to_time() and rtc_time_to_tm()
From: Xunlei Pang pang.xun...@linaro.org The driver uses deprecated rtc_tm_to_time() and rtc_time_to_tm(), which will overflow in year 2106 on 32-bit machines. This patch solves this by: - Replacing rtc_tm_to_time() with rtc_tm_to_time64() - Replacing rtc_time_to_tm() with rtc_time64_to_tm() Cc: CIH c...@coventive.com Cc: Nicolas Pitre n...@fluxnic.net Cc: Andrew Christian andrew.christ...@hp.com Cc: Richard Purdie rpur...@rpsys.net Signed-off-by: Xunlei Pang pang.xun...@linaro.org --- drivers/rtc/rtc-sa1100.c | 21 + 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index b6e1ca0..625a320 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c @@ -157,19 +157,14 @@ static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) { - rtc_time_to_tm(RCNR, tm); + rtc_time64_to_tm(RCNR, tm); return 0; } static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm) { - unsigned long time; - int ret; - - ret = rtc_tm_to_time(tm, time); - if (ret == 0) - RCNR = time; - return ret; + RCNR = rtc_tm_to_time64(tm); + return 0; } static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -185,23 +180,17 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct sa1100_rtc *info = dev_get_drvdata(dev); - unsigned long time; - int ret; spin_lock_irq(info-lock); - ret = rtc_tm_to_time(alrm-time, time); - if (ret != 0) - goto out; RTSR = RTSR (RTSR_HZE|RTSR_ALE|RTSR_AL); - RTAR = time; + RTAR = rtc_tm_to_time64(alrm-time); if (alrm-enabled) RTSR |= RTSR_ALE; else RTSR = ~RTSR_ALE; -out: spin_unlock_irq(info-lock); - return ret; + return 0; } static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/