Re: [PATCH] macintosh: fix via-pmu and via-cuda build without RTC_CLASS

From: Christophe Leroy
Date: Sun Apr 10 2022 - 03:05:22 EST




Le 09/04/2022 à 04:08, Randy Dunlap a écrit :
> Fix build when RTC_CLASS is not set/enabled.
> Eliminates these build errors:
>
> m68k-linux-ld: drivers/macintosh/via-pmu.o: in function `pmu_set_rtc_time':
> drivers/macintosh/via-pmu.c:1769: undefined reference to `rtc_tm_to_time64'
> m68k-linux-ld: drivers/macintosh/via-cuda.o: in function `cuda_set_rtc_time':
> drivers/macintosh/via-cuda.c:797: undefined reference to `rtc_tm_to_time64'

You don't need RTC_CLASS for that. All you need is RTC_LIB I think.

What about selecting RTC_LIB from m68k Kconfig just like powerpc and a
few architectures do ?

See
https://elixir.bootlin.com/linux/v5.18-rc1/source/arch/powerpc/Kconfig#L269

Otherwise, I think it would be better to move (and rename)
rtc_tm_to_time64() into kernel/time/time.c instead of opencoding it twice.

Christophe


>
> Fixes: 0792a2c8e0bb ("macintosh: Use common code to access RTC")
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Finn Thain <fthain@xxxxxxxxxxxxxx>
> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
> Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
> ---
> drivers/macintosh/via-cuda.c | 5 ++++-
> drivers/macintosh/via-pmu.c | 5 ++++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> --- a/drivers/macintosh/via-cuda.c
> +++ b/drivers/macintosh/via-cuda.c
> @@ -794,7 +794,10 @@ int cuda_set_rtc_time(struct rtc_time *t
> u32 now;
> struct adb_request req;
>
> - now = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
> + now = lower_32_bits(mktime64(((unsigned int)tm->tm_year + 1900),
> + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
> + tm->tm_min, tm->tm_sec)
> + + RTC_OFFSET);
> if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
> now >> 24, now >> 16, now >> 8, now) < 0)
> return -ENXIO;
> --- a/drivers/macintosh/via-pmu.c
> +++ b/drivers/macintosh/via-pmu.c
> @@ -1766,7 +1766,10 @@ int pmu_set_rtc_time(struct rtc_time *tm
> u32 now;
> struct adb_request req;
>
> - now = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
> + now = lower_32_bits(mktime64(((unsigned int)tm->tm_year + 1900),
> + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
> + tm->tm_min, tm->tm_sec)
> + + RTC_OFFSET);
> if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
> now >> 24, now >> 16, now >> 8, now) < 0)
> return -ENXIO;