linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/11] mfd: pcf50633: Check return value of platform_device_add()
Date: Thu, 28 Aug 2014 14:14:15 +0100	[thread overview]
Message-ID: <1409231657-18294-9-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1409231657-18294-1-git-send-email-lee.jones@linaro.org>

The return value of platform_device_add() is checked after every
other use throughout the kernel.

We're also sliding in another cheeky dev_err() => dev_warn() change
as we're not actually erroring out here, rather reporting the fact
that something's gone wrong, but carrying on regardless.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/pcf50633-core.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index c87f7a0..e15c060 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client,
 				const struct i2c_device_id *ids)
 {
 	struct pcf50633 *pcf;
+	struct platform_device *pdev;
 	struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev);
-	int i, ret;
+	int i, j, ret;
 	int version, variant;
 
 	if (!client->irq) {
@@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client,
 
 
 	for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
-		struct platform_device *pdev;
-		int j;
-
 		pdev = platform_device_alloc("pcf50633-regulator", i);
 		if (!pdev)
 			return -ENOMEM;
@@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client,
 		pdev->dev.parent = pcf->dev;
 		ret = platform_device_add_data(pdev, &pdata->reg_init_data[i],
 					       sizeof(pdata->reg_init_data[i]));
-		if (ret) {
-			platform_device_put(pdev);
-			for (j = 0; j < i; j++)
-				platform_device_put(pcf->regulator_pdev[j]);
-			return ret;
-		}
-		pcf->regulator_pdev[i] = pdev;
+		if (ret)
+			goto err;
+
+		ret = platform_device_add(pdev);
+		if (ret)
+			goto err;
 
-		platform_device_add(pdev);
+		pcf->regulator_pdev[i] = pdev;
 	}
 
 	ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
 	if (ret)
-		dev_err(pcf->dev, "error creating sysfs entries\n");
+		dev_warn(pcf->dev, "error creating sysfs entries\n");
 
 	if (pdata->probe_done)
 		pdata->probe_done(pcf);
 
 	return 0;
+
+err:
+	platform_device_put(pdev);
+	for (j = 0; j < i; j++)
+		platform_device_put(pcf->regulator_pdev[j]);
+
+	return ret;
 }
 
 static int pcf50633_remove(struct i2c_client *client)
-- 
1.9.1

  parent reply	other threads:[~2014-08-28 13:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 13:14 [PATCH 01/11] iio: sensors-core: st: Check st_sensors_set_drdy_int_pin()'s return value Lee Jones
2014-08-28 13:14 ` [PATCH 02/11] misc: st_core: Protect unsigned value against becoming negative Lee Jones
2014-08-28 13:14 ` [PATCH 03/11] misc: st_kim: Increase size of dev_name buffer to incorporate termination Lee Jones
2014-08-28 13:14 ` [PATCH 04/11] mfd: htc-i2cpld: container_of() cannot return NULL Lee Jones
2014-08-28 13:14 ` [PATCH 05/11] mfd: htc-i2cpld: Use '!variable' instead of 'variable == NULL' Lee Jones
2014-08-28 13:14 ` [PATCH 06/11] mfd: htc-i2cpld: Rectify pointer offset error Lee Jones
2014-08-28 13:14 ` [PATCH 07/11] mfd: wm5102: Insert missing break in case statement Lee Jones
2014-08-28 13:14 ` [PATCH 08/11] mfd: max77686: Remove check which is always true Lee Jones
2014-08-28 13:14 ` Lee Jones [this message]
2014-08-28 13:14 ` [PATCH 10/11] mfd: twl4030-irq: Check return value from twl_i2c_write() - warn() on failure Lee Jones
2014-08-28 13:14 ` [PATCH 11/11] mfd: sm501: Avoid implicit sign extension Lee Jones
2014-08-30  9:49 ` [PATCH 01/11] iio: sensors-core: st: Check st_sensors_set_drdy_int_pin()'s return value Jonathan Cameron

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=1409231657-18294-9-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).