aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2011-05-06 05:21:23 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2011-05-26 13:45:38 -0400
commit586e1a1763d34bd256f3f1e77293d8386e4871d2 (patch)
treec02a3a61e0974e669fb58c690d1988c061b28e4e
parentebf9988ecad6727e5ae950fc2c72b963a1bfc0fe (diff)
mfd: Avoid to use constraint name in 88pm860x regulator driver
Avoid to use constraint name in regulator driver. So use regulator id is used instead in platform driver. Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Cc: Liam Girdwood <lrg@slimlogic.co.uk> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/88pm860x-core.c35
-rw-r--r--drivers/regulator/88pm8607.c25
2 files changed, 21 insertions, 39 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 91962ef38c08..17dfe9bb6d27 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -578,7 +578,7 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
578{ 578{
579 struct regulator_init_data *initdata; 579 struct regulator_init_data *initdata;
580 int ret; 580 int ret;
581 int i, j; 581 int i, seq;
582 582
583 if ((pdata == NULL) || (pdata->regulator == NULL)) 583 if ((pdata == NULL) || (pdata->regulator == NULL))
584 return; 584 return;
@@ -586,40 +586,21 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
586 if (pdata->num_regulators > ARRAY_SIZE(regulator_devs)) 586 if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
587 pdata->num_regulators = ARRAY_SIZE(regulator_devs); 587 pdata->num_regulators = ARRAY_SIZE(regulator_devs);
588 588
589 for (i = 0, j = -1; i < pdata->num_regulators; i++) { 589 for (i = 0, seq = -1; i < pdata->num_regulators; i++) {
590 initdata = &pdata->regulator[i]; 590 initdata = &pdata->regulator[i];
591 if (strstr(initdata->constraints.name, "BUCK")) { 591 seq = *(unsigned int *)initdata->driver_data;
592 sscanf(initdata->constraints.name, "BUCK%d", &j); 592 if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) {
593 /* BUCK1 ~ BUCK3 */ 593 dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
594 if ((j < 1) || (j > 3)) { 594 seq, initdata->constraints.name);
595 dev_err(chip->dev, "Failed to add constraint "
596 "(%s)\n", initdata->constraints.name);
597 goto out;
598 }
599 j = (j - 1) + PM8607_ID_BUCK1;
600 }
601 if (strstr(initdata->constraints.name, "LDO")) {
602 sscanf(initdata->constraints.name, "LDO%d", &j);
603 /* LDO1 ~ LDO15 */
604 if ((j < 1) || (j > 15)) {
605 dev_err(chip->dev, "Failed to add constraint "
606 "(%s)\n", initdata->constraints.name);
607 goto out;
608 }
609 j = (j - 1) + PM8607_ID_LDO1;
610 }
611 if (j == -1) {
612 dev_err(chip->dev, "Failed to add constraint (%s)\n",
613 initdata->constraints.name);
614 goto out; 595 goto out;
615 } 596 }
616 regulator_devs[i].platform_data = &pdata->regulator[i]; 597 regulator_devs[i].platform_data = &pdata->regulator[i];
617 regulator_devs[i].pdata_size = sizeof(struct regulator_init_data); 598 regulator_devs[i].pdata_size = sizeof(struct regulator_init_data);
618 regulator_devs[i].num_resources = 1; 599 regulator_devs[i].num_resources = 1;
619 regulator_devs[i].resources = &regulator_resources[j]; 600 regulator_devs[i].resources = &regulator_resources[seq];
620 601
621 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[i], 1, 602 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[i], 1,
622 &regulator_resources[j], 0); 603 &regulator_resources[seq], 0);
623 if (ret < 0) { 604 if (ret < 0) {
624 dev_err(chip->dev, "Failed to add regulator subdev\n"); 605 dev_err(chip->dev, "Failed to add regulator subdev\n");
625 goto out; 606 goto out;
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 784ea7724c7a..1904be9149af 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -398,32 +398,33 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
398{ 398{
399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
400 struct pm8607_regulator_info *info = NULL; 400 struct pm8607_regulator_info *info = NULL;
401 struct regulator_init_data *pdata; 401 struct regulator_init_data *pdata = pdev->dev.platform_data;
402 struct resource *res;
402 int i; 403 int i;
403 404
404 pdata = pdev->dev.platform_data; 405 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
405 if (pdata == NULL) 406 if (res == NULL) {
407 dev_err(&pdev->dev, "No I/O resource!\n");
406 return -EINVAL; 408 return -EINVAL;
407 409 }
408 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { 410 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
409 info = &pm8607_regulator_info[i]; 411 info = &pm8607_regulator_info[i];
410 if (!strcmp(info->desc.name, pdata->constraints.name)) 412 if (info->desc.id == res->start)
411 break; 413 break;
412 } 414 }
413 if (i > ARRAY_SIZE(pm8607_regulator_info)) { 415 if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
414 dev_err(&pdev->dev, "Failed to find regulator %s\n", 416 dev_err(&pdev->dev, "Failed to find regulator %d\n",
415 pdata->constraints.name); 417 res->start);
416 return -EINVAL; 418 return -EINVAL;
417 } 419 }
418
419 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; 420 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
420 info->chip = chip; 421 info->chip = chip;
421 422
422 /* check DVC ramp slope double */ 423 /* check DVC ramp slope double */
423 if (!strcmp(info->desc.name, "BUCK3")) 424 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
424 if (info->chip->buck3_double) 425 info->slope_double = 1;
425 info->slope_double = 1;
426 426
427 /* replace driver_data with info */
427 info->regulator = regulator_register(&info->desc, &pdev->dev, 428 info->regulator = regulator_register(&info->desc, &pdev->dev,
428 pdata, info); 429 pdata, info);
429 if (IS_ERR(info->regulator)) { 430 if (IS_ERR(info->regulator)) {