* [PATCH] gpio: ge: Convert to use devm_kstrdup
@ 2015-01-21 1:50 Axel Lin
2015-01-29 9:33 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2015-01-21 1:50 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot
Cc: Kamlakant Patel, Martyn Welch, linux-gpio
Use devm_kstrdup to simplify the error handling path.
Also return -ENOMEM instead of 0 if devm_kstrdup fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/gpio/gpio-ge.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-ge.c b/drivers/gpio/gpio-ge.c
index 6ea9303..f9ac3f3 100644
--- a/drivers/gpio/gpio-ge.c
+++ b/drivers/gpio/gpio-ge.c
@@ -76,9 +76,12 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
}
/* Setup pointers to chip functions */
- bgc->gc.label = kstrdup(pdev->dev.of_node->full_name, GFP_KERNEL);
- if (!bgc->gc.label)
+ bgc->gc.label = devm_kstrdup(&pdev->dev, pdev->dev.of_node->full_name,
+ GFP_KERNEL);
+ if (!bgc->gc.label) {
+ ret = -ENOMEM;
goto err0;
+ }
bgc->gc.base = -1;
bgc->gc.ngpio = (u16)(uintptr_t)of_id->data;
@@ -88,11 +91,9 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
/* This function adds a memory mapped GPIO chip */
ret = gpiochip_add(&bgc->gc);
if (ret)
- goto err1;
+ goto err0;
return 0;
-err1:
- kfree(bgc->gc.label);
err0:
iounmap(regs);
pr_err("%s: GPIO chip registration failed\n",
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: ge: Convert to use devm_kstrdup
2015-01-21 1:50 [PATCH] gpio: ge: Convert to use devm_kstrdup Axel Lin
@ 2015-01-29 9:33 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2015-01-29 9:33 UTC (permalink / raw)
To: Axel Lin; +Cc: Alexandre Courbot, Kamlakant Patel, Martyn Welch, linux-gpio
On Wed, Jan 21, 2015 at 2:50 AM, Axel Lin <axel.lin@ingics.com> wrote:
> Use devm_kstrdup to simplify the error handling path.
> Also return -ENOMEM instead of 0 if devm_kstrdup fails.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-29 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 1:50 [PATCH] gpio: ge: Convert to use devm_kstrdup Axel Lin
2015-01-29 9:33 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.