Re: [PATCH v6 3/3] hwmon: (applesmc) Convert to hwmon_device_register_with_info

From: Guenter Roeck

Date: Sun Jul 19 2026 - 10:40:22 EST


On Sat, Jul 11, 2026 at 05:33:23PM +0800, Shih-Yuan Lee wrote:
> The legacy hwmon_device_register() function is deprecated and triggers
> warnings in dmesg. Convert the driver to the modern
> hwmon_device_register_with_info() API.
>
> This conversion does the following:
> - Dynamically allocates standard HWMON temp, fan, and pwm channels.
> - Configures HWMON ops callbacks (.is_visible, .read, .read_string, .write).
> - Standardizes attribute naming to match the HWMON ABI:
> - fanX_output -> fanX_target (HWMON_F_TARGET)
> - fanX_manual -> pwmX_enable (HWMON_PWM_ENABLE)
> - Dynamically registers non-standard fanX_safe attributes under the HWMON
> class directory via extra_groups.
> - Cleans up legacy sysfs nodes, groups, and unused show/store static functions
> to avoid unused symbol compiler warnings.
> - Avoids recursive mutex deadlocks when writing to pwmX_enable by locklessly
> resolving the entry and invoking the underlying raw SMC read/write calls.
> - Avoids UAF race condition on module exit by using unmanaged registration and
> explicitly calling hwmon_device_unregister() as the first step of applesmc_exit(),
> guaranteeing that HWMON nodes are destroyed before static structures are freed.
>
> Signed-off-by: Shih-Yuan Lee <fourdollars@xxxxxxxxxx>

Applied.

Thanks,
Guenter