watchdog: mtx1-wdt: use devm_gpio_request_one()
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
@@ -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
Quoted 3 lines · Jingoo Han
Use
devm_gpio_request_one()to make cleanup paths simpler.Signed-off-by Jingoo Han <[email protected]>
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@@ -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
Quoted 7 lines · Guenter Roeck
Quoted 3 lines · Jingoo Han
Use
devm_gpio_request_one()to make cleanup paths simpler.Signed-off-by Jingoo Han <[email protected]>This patch also addresses the missing
gpio_freein the probe error path (if the call tomisc_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
Reviewed-by Guenter Roeck <[email protected]>
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@@ -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
Guenter Roeck
maintainerQuoted 9 lines · Jingoo Han
Quoted 7 lines · Guenter Roeck
Quoted 3 lines · Jingoo Han
Use
devm_gpio_request_one()to make cleanup paths simpler.Signed-off-by Jingoo Han <[email protected]>This patch also addresses the missing
gpio_freein the probe error path (if the call tomisc_register()fails).
Quoted 7 lines
When
devm_gpio_request_one()is used, there is no need to calldevm_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
Hi Jingoo,
Quoted 7 lines
Use
devm_gpio_request_one()to make cleanup paths simpler.Signed-off-by Jingoo Han <[email protected]>--- drivers/watchdog/mtx-1_wdt.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
Patch added to linux-watchdog-next.
Kind regards,
Wim.