[PATCH 2/2] regulator: gpio: Move last remaining memory allocation to devres

From: Harald Geyer
Date: Thu Jan 28 2016 - 15:03:23 EST


Simple cleanup without functional changes.

Signed-off-by: Harald Geyer <harald@xxxxxxxxx>
---
drivers/regulator/gpio-regulator.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 5e2e14d..5fe4921 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -263,11 +263,11 @@ static int gpio_regulator_probe(struct platform_device *pdev)
return PTR_ERR(config);
}

- drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
+ drvdata->desc.name = devm_kstrdup(&pdev->dev, config->supply_name,
+ GFP_KERNEL);
if (drvdata->desc.name == NULL) {
dev_err(&pdev->dev, "Failed to allocate supply name\n");
- ret = -ENOMEM;
- goto err;
+ return -ENOMEM;
}

if (config->nr_gpios != 0) {
@@ -278,7 +278,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev,
"Could not obtain regulator setting GPIOs: %d\n", ret);
- goto err_name;
+ return ret;
}
}

@@ -348,9 +348,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)

err_gpio:
gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
-err_name:
- kfree(drvdata->desc.name);
-err:
+
return ret;
}

@@ -362,8 +360,6 @@ static int gpio_regulator_remove(struct platform_device *pdev)

gpio_free_array(drvdata->gpios, drvdata->nr_gpios);

- kfree(drvdata->desc.name);
-
return 0;
}

--
2.1.4