aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max77686.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-08-04 22:11:16 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-28 14:00:26 -0400
commitcb44cdeacd693ca964deab9d9f698920bb73529d (patch)
treee38a4216e4706f2f140a9461c9afefee02ade2a8 /drivers/regulator/max77686.c
parent2c58e2669f197ab0fd5e7552fe82f7bc7d06b15d (diff)
regulator: max77686: Use array to save pointer to rdev
MAX77686_REGULATORS is known in compile time. Use array to save pointer to rdev makes the code simpler. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max77686.c')
-rw-r--r--drivers/regulator/max77686.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 87544b34628a..2a67d08658ad 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -66,7 +66,7 @@ enum max77686_ramp_rate {
66}; 66};
67 67
68struct max77686_data { 68struct max77686_data {
69 struct regulator_dev **rdev; 69 struct regulator_dev *rdev[MAX77686_REGULATORS];
70}; 70};
71 71
72static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) 72static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
@@ -284,10 +284,8 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev)
284{ 284{
285 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 285 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
286 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); 286 struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
287 struct regulator_dev **rdev;
288 struct max77686_data *max77686; 287 struct max77686_data *max77686;
289 int i, size; 288 int i, ret = 0;
290 int ret = 0;
291 struct regulator_config config = { }; 289 struct regulator_config config = { };
292 290
293 dev_dbg(&pdev->dev, "%s\n", __func__); 291 dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -314,12 +312,6 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev)
314 if (!max77686) 312 if (!max77686)
315 return -ENOMEM; 313 return -ENOMEM;
316 314
317 size = sizeof(struct regulator_dev *) * MAX77686_REGULATORS;
318 max77686->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
319 if (!max77686->rdev)
320 return -ENOMEM;
321
322 rdev = max77686->rdev;
323 config.dev = &pdev->dev; 315 config.dev = &pdev->dev;
324 config.regmap = iodev->regmap; 316 config.regmap = iodev->regmap;
325 platform_set_drvdata(pdev, max77686); 317 platform_set_drvdata(pdev, max77686);
@@ -328,32 +320,30 @@ static __devinit int max77686_pmic_probe(struct platform_device *pdev)
328 config.init_data = pdata->regulators[i].initdata; 320 config.init_data = pdata->regulators[i].initdata;
329 config.of_node = pdata->regulators[i].of_node; 321 config.of_node = pdata->regulators[i].of_node;
330 322
331 rdev[i] = regulator_register(&regulators[i], &config); 323 max77686->rdev[i] = regulator_register(&regulators[i], &config);
332 if (IS_ERR(rdev[i])) { 324 if (IS_ERR(max77686->rdev[i])) {
333 ret = PTR_ERR(rdev[i]); 325 ret = PTR_ERR(max77686->rdev[i]);
334 dev_err(&pdev->dev, 326 dev_err(&pdev->dev,
335 "regulator init failed for %d\n", i); 327 "regulator init failed for %d\n", i);
336 rdev[i] = NULL; 328 max77686->rdev[i] = NULL;
337 goto err; 329 goto err;
338 } 330 }
339 } 331 }
340 332
341 return 0; 333 return 0;
342err: 334err:
343 while (--i >= 0) 335 while (--i >= 0)
344 regulator_unregister(rdev[i]); 336 regulator_unregister(max77686->rdev[i]);
345 return ret; 337 return ret;
346} 338}
347 339
348static int __devexit max77686_pmic_remove(struct platform_device *pdev) 340static int __devexit max77686_pmic_remove(struct platform_device *pdev)
349{ 341{
350 struct max77686_data *max77686 = platform_get_drvdata(pdev); 342 struct max77686_data *max77686 = platform_get_drvdata(pdev);
351 struct regulator_dev **rdev = max77686->rdev;
352 int i; 343 int i;
353 344
354 for (i = 0; i < MAX77686_REGULATORS; i++) 345 for (i = 0; i < MAX77686_REGULATORS; i++)
355 if (rdev[i]) 346 regulator_unregister(max77686->rdev[i]);
356 regulator_unregister(rdev[i]);
357 347
358 return 0; 348 return 0;
359} 349}