From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Kamil Debski <kamil@wypas.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 1/2] hwmon: (pwm-fan) add option to stop fan on shutdown
Date: Sun, 22 Dec 2019 23:10:22 +0900 [thread overview]
Message-ID: <1577023823-9615-2-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1577023823-9615-1-git-send-email-akinobu.mita@gmail.com>
The pwm-fan driver leaves the fun running when shutting down the system.
(On the other hand the gpio-fan driver stops it.)
This adds an optional property "disable-state-shutdown" in case someone
wants to stop the fun running when shutting down the system.
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>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/hwmon/pwm-fan.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 42ffd2e..8775d37 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,6 +33,7 @@ struct pwm_fan_ctx {
u8 pulses_per_revolution;
ktime_t sample_start;
struct timer_list rpm_timer;
+ bool disable_state_shutdown;
unsigned int pwm_value;
unsigned int pwm_fan_state;
@@ -292,6 +293,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
mutex_init(&ctx->lock);
+ ctx->disable_state_shutdown =
+ of_property_read_bool(dev->of_node, "disable-state-shutdown");
+
ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
if (IS_ERR(ctx->pwm)) {
ret = PTR_ERR(ctx->pwm);
@@ -390,8 +394,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 +421,22 @@ static int pwm_fan_suspend(struct device *dev)
return 0;
}
+static void pwm_fan_shutdown(struct platform_device *pdev)
+{
+ struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
+
+ if (!ctx->disable_state_shutdown)
+ return;
+
+ 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 +474,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
next prev parent reply other threads:[~2019-12-22 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-22 14:10 [PATCH 0/2] hwmon: (pwm-fan) add option to stop fan on shutdown Akinobu Mita
2019-12-22 14:10 ` Akinobu Mita [this message]
2020-01-08 16:13 ` [PATCH 1/2] " Rob Herring
2020-01-10 5:06 ` Akinobu Mita
2020-01-13 16:03 ` Rob Herring
2019-12-22 14:10 ` [PATCH 2/2] dt-bindings: hwmon: (pwm-fan) add disable-state-shutdown property Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1577023823-9615-2-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=b.zolnierkie@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=kamil@wypas.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).