[PATCH] hwmon: gpio-fan: allow to stop FANs when CONFIG_PM is disabled

Gabor Juhos posted 1 patch 4 days, 11 hours ago
drivers/hwmon/gpio-fan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hwmon: gpio-fan: allow to stop FANs when CONFIG_PM is disabled
Posted by Gabor Juhos 4 days, 11 hours ago
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>
---
 drivers/hwmon/gpio-fan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index 516c34bb61c9cfa2927d31ee6459c8306be2fb5b..37645e9141dc7034fd440afed695af57829ec900 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -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;
 	}
 

---
base-commit: 1117702454262fb361869451be5b006c022eb08a
change-id: 20260202-gpio-fan-stop-fix-9ef4c26a9364

Best regards,
-- 
Gabor Juhos <j4g8y7@gmail.com>
Re: [PATCH] hwmon: gpio-fan: allow to stop FANs when CONFIG_PM is disabled
Posted by Guenter Roeck 4 days, 10 hours ago
On Mon, Feb 02, 2026 at 04:58:57PM +0100, Gabor Juhos wrote:
> 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>

Applied.

Thanks,
Guenter