lkml.org 
[lkml]   [2009]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] mfd: pcf50633 - move creating of regulator devices out of line
Date
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"


\
 
 \ /
  Last update: 2009-11-16 07:13    [W:0.047 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site