Commit 586e1a1763d34bd256f3f1e77293d8386e4871d2

Authored by Haojian Zhuang
Committed by Samuel Ortiz
1 parent ebf9988eca

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>

Showing 2 changed files with 21 additions and 39 deletions Side-by-side Diff

drivers/mfd/88pm860x-core.c
... ... @@ -578,7 +578,7 @@
578 578 {
579 579 struct regulator_init_data *initdata;
580 580 int ret;
581   - int i, j;
  581 + int i, seq;
582 582  
583 583 if ((pdata == NULL) || (pdata->regulator == NULL))
584 584 return;
585 585  
586 586  
587 587  
... ... @@ -586,40 +586,21 @@
586 586 if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
587 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 590 initdata = &pdata->regulator[i];
591   - if (strstr(initdata->constraints.name, "BUCK")) {
592   - sscanf(initdata->constraints.name, "BUCK%d", &j);
593   - /* BUCK1 ~ BUCK3 */
594   - if ((j < 1) || (j > 3)) {
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);
  591 + seq = *(unsigned int *)initdata->driver_data;
  592 + if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) {
  593 + dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
  594 + seq, initdata->constraints.name);
614 595 goto out;
615 596 }
616 597 regulator_devs[i].platform_data = &pdata->regulator[i];
617 598 regulator_devs[i].pdata_size = sizeof(struct regulator_init_data);
618 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 602 ret = mfd_add_devices(chip->dev, 0, &regulator_devs[i], 1,
622   - &regulator_resources[j], 0);
  603 + &regulator_resources[seq], 0);
623 604 if (ret < 0) {
624 605 dev_err(chip->dev, "Failed to add regulator subdev\n");
625 606 goto out;
drivers/regulator/88pm8607.c
... ... @@ -398,32 +398,33 @@
398 398 {
399 399 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
400 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 403 int i;
403 404  
404   - pdata = pdev->dev.platform_data;
405   - if (pdata == NULL)
  405 + res = platform_get_resource(pdev, IORESOURCE_IO, 0);
  406 + if (res == NULL) {
  407 + dev_err(&pdev->dev, "No I/O resource!\n");
406 408 return -EINVAL;
407   -
  409 + }
408 410 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
409 411 info = &pm8607_regulator_info[i];
410   - if (!strcmp(info->desc.name, pdata->constraints.name))
  412 + if (info->desc.id == res->start)
411 413 break;
412 414 }
413   - if (i > ARRAY_SIZE(pm8607_regulator_info)) {
414   - dev_err(&pdev->dev, "Failed to find regulator %s\n",
415   - pdata->constraints.name);
  415 + if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
  416 + dev_err(&pdev->dev, "Failed to find regulator %d\n",
  417 + res->start);
416 418 return -EINVAL;
417 419 }
418   -
419 420 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
420 421 info->chip = chip;
421 422  
422 423 /* check DVC ramp slope double */
423   - if (!strcmp(info->desc.name, "BUCK3"))
424   - if (info->chip->buck3_double)
425   - info->slope_double = 1;
  424 + if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
  425 + info->slope_double = 1;
426 426  
  427 + /* replace driver_data with info */
427 428 info->regulator = regulator_register(&info->desc, &pdev->dev,
428 429 pdata, info);
429 430 if (IS_ERR(info->regulator)) {