Re: [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT

2018-02-20 Thread Moritz Fischer
On Tue, Feb 20, 2018 at 04:12:59PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 20, 2018 at 12:59 AM, Moritz Fischer  wrote:
> > Add support for reading a timeout value from devicetree.
> > Fall back to previous default of 3s if nothing is specified.
> 
> 
> > +   of_property_read_u32(pdev->dev.of_node, "timeout_ms", &timeout);
> 
> Perhaps stop being OF-centric by using device_property_read_u32() instead?

Good catch, will do. Should probably change commit message accordingly,
too.

Thanks,

Moritz


signature.asc
Description: PGP signature


Re: [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT

2018-02-20 Thread Andy Shevchenko
On Tue, Feb 20, 2018 at 12:59 AM, Moritz Fischer  wrote:
> Add support for reading a timeout value from devicetree.
> Fall back to previous default of 3s if nothing is specified.


> +   of_property_read_u32(pdev->dev.of_node, "timeout_ms", &timeout);

Perhaps stop being OF-centric by using device_property_read_u32() instead?

-- 
With Best Regards,
Andy Shevchenko


[PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT

2018-02-19 Thread Moritz Fischer
Add support for reading a timeout value from devicetree.
Fall back to previous default of 3s if nothing is specified.

Signed-off-by: Moritz Fischer 
---

Changes from v1:
- of_property_read_u32() overwrites the output only if it succeeds,
  simplify error handling
---
 drivers/power/reset/gpio-poweroff.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/gpio-poweroff.c 
b/drivers/power/reset/gpio-poweroff.c
index be3d81ff51cc..265cc37646a9 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -19,11 +19,13 @@
 #include 
 #include 
 
+#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);
 }
@@ -64,6 +66,8 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
else
flags = GPIOD_OUT_LOW;
 
+   of_property_read_u32(pdev->dev.of_node, "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