From: Moritz Fischer <mdf@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
sre@kernel.org, robh+dt@kernel.org, andy.shevchenko@gmail.com,
Moritz Fischer <mdf@kernel.org>
Subject: [PATCH v3 2/2] power: reset: gpio-poweroff: Support for timeout from device property
Date: Thu, 22 Feb 2018 15:17:14 -0800 [thread overview]
Message-ID: <20180222231714.11843-2-mdf@kernel.org> (raw)
In-Reply-To: <20180222231714.11843-1-mdf@kernel.org>
Add support for reading a timeout value from device property.
Fall back to previous default of 3s if nothing is specified.
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
Changes from v2:
- use device_property_read_{bool,u32} instead of of equivalent
Changes from v1:
- of_property_read_u32() overwrites the output only if it succeeds,
simplify error handling
---
drivers/power/reset/gpio-poweroff.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
index be3d81ff51cc..6273ad3b411d 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -19,11 +19,13 @@
#include <linux/of_platform.h>
#include <linux/module.h>
+#define DEFAULT_TIMEOUT_MS 3000
/*
* Hold configuration here, cannot be more than one instance of the driver
* since pm_power_off itself is global.
*/
static struct gpio_desc *reset_gpio;
+static u32 timeout = DEFAULT_TIMEOUT_MS;
static void gpio_poweroff_do_poweroff(void)
{
@@ -40,7 +42,7 @@ static void gpio_poweroff_do_poweroff(void)
gpiod_set_value(reset_gpio, 1);
/* give it some time */
- mdelay(3000);
+ mdelay(timeout);
WARN_ON(1);
}
@@ -58,12 +60,14 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
return -EBUSY;
}
- input = of_property_read_bool(pdev->dev.of_node, "input");
+ input = device_property_read_bool(&pdev->dev, "input");
if (input)
flags = GPIOD_IN;
else
flags = GPIOD_OUT_LOW;
+ device_property_read_u32(&pdev->dev, "timeout-ms", &timeout);
+
reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
--
2.16.1
next prev parent reply other threads:[~2018-02-22 23:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 23:17 [PATCH v3 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout-ms' property Moritz Fischer
2018-02-22 23:17 ` Moritz Fischer [this message]
2018-03-09 16:19 ` [PATCH v3 2/2] power: reset: gpio-poweroff: Support for timeout from device property Sebastian Reichel
2018-03-01 23:26 ` [PATCH v3 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout-ms' property Rob Herring
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=20180222231714.11843-2-mdf@kernel.org \
--to=mdf@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sre@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