* [PATCH] rtc: gamecube: Fix supported time range in gamecube_rtc_probe()
@ 2026-11-02 2:21 Thorsten Blum
2026-11-02 2:25 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-11-02 2:21 UTC (permalink / raw)
To: Alexandre Belloni, Emmanuel Gil Peyrot, Michael Ellerman
Cc: Thorsten Blum, linux-rtc, linux-kernel
gamecube_rtc_read_time() adds the SRAM bias to the 32-bit RTC counter.
However, gamecube_rtc_probe() sets the supported time range from 0 to
U32_MAX without taking the bias into account.
gamecube_rtc_set_time() subtracts the bias from the timestamp, and if
the timestamp is smaller than the bias, the result is negative and wraps
when passed to regmap_write(), storing the wrong time.
Add the bias to the supported range to match gamecube_rtc_read_time()
and gamecube_rtc_set_time(). Setting a time below the bias now returns
-ERANGE. This also allows setting dates beyond the 2106 limit. Update
the comment accordingly.
Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
Not tested on hardware.
drivers/rtc/rtc-gamecube.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c
index 889028cecf4a..276e1f889d34 100644
--- a/drivers/rtc/rtc-gamecube.c
+++ b/drivers/rtc/rtc-gamecube.c
@@ -347,12 +347,9 @@ static int gamecube_rtc_probe(struct platform_device *pdev)
if (IS_ERR(rtc))
return PTR_ERR(rtc);
- /* We can represent further than that, but it depends on the stored
- * bias and we can’t modify it persistently on all supported consoles,
- * so here we pretend to be limited to 2106.
- */
- rtc->range_min = 0;
- rtc->range_max = U32_MAX;
+ /* Shift the range since the RTC counter is offset by the SRAM bias. */
+ rtc->range_min = d->rtc_bias;
+ rtc->range_max = (timeu64_t)d->rtc_bias + U32_MAX;
rtc->ops = &gamecube_rtc_ops;
return devm_rtc_register_device(rtc);
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] rtc: gamecube: Fix supported time range in gamecube_rtc_probe()
2026-11-02 2:21 [PATCH] rtc: gamecube: Fix supported time range in gamecube_rtc_probe() Thorsten Blum
@ 2026-11-02 2:25 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-02 2:25 UTC (permalink / raw)
To: Thorsten Blum; +Cc: linux-rtc, Alexandre Belloni
> gamecube_rtc_read_time() adds the SRAM bias to the 32-bit RTC counter.
> However, gamecube_rtc_probe() sets the supported time range from 0 to
> U32_MAX without taking the bias into account.
>
> gamecube_rtc_set_time() subtracts the bias from the timestamp, and if
> the timestamp is smaller than the bias, the result is negative and wraps
> when passed to regmap_write(), storing the wrong time.
>
> Add the bias to the supported range to match gamecube_rtc_read_time()
> and gamecube_rtc_set_time(). Setting a time below the bias now returns
> -ERANGE. This also allows setting dates beyond the 2106 limit. Update
> the comment accordingly.
>
> Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <blum@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261102022110.206609-2-blum@kernel.org?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-02 2:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 2:21 [PATCH] rtc: gamecube: Fix supported time range in gamecube_rtc_probe() Thorsten Blum
2026-11-02 2:25 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.