mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harald Geyer <harald@ccbib.org>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Heiko Stuebner <heiko@sntech.de>
Cc: linux-kernel@vger.kernel.org, Harald Geyer <harald@ccbib.org>
Subject: [PATCH 2/2] regulator: gpio: Move last remaining memory allocation to devres
Date: Thu, 28 Jan 2016 19:55:18 +0000	[thread overview]
Message-ID: <1454010918-29369-3-git-send-email-harald@ccbib.org> (raw)
In-Reply-To: <1454010918-29369-1-git-send-email-harald@ccbib.org>

Simple cleanup without functional changes.

Signed-off-by: Harald Geyer <harald@ccbib.org>
---
 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

      parent reply	other threads:[~2016-01-28 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28 19:55 [PATCH 0/2] regulator: gpio: fix error paths in probe() Harald Geyer
2016-01-28 19:55 ` [PATCH 1/2] regulator: gpio: Avoid unnecessarily copying data structures " Harald Geyer
2016-01-28 23:09   ` Mark Brown
2016-01-29 16:25     ` Harald Geyer
2016-02-03 17:20       ` Mark Brown
2016-01-28 19:55 ` Harald Geyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454010918-29369-3-git-send-email-harald@ccbib.org \
    --to=harald@ccbib.org \
    --cc=broonie@kernel.org \
    --cc=heiko@sntech.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®