linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown
@ 2020-01-20 15:32 Akinobu Mita
  2020-01-21  2:16 ` Guenter Roeck
  2021-09-22  5:56 ` Billy Tsai
  0 siblings, 2 replies; 3+ messages in thread
From: Akinobu Mita @ 2020-01-20 15:32 UTC (permalink / raw)
  To: linux-hwmon, linux-pwm
  Cc: Akinobu Mita, Rob Herring, Mark Rutland, Kamil Debski,
	Bartlomiej Zolnierkiewicz, Guenter Roeck, Thierry Reding,
	Uwe Kleine-König

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 <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Kamil Debski <kamil@wypas.org>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* 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(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 42ffd2e..30b7b3e 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -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.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown
  2020-01-20 15:32 [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown Akinobu Mita
@ 2020-01-21  2:16 ` Guenter Roeck
  2021-09-22  5:56 ` Billy Tsai
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-01-21  2:16 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, linux-pwm, Rob Herring, Mark Rutland, Kamil Debski,
	Bartlomiej Zolnierkiewicz, Thierry Reding, Uwe Kleine-König

On Tue, Jan 21, 2020 at 12:32:24AM +0900, Akinobu Mita wrote:
> 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 <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Kamil Debski <kamil@wypas.org>
> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Applied.

Thanks,
Guenter

> ---
> * 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(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 42ffd2e..30b7b3e 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown
  2020-01-20 15:32 [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown Akinobu Mita
  2020-01-21  2:16 ` Guenter Roeck
@ 2021-09-22  5:56 ` Billy Tsai
  1 sibling, 0 replies; 3+ messages in thread
From: Billy Tsai @ 2021-09-22  5:56 UTC (permalink / raw)
  To: akinobu.mita
  Cc: b.zolnierkie, kamil, linux-hwmon, linux-pwm, linux, mark.rutland,
	robh+dt, thierry.reding, u.kleine-koenig, BMC-SW

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-22  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 15:32 [PATCH v2] hwmon: (pwm-fan) stop fan on shutdown Akinobu Mita
2020-01-21  2:16 ` Guenter Roeck
2021-09-22  5:56 ` Billy Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).