* [PATCH] macintosh/smu: Fix BCD encoding of the RTC month
@ 2026-11-24 13:23 Thorsten Blum
2026-11-24 15:46 ` Christophe Leroy (CS GROUP)
0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2026-11-24 13:23 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP)
Cc: Thorsten Blum, linuxppc-dev
The SMU expects a one-based month encoded as BCD, while tm_mon is
zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes
October as 0x0a instead of 0x10.
Add 1 to tm_mon before converting it to BCD.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/macintosh/smu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index c463760710b6..fb93094ff608 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -374,7 +374,7 @@ static inline void smu_fill_set_rtc_cmd(struct smu_cmd_buf *cmd_buf,
cmd_buf->data[3] = hex2bcd(time->tm_hour);
cmd_buf->data[4] = time->tm_wday;
cmd_buf->data[5] = hex2bcd(time->tm_mday);
- cmd_buf->data[6] = hex2bcd(time->tm_mon) + 1;
+ cmd_buf->data[6] = hex2bcd(time->tm_mon + 1);
cmd_buf->data[7] = hex2bcd(time->tm_year - 100);
}
@@ -421,7 +421,7 @@ int smu_set_rtc_time(struct rtc_time *time, int spinwait)
hex2bcd(time->tm_hour),
time->tm_wday,
hex2bcd(time->tm_mday),
- hex2bcd(time->tm_mon) + 1,
+ hex2bcd(time->tm_mon + 1),
hex2bcd(time->tm_year - 100));
if (rc)
return rc;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] macintosh/smu: Fix BCD encoding of the RTC month
2026-11-24 13:23 [PATCH] macintosh/smu: Fix BCD encoding of the RTC month Thorsten Blum
@ 2026-11-24 15:46 ` Christophe Leroy (CS GROUP)
2026-11-24 18:06 ` Christophe Leroy (CS GROUP)
0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-11-24 15:46 UTC (permalink / raw)
To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
Nicholas Piggin
Cc: linuxppc-dev
Le 24/11/2026 à 14:23, Thorsten Blum a écrit :
> The SMU expects a one-based month encoded as BCD, while tm_mon is
> zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes
> October as 0x0a instead of 0x10.
>
> Add 1 to tm_mon before converting it to BCD.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Thorsten Blum <blum@kernel.org>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> ---
> drivers/macintosh/smu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
> index c463760710b6..fb93094ff608 100644
> --- a/drivers/macintosh/smu.c
> +++ b/drivers/macintosh/smu.c
> @@ -374,7 +374,7 @@ static inline void smu_fill_set_rtc_cmd(struct smu_cmd_buf *cmd_buf,
> cmd_buf->data[3] = hex2bcd(time->tm_hour);
> cmd_buf->data[4] = time->tm_wday;
> cmd_buf->data[5] = hex2bcd(time->tm_mday);
> - cmd_buf->data[6] = hex2bcd(time->tm_mon) + 1;
> + cmd_buf->data[6] = hex2bcd(time->tm_mon + 1);
> cmd_buf->data[7] = hex2bcd(time->tm_year - 100);
> }
>
> @@ -421,7 +421,7 @@ int smu_set_rtc_time(struct rtc_time *time, int spinwait)
> hex2bcd(time->tm_hour),
> time->tm_wday,
> hex2bcd(time->tm_mday),
> - hex2bcd(time->tm_mon) + 1,
> + hex2bcd(time->tm_mon + 1),
> hex2bcd(time->tm_year - 100));
> if (rc)
> return rc;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] macintosh/smu: Fix BCD encoding of the RTC month
2026-11-24 15:46 ` Christophe Leroy (CS GROUP)
@ 2026-11-24 18:06 ` Christophe Leroy (CS GROUP)
2026-11-24 22:32 ` Thorsten Blum
0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-11-24 18:06 UTC (permalink / raw)
To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
Nicholas Piggin
Cc: linuxppc-dev
Le 24/11/2026 à 16:46, Christophe Leroy (CS GROUP) a écrit :
>
>
> Le 24/11/2026 à 14:23, Thorsten Blum a écrit :
>> The SMU expects a one-based month encoded as BCD, while tm_mon is
>> zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes
>> October as 0x0a instead of 0x10.
>>
>> Add 1 to tm_mon before converting it to BCD.
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
The real origin is commit faa5ee3743ff ("[PATCH] ppc64: Add basic
support for the SMU chip in iMac G5")
Found on repository https://github.com/mpe/linux-fullhistory.git
>> Signed-off-by: Thorsten Blum <blum@kernel.org>
>
> Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
>
>> ---
>> drivers/macintosh/smu.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
>> index c463760710b6..fb93094ff608 100644
>> --- a/drivers/macintosh/smu.c
>> +++ b/drivers/macintosh/smu.c
>> @@ -374,7 +374,7 @@ static inline void smu_fill_set_rtc_cmd(struct
>> smu_cmd_buf *cmd_buf,
>> cmd_buf->data[3] = hex2bcd(time->tm_hour);
>> cmd_buf->data[4] = time->tm_wday;
>> cmd_buf->data[5] = hex2bcd(time->tm_mday);
>> - cmd_buf->data[6] = hex2bcd(time->tm_mon) + 1;
>> + cmd_buf->data[6] = hex2bcd(time->tm_mon + 1);
>> cmd_buf->data[7] = hex2bcd(time->tm_year - 100);
>> }
>> @@ -421,7 +421,7 @@ int smu_set_rtc_time(struct rtc_time *time, int
>> spinwait)
>> hex2bcd(time->tm_hour),
>> time->tm_wday,
>> hex2bcd(time->tm_mday),
>> - hex2bcd(time->tm_mon) + 1,
>> + hex2bcd(time->tm_mon + 1),
>> hex2bcd(time->tm_year - 100));
>> if (rc)
>> return rc;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] macintosh/smu: Fix BCD encoding of the RTC month
2026-11-24 18:06 ` Christophe Leroy (CS GROUP)
@ 2026-11-24 22:32 ` Thorsten Blum
0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-11-24 22:32 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
linuxppc-dev
On Tue, Nov 24, 2026 at 07:06:39PM +0100, Christophe Leroy (CS GROUP) wrote:
> Le 24/11/2026 à 16:46, Christophe Leroy (CS GROUP) a écrit :
> > Le 24/11/2026 à 14:23, Thorsten Blum a écrit :
> > > The SMU expects a one-based month encoded as BCD, while tm_mon is
> > > zero-based. Adding 1 after converting tm_mon to BCD incorrectly encodes
> > > October as 0x0a instead of 0x10.
> > >
> > > Add 1 to tm_mon before converting it to BCD.
> > >
> > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>
> The real origin is commit faa5ee3743ff ("[PATCH] ppc64: Add basic support
> for the SMU chip in iMac G5")
>
> Found on repository https://github.com/mpe/linux-fullhistory.git
Thanks for the review and for digging this up.
IIRC, we keep the Fixes: tag pointing to the initial git commit rather
than referencing a commit that predates the history, don't we?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-24 22:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:23 [PATCH] macintosh/smu: Fix BCD encoding of the RTC month Thorsten Blum
2026-11-24 15:46 ` Christophe Leroy (CS GROUP)
2026-11-24 18:06 ` Christophe Leroy (CS GROUP)
2026-11-24 22:32 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox