Skip to contentSkip to conversation

hwmon: (pwm-fan) stop fan on shutdown

PATCH Applied Akinobu Mita 3 participants 3 messages Jan 20, 2020 – Sep 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hwmon: (pwm-fan) stop fan on shutdown

The pwm-fan driver stops the fan in suspend but leaves the fan on in shutdown. It seems strange to leave the fan on in shutdown because there is no use case in my mind and the gpio-fan driver on the other hand stops in shutdown.

This change turns off the fan in shutdown. If anyone complains then we'll add an optional property to switch the behavior.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Kamil Debski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Uwe Kleine-König <[email protected]>

---
* v2
- remove optional property and just turn off the fan in shutdown

 drivers/hwmon/pwm-fan.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/hwmon/pwm-fan.c +13 -2
index 42ffd2e..30b7b3e 100644
@@ -390,8 +390,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int pwm_fan_suspend(struct device *dev)
+static int pwm_fan_disable(struct device *dev)
 {
 	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
 	struct pwm_args args;
@@ -418,6 +417,17 @@ static int pwm_fan_suspend(struct device *dev)
 	return 0;
 }
 
+static void pwm_fan_shutdown(struct platform_device *pdev)
+{
+	pwm_fan_disable(&pdev->dev);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int pwm_fan_suspend(struct device *dev)
+{
+	return pwm_fan_disable(dev);
+}
+
 static int pwm_fan_resume(struct device *dev)
 {
 	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
@@ -455,6 +465,7 @@ MODULE_DEVICE_TABLE(of, of_pwm_fan_match);
 
 static struct platform_driver pwm_fan_driver = {
 	.probe		= pwm_fan_probe,
+	.shutdown	= pwm_fan_shutdown,
 	.driver	= {
 		.name		= "pwm-fan",
 		.pm		= &pwm_fan_pm,
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 8 lines · Akinobu Mita

The pwm-fan driver stops the fan in suspend but leaves the fan on in shutdown. It seems strange to leave the fan on in shutdown because there is no use case in my mind and the gpio-fan driver on the other hand stops in shutdown.

This change turns off the fan in shutdown. If anyone complains then we'll add an optional property to switch the behavior.

Quoted 8 lines
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Kamil Debski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Uwe Kleine-König <[email protected]>

Applied.

Thanks,
Guenter

Quoted 47 lines

---
* v2
- remove optional property and just turn off the fan in shutdown

 drivers/hwmon/pwm-fan.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/hwmon/pwm-fan.c +13 -2
index 42ffd2e..30b7b3e 100644
@@ -390,8 +390,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int pwm_fan_suspend(struct device *dev)
+static int pwm_fan_disable(struct device *dev)
 {
 	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
 	struct pwm_args args;
@@ -418,6 +417,17 @@ static int pwm_fan_suspend(struct device *dev)
 	return 0;
 }
 
+static void pwm_fan_shutdown(struct platform_device *pdev)
+{
+	pwm_fan_disable(&pdev->dev);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int pwm_fan_suspend(struct device *dev)
+{
+	return pwm_fan_disable(dev);
+}
+
 static int pwm_fan_resume(struct device *dev)
 {
 	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
@@ -455,6 +465,7 @@ MODULE_DEVICE_TABLE(of, of_pwm_fan_match);
 
 static struct platform_driver pwm_fan_driver = {
 	.probe		= pwm_fan_probe,
+	.shutdown	= pwm_fan_shutdown,
 	.driver	= {
 		.name		= "pwm-fan",
 		.pm		= &pwm_fan_pm,
#2 lore raw
In reply to Akinobu Mita

Hi Akinobu,

Can you add optional properties to switch the behavior?
For the use case below, the pwm fan should not stop when the device is shutdown by the system reboot. Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered.