mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Balaji Rao <balajirrao@openmoko.org>
Subject: [PATCH 3/5] mfd: pcf50633 - move creating of regulator devices out of line
Date: Sun, 15 Nov 2009 22:08:54 -0800	[thread overview]
Message-ID: <20091116060854.20162.55542.stgit@localhost.localdomain> (raw)
In-Reply-To: <20091116060611.20162.81714.stgit@localhost.localdomain>

This cleans up pcf50633_probe a bit and lays ground for the patch adding
error handling to the probe function.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/mfd/pcf50633-core.c |   57 +++++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index ff43f34..474a76c 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -438,6 +438,45 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int pcf50633_regulator_dev_register(struct pcf50633 *pcf,
+					   unsigned int num)
+{
+	struct pcf50633_platform_data *pdata = pcf->pdata;
+	struct platform_device *pdev;
+	int error;
+
+	pdev = platform_device_alloc("pcf50633-regltr", num);
+	if (!pdev) {
+		dev_err(pcf->dev,
+			"Not enough memory for regulator device %d\n", num);
+		return -ENOMEM;
+	}
+
+	pdev->dev.parent = pcf->dev;
+
+	error = platform_device_add_data(pdev, &pdata->reg_init_data[num],
+					 sizeof(pdata->reg_init_data[num]));
+	if (error) {
+		dev_err(pcf->dev, "Failed to add platform data for %s: %d\n",
+			dev_name(&pdev->dev), error);
+		goto err_free_dev;
+	}
+
+	error = platform_device_add(pdev);
+	if (error) {
+		dev_err(pcf->dev, "Failed to register %s: %d\n",
+			dev_name(&pdev->dev), error);
+		goto err_free_dev;
+	}
+
+	pcf->regulator_pdev[num] = pdev;
+	return 0;
+
+ err_free_dev:
+	platform_device_put(pdev);
+	return error;
+}
+
 static void
 pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
 						struct platform_device **pdev)
@@ -588,22 +627,8 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
 	pcf50633_client_dev_register(pcf, "pcf50633-adc",
 						&pcf->adc_pdev);
 
-	for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
-		struct platform_device *pdev;
-
-		pdev = platform_device_alloc("pcf50633-regltr", i);
-		if (!pdev) {
-			dev_err(pcf->dev, "Cannot create regulator %d\n", i);
-			continue;
-		}
-
-		pdev->dev.parent = pcf->dev;
-		platform_device_add_data(pdev, &pdata->reg_init_data[i],
-					sizeof(pdata->reg_init_data[i]));
-		pcf->regulator_pdev[i] = pdev;
-
-		platform_device_add(pdev);
-	}
+	for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
+		pcf50633_regulator_dev_register(pcf, i);
 
 	if (enable_irq_wake(client->irq) < 0)
 		dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"


  parent reply	other threads:[~2009-11-16  6:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16  6:08 [PATCH 0/5] pcf50633 - error handling & use threaded IRQs - v2 Dmitry Torokhov
2009-11-16  6:08 ` [PATCH 1/5] mfd: pcf50633 - make 'is_suspended' a bool Dmitry Torokhov
2009-11-16  6:08 ` [PATCH 2/5] mfd: pcf50633 - use threaded interrupts Dmitry Torokhov
2009-11-16  6:08 ` Dmitry Torokhov [this message]
2009-11-16  6:08 ` [PATCH 4/5] mfd: pcf50633 - fix error handling during probe Dmitry Torokhov
2009-11-16  6:09 ` [PATCH 5/5] mfd: pcf50633 - whitespace and formatting fixes Dmitry Torokhov
2009-11-20  9:45 ` [PATCH 0/5] pcf50633 - error handling & use threaded IRQs - v2 Samuel Ortiz
2010-05-07 21:38   ` Lars-Peter Clausen

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=20091116060854.20162.55542.stgit@localhost.localdomain \
    --to=dmitry.torokhov@gmail.com \
    --cc=balajirrao@openmoko.org \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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

Powered by JetHome