Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74b18de9 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij
Browse files

gpio: ge: Convert to use devm_kstrdup



Use devm_kstrdup to simplify the error handling path.
Also return -ENOMEM instead of 0 if devm_kstrdup fails.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ef3b2bd6
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -76,9 +76,12 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
	}
	}


	/* Setup pointers to chip functions */
	/* Setup pointers to chip functions */
	bgc->gc.label = kstrdup(pdev->dev.of_node->full_name, GFP_KERNEL);
	bgc->gc.label = devm_kstrdup(&pdev->dev, pdev->dev.of_node->full_name,
	if (!bgc->gc.label)
				     GFP_KERNEL);
	if (!bgc->gc.label) {
		ret = -ENOMEM;
		goto err0;
		goto err0;
	}


	bgc->gc.base = -1;
	bgc->gc.base = -1;
	bgc->gc.ngpio = (u16)(uintptr_t)of_id->data;
	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 */
	/* This function adds a memory mapped GPIO chip */
	ret = gpiochip_add(&bgc->gc);
	ret = gpiochip_add(&bgc->gc);
	if (ret)
	if (ret)
		goto err1;
		goto err0;


	return 0;
	return 0;
err1:
	kfree(bgc->gc.label);
err0:
err0:
	iounmap(regs);
	iounmap(regs);
	pr_err("%s: GPIO chip registration failed\n",
	pr_err("%s: GPIO chip registration failed\n",