diff mbox series

[1/2] watchdog: gpio: Add some local helper variables

Message ID 20170926200712.10069-1-linus.walleij@linaro.org
State Superseded
Headers show
Series [1/2] watchdog: gpio: Add some local helper variables | expand

Commit Message

Linus Walleij Sept. 26, 2017, 8:07 p.m. UTC
This add "dev" and "np" variables to make the probe() function
a bit easier to read.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/watchdog/gpio_wdt.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

-- 
2.13.5

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Guenter Roeck Oct. 8, 2017, 4:16 p.m. UTC | #1
On 09/26/2017 01:07 PM, Linus Walleij wrote:
> This add "dev" and "np" variables to make the probe() function

> a bit easier to read.

> 

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Reviewed-by: Guenter Roeck <linux@roeck-us.net>


> ---

>   drivers/watchdog/gpio_wdt.c | 20 +++++++++++---------

>   1 file changed, 11 insertions(+), 9 deletions(-)

> 

> diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c

> index cb66c2f99ff1..448e6c3ba73c 100644

> --- a/drivers/watchdog/gpio_wdt.c

> +++ b/drivers/watchdog/gpio_wdt.c

> @@ -101,6 +101,8 @@ static const struct watchdog_ops gpio_wdt_ops = {

>   

>   static int gpio_wdt_probe(struct platform_device *pdev)

>   {

> +	struct device *dev = &pdev->dev;

> +	struct device_node *np = dev->of_node;

>   	struct gpio_wdt_priv *priv;

>   	enum of_gpio_flags flags;

>   	unsigned int hw_margin;

> @@ -108,19 +110,19 @@ static int gpio_wdt_probe(struct platform_device *pdev)

>   	const char *algo;

>   	int ret;

>   

> -	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);

> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);

>   	if (!priv)

>   		return -ENOMEM;

>   

>   	platform_set_drvdata(pdev, priv);

>   

> -	priv->gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);

> +	priv->gpio = of_get_gpio_flags(np, 0, &flags);

>   	if (!gpio_is_valid(priv->gpio))

>   		return priv->gpio;

>   

>   	priv->active_low = flags & OF_GPIO_ACTIVE_LOW;

>   

> -	ret = of_property_read_string(pdev->dev.of_node, "hw_algo", &algo);

> +	ret = of_property_read_string(np, "hw_algo", &algo);

>   	if (ret)

>   		return ret;

>   	if (!strcmp(algo, "toggle")) {

> @@ -133,12 +135,12 @@ static int gpio_wdt_probe(struct platform_device *pdev)

>   		return -EINVAL;

>   	}

>   

> -	ret = devm_gpio_request_one(&pdev->dev, priv->gpio, f,

> -				    dev_name(&pdev->dev));

> +	ret = devm_gpio_request_one(dev, priv->gpio, f,

> +				    dev_name(dev));

>   	if (ret)

>   		return ret;

>   

> -	ret = of_property_read_u32(pdev->dev.of_node,

> +	ret = of_property_read_u32(np,

>   				   "hw_margin_ms", &hw_margin);

>   	if (ret)

>   		return ret;

> @@ -146,7 +148,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)

>   	if (hw_margin < 2 || hw_margin > 65535)

>   		return -EINVAL;

>   

> -	priv->always_running = of_property_read_bool(pdev->dev.of_node,

> +	priv->always_running = of_property_read_bool(np,

>   						     "always-running");

>   

>   	watchdog_set_drvdata(&priv->wdd, priv);

> @@ -155,9 +157,9 @@ static int gpio_wdt_probe(struct platform_device *pdev)

>   	priv->wdd.ops		= &gpio_wdt_ops;

>   	priv->wdd.min_timeout	= SOFT_TIMEOUT_MIN;

>   	priv->wdd.max_hw_heartbeat_ms = hw_margin;

> -	priv->wdd.parent	= &pdev->dev;

> +	priv->wdd.parent	= dev;

>   

> -	if (watchdog_init_timeout(&priv->wdd, 0, &pdev->dev) < 0)

> +	if (watchdog_init_timeout(&priv->wdd, 0, dev) < 0)

>   		priv->wdd.timeout = SOFT_TIMEOUT_DEF;

>   

>   	watchdog_stop_on_reboot(&priv->wdd);

> 


--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index cb66c2f99ff1..448e6c3ba73c 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -101,6 +101,8 @@  static const struct watchdog_ops gpio_wdt_ops = {
 
 static int gpio_wdt_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
 	struct gpio_wdt_priv *priv;
 	enum of_gpio_flags flags;
 	unsigned int hw_margin;
@@ -108,19 +110,19 @@  static int gpio_wdt_probe(struct platform_device *pdev)
 	const char *algo;
 	int ret;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, priv);
 
-	priv->gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+	priv->gpio = of_get_gpio_flags(np, 0, &flags);
 	if (!gpio_is_valid(priv->gpio))
 		return priv->gpio;
 
 	priv->active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-	ret = of_property_read_string(pdev->dev.of_node, "hw_algo", &algo);
+	ret = of_property_read_string(np, "hw_algo", &algo);
 	if (ret)
 		return ret;
 	if (!strcmp(algo, "toggle")) {
@@ -133,12 +135,12 @@  static int gpio_wdt_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ret = devm_gpio_request_one(&pdev->dev, priv->gpio, f,
-				    dev_name(&pdev->dev));
+	ret = devm_gpio_request_one(dev, priv->gpio, f,
+				    dev_name(dev));
 	if (ret)
 		return ret;
 
-	ret = of_property_read_u32(pdev->dev.of_node,
+	ret = of_property_read_u32(np,
 				   "hw_margin_ms", &hw_margin);
 	if (ret)
 		return ret;
@@ -146,7 +148,7 @@  static int gpio_wdt_probe(struct platform_device *pdev)
 	if (hw_margin < 2 || hw_margin > 65535)
 		return -EINVAL;
 
-	priv->always_running = of_property_read_bool(pdev->dev.of_node,
+	priv->always_running = of_property_read_bool(np,
 						     "always-running");
 
 	watchdog_set_drvdata(&priv->wdd, priv);
@@ -155,9 +157,9 @@  static int gpio_wdt_probe(struct platform_device *pdev)
 	priv->wdd.ops		= &gpio_wdt_ops;
 	priv->wdd.min_timeout	= SOFT_TIMEOUT_MIN;
 	priv->wdd.max_hw_heartbeat_ms = hw_margin;
-	priv->wdd.parent	= &pdev->dev;
+	priv->wdd.parent	= dev;
 
-	if (watchdog_init_timeout(&priv->wdd, 0, &pdev->dev) < 0)
+	if (watchdog_init_timeout(&priv->wdd, 0, dev) < 0)
 		priv->wdd.timeout = SOFT_TIMEOUT_DEF;
 
 	watchdog_stop_on_reboot(&priv->wdd);