]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (gpio-fan) Allow to stop FANs when CONFIG_PM is disabled
authorGabor Juhos <j4g8y7@gmail.com>
Mon, 2 Feb 2026 15:58:57 +0000 (16:58 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 2 Feb 2026 17:00:28 +0000 (09:00 -0800)
When CONFIG_PM is disabled, the GPIO controlled FANs can't be stopped by
using the sysfs attributes since commit 0d01110e6356 ("hwmon: (gpio-fan)
Add regulator support").

Using either the 'pwm1' or the 'fan1_target' attribute fails the same way:

  $ echo 0 > /sys/class/hwmon/hwmon1/pwm1
  ash: write error: Function not implemented
  $ echo 0 > /sys/class/hwmon/hwmon1/fan1_target
  ash: write error: Function not implemented

Both commands were working flawlessly before the mentioned commit.

The issue happens because pm_runtime_put_sync() returns with -ENOSYS
when CONFIG_PM is disabled, and the set_fan_speed() function handles
this as an error.

In order to restore the previous behaviour, change the error check in
the set_fan_speed() function to ignore the -ENOSYS error code.

Cc: stable@vger.kernel.org
Fixes: 0d01110e6356 ("hwmon: (gpio-fan) Add regulator support")
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Link: https://lore.kernel.org/r/20260202-gpio-fan-stop-fix-v1-1-c7853183d93d@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/gpio-fan.c

index d7fa021f376e39b79b6a0302377c4516f9861459..a8892ced1e549f9797e6e0375a3201b00aff762e 100644 (file)
@@ -148,7 +148,7 @@ static int set_fan_speed(struct gpio_fan_data *fan_data, int speed_index)
                int ret;
 
                ret = pm_runtime_put_sync(fan_data->dev);
-               if (ret < 0)
+               if (ret < 0 && ret != -ENOSYS)
                        return ret;
        }