On Fri, Dec 04, 2026 at 08:12:47AM -0500, Atharva Tiwari wrote:
> Make macsmc-rtc work on Intel Macs. The ACPI RTC doesn't
> work correctly on T2 Macs, so the clock from the SMC is
> used instead.
> 
> On these machines the time offset is kept in the SMC instead
> of NVMEM, and the clock rate is read from the SMC too.

...

> +static bool force_clkm;
> +module_param(force_clkm, bool, 0644);
> +MODULE_PARM_DESC(force_clkm, "Force CLKM Key, instead of trying to use 
> CLKL");

No, why?!

...

>  struct macsmc_rtc {
>       struct device *dev;
>       struct apple_smc *smc;
>       struct rtc_device *rtc_dev;
>       struct nvmem_cell *rtc_offset;
> +     uint8_t shift;

No, use kernel types.

> +     bool async_rtc;
>  };

...

> +static int macsmc_rtc_read_clkl(struct macsmc_rtc *rtc, u64 *ctr)
> +{
> +     u64 request = 0xffffffffffffULL;
> +     u64 response = 0;
> +     int i, j, ret;
> +
> +     for (i = 0; i < 4; i++) {
> +             for (j = 0; j < 40; j++) {
> +                     ret = apple_smc_write(rtc->smc, SMC_KEY(CLKL), 
> &request, RTC_BYTES);
> +                     if (ret == RTC_BYTES)
> +                             break;
> +             }
> +             if (ret != RTC_BYTES)
> +                     continue;
> +
> +             msleep(20);
> +
> +             for (j = 0; j < 20; j++) {
> +                     ret = apple_smc_read(rtc->smc, SMC_KEY(CLKL), 
> &response, RTC_BYTES);
> +                     if (ret == RTC_BYTES) {
> +                             if ((response & 0x7fff) == 5 || (response & 
> 0x7fff) == 6)
> +                                     return -EAGAIN;
> +
> +                             if (response != 0xffffffffffffULL) {
> +                                     *ctr = response;
> +                                     return RTC_BYTES;
> +                             }
> +                     }
> +                     fsleep(1000);
> +             }
> +     }
> +
> +     return -EIO;
> +}

Really, folks, read the last a year code or so to understand why the above is
no go (style-wise). It's your homework, you can find all of the typical issues
in the mailing list archives.

...

> +MODULE_ALIAS("platform:macsmc-rtc");

Are you sure it's a best approach?

...

Overall impression that you copied'n'pasted AI slop without much effort made on
editing and understanding. Also looks like each patch requires a logical split
to a mini-series.

-- 
With Best Regards,
Andy Shevchenko



Reply via email to