Skip to contentSkip to conversation

watchdog: mtx1-wdt: use devm_gpio_request_one()

PATCH RESEND In review Jingoo Han 3 participants 5 messages Apr 29, 2013 – May 26, 2013 Watchdog device drivers

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH RESEND 1/2 watchdog: mtx1-wdt: use devm_gpio_request_one()

Use devm_gpio_request_one() to make cleanup paths simpler.

---
 drivers/watchdog/mtx-1_wdt.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/watchdog/mtx-1_wdt.c +1 -2
index 14dab6f..b434111 100644
@@ -209,7 +209,7 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
 	int ret;
 
 	mtx1_wdt_device.gpio = pdev->resource[0].start;
-	ret = gpio_request_one(mtx1_wdt_device.gpio,
+	ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio,
 				GPIOF_OUT_INIT_HIGH, "mtx1-wdt");
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to request gpio");
@@ -241,7 +241,6 @@ static int mtx1_wdt_remove(struct platform_device *pdev)
 		wait_for_completion(&mtx1_wdt_device.stop);
 	}
 
-	gpio_free(mtx1_wdt_device.gpio);
 	misc_deregister(&mtx1_wdt_misc);
 	return 0;
 }
Signature · 1 line
1.7.2.5
maintainer Reviewed-by on v1 1/2
#1 lore raw
Quoted 3 lines · Jingoo Han

Use devm_gpio_request_one() to make cleanup paths simpler.

This patch also addresses the missing gpio_free in the probe error path (if the call to misc_register() fails).

Quoted 34 lines
---
 drivers/watchdog/mtx-1_wdt.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/watchdog/mtx-1_wdt.c +1 -2
index 14dab6f..b434111 100644
@@ -209,7 +209,7 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
 	int ret;
 
 	mtx1_wdt_device.gpio = pdev->resource[0].start;
-	ret = gpio_request_one(mtx1_wdt_device.gpio,
+	ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio,
 				GPIOF_OUT_INIT_HIGH, "mtx1-wdt");
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to request gpio");
@@ -241,7 +241,6 @@ static int mtx1_wdt_remove(struct platform_device *pdev)
 		wait_for_completion(&mtx1_wdt_device.stop);
 	}
 
-	gpio_free(mtx1_wdt_device.gpio);
 	misc_deregister(&mtx1_wdt_misc);
 	return 0;
 }
Signature · 7 lines
1.7.2.5


--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw
Quoted 7 lines · Guenter Roeck
Quoted 3 lines · Jingoo Han

Use devm_gpio_request_one() to make cleanup paths simpler.

This patch also addresses the missing gpio_free in the probe error path (if the call to misc_register() fails).

When devm_gpio_request_one() is used, there is no need to call devm_gpio_free().

It is because, these resource managed functions such as devm_gpio_request_one() allow the driver core to automatically clean up any allocation, when probe function fails.

Quoted 2 lines

Thank you for your reviewing.

Best regards,
Jingoo Han

Quoted 35 lines
Quoted 35 lines
---
 drivers/watchdog/mtx-1_wdt.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/watchdog/mtx-1_wdt.c +1 -3
index 14dab6f..b434111 100644
@@ -209,7 +209,7 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
 	int ret;
 
 	mtx1_wdt_device.gpio = pdev->resource[0].start;
-	ret = gpio_request_one(mtx1_wdt_device.gpio,
+	ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio,
 				GPIOF_OUT_INIT_HIGH, "mtx1-wdt");
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to request gpio");
@@ -241,7 +241,6 @@ static int mtx1_wdt_remove(struct platform_device *pdev)
 		wait_for_completion(&mtx1_wdt_device.stop);
 	}
 
-	gpio_free(mtx1_wdt_device.gpio);
 	misc_deregister(&mtx1_wdt_misc);
 	return 0;
 }
--

1.7.2.5

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

maintainer
#3 lore raw
Quoted 9 lines · Jingoo Han
Quoted 7 lines · Guenter Roeck
Quoted 3 lines · Jingoo Han

Use devm_gpio_request_one() to make cleanup paths simpler.

This patch also addresses the missing gpio_free in the probe error path (if the call to misc_register() fails).

Quoted 7 lines

When devm_gpio_request_one() is used, there is no need to call devm_gpio_free().

It is because, these resource managed functions such as devm_gpio_request_one() allow the driver core to automatically clean up any allocation, when probe function fails.

I am well aware of this.

I said this patch _addresses_ a problem, not that it creates one.

Guenter