hwmon: (pwm-fan) stop fan on shutdown
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 20 Jan 2020 15:32:24 +0000 (00:32 +0900)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 23 Jan 2020 21:15:11 +0000 (13:15 -0800)
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>
Link: https://lore.kernel.org/r/1579534344-11694-1-git-send-email-akinobu.mita@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pwm-fan.c

index 42ffd2e5182d57edc3bf3c0e54513f0dc4422bf7..30b7b3ea8836fc97318091ffa548f3e632bd2bf4 100644 (file)
@@ -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,