Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rtc: use timeu64_t for range_max
@ 2019-09-27 11:04 Emmanuel Nicolet
  2019-10-03 19:55 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Nicolet @ 2019-09-27 11:04 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc

Hi,
for rtc drivers where rtc->range_max is set U64_MAX, like the PS3 rtc,
rtc_valid_range() always returns -ERANGE. This is because the local
variable range_max has type time64_t, so the test
	if (time < range_min || time > range_max)
		return -ERANGE;
becomes (time < range_min || time > -1), which always evaluates to true.
timeu64_t should be used, since it's the type of rtc->range_max.

Signed-off-by: Emmanuel Nicolet <emmanuel.nicolet@gmail.com>
---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index c93ef33b01d3..eea700723976 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -70,7 +70,7 @@ static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm)
 		time64_t time = rtc_tm_to_time64(tm);
 		time64_t range_min = rtc->set_start_time ? rtc->start_secs :
 			rtc->range_min;
-		time64_t range_max = rtc->set_start_time ?
+		timeu64_t range_max = rtc->set_start_time ?
 			(rtc->start_secs + rtc->range_max - rtc->range_min) :
 			rtc->range_max;
 
-- 
2.23.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: use timeu64_t for range_max
  2019-09-27 11:04 [PATCH] rtc: use timeu64_t for range_max Emmanuel Nicolet
@ 2019-10-03 19:55 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2019-10-03 19:55 UTC (permalink / raw)
  To: Emmanuel Nicolet; +Cc: Alessandro Zummo, linux-rtc

On 27/09/2019 13:04:46+0200, Emmanuel Nicolet wrote:
> Hi,
> for rtc drivers where rtc->range_max is set U64_MAX, like the PS3 rtc,
> rtc_valid_range() always returns -ERANGE. This is because the local
> variable range_max has type time64_t, so the test
> 	if (time < range_min || time > range_max)
> 		return -ERANGE;
> becomes (time < range_min || time > -1), which always evaluates to true.
> timeu64_t should be used, since it's the type of rtc->range_max.
> 
> Signed-off-by: Emmanuel Nicolet <emmanuel.nicolet@gmail.com>
> ---
>  drivers/rtc/interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 11:04 [PATCH] rtc: use timeu64_t for range_max Emmanuel Nicolet
2019-10-03 19:55 ` Alexandre Belloni

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org linux-rtc@archiver.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox