Re: [PATCH] hwmon: (macsmc) Allow enable writing to fan speeds by modifying sysfs

From: Guenter Roeck

Date: Mon Oct 26 2026 - 17:23:23 EST


On Sun, Oct 18, 2026 at 05:02:48PM +0530, Aditya Garg wrote:
> The fan_control module parameter in the driver enables/disables the user's
> ability to manually modify the fan speeds. In case the user attempts to
> change the module parameter via sysfs rather than at the time of modprobe,
> changing fan speeds is still restricted.
>
> The reason behind this is because during probe the fan_control variable is
> used to restrict the user in the following two ways:
>
> 1. if (!fan_control || hwmon->fan.fans[channel].mode.macsmc_key == 0)
> return -EOPNOTSUPP;
>
> Here, if disabled, the OS will return an error and will not allow changing
> the speeds.
>
> 2. if (fan->attrs & BIT(attr)) {
> if (attr == hwmon_fan_target && fan_control && fan->mode.macsmc_key)
> return 0644;
>
> return 0444;
> }
>
> Here, if disabled, the sysfs files are with permissions 0444.
>
> In case a user changes the module parameter via sysfs, due to the second
> check, the sysfs files remain with permissions 0444, and user isn't able to
> change the speeds.
>
> Since 2 checks are practically unnecessary, and the second is causing problems
> this patch removes the second check. Now, if the module parameter is changed
> via sysfs, the first check will pass and user will be able to modify the fan
> speeds.
>
> Signed-off-by: Aditya Garg <aditya.garg@xxxxxxxxx>

Applied.

Thanks,
Guenter