gpio: ge: Convert to use devm_kstrdup
authorAxel Lin <axel.lin@ingics.com>
Wed, 21 Jan 2015 01:50:06 +0000 (09:50 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 29 Jan 2015 09:33:15 +0000 (10:33 +0100)
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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-ge.c

index 6ea9303..f9ac3f3 100644 (file)
@@ -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",