Re: [PATCH 01/14] treewide: Add backend for macsmc
From: Andy Shevchenko
Date: Fri Dec 04 2026 - 09:07:28 EST
On Fri, Dec 04, 2026 at 08:12:41AM -0500, Atharva Tiwari wrote:
> Split the Apple SMC driver into a common core and a backend
> that handles the actual communication. The existing RTKit
> code moves to its own backend, and nothing changes for
> Apple Silicon.
>
> This lets the same SMC drivers run on other kinds of
> hardware, starting with Intel Macs, as a replacement for
> applesmc.
There are plenty of style related issues in this code, besides the fact
that it begs for a split. Read mailing list archives to understand what
the problems are.
...
> +#include <linux/bitfield.h>
> +#include <linux/device.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/macsmc.h>
> +#include <linux/mutex.h>
> +#include <linux/spinlock.h>
Does it follow IWYU?
...
> +EXPORT_SYMBOL(apple_smc_enter_atomic);
Why no namespace is used?
...
> +int apple_smc_write_atomic(struct apple_smc *smc, smc_key key, const void *buf, size_t size)
> +{
> + guard(spinlock_irqsave)(&smc->lock);
Delimit guard()() with blank line(s) so it will be easier to catch when reading
the code.
> + return smc->be->write_atomic(smc->be_cookie, key, buf, size);
> +}
...
> +int apple_smc_get_key_by_index(struct apple_smc *smc, int index, smc_key *key)
> +{
> + guard(mutex)(&smc->mutex);
> + int ret;
No, we define variables at the top (yes, still).
> + ret = smc->be->get_key_by_index(smc->be_cookie, index, key);
> + *key = swab32(*key);
> +
> + return ret;
> +}
...
The above just something that I see briefly. But you need to revisit the whole
code base.
--
With Best Regards,
Andy Shevchenko