mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
ebf9988eca
commit
586e1a1763
|
@ -578,7 +578,7 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
|
||||||
{
|
{
|
||||||
struct regulator_init_data *initdata;
|
struct regulator_init_data *initdata;
|
||||||
int ret;
|
int ret;
|
||||||
int i, j;
|
int i, seq;
|
||||||
|
|
||||||
if ((pdata == NULL) || (pdata->regulator == NULL))
|
if ((pdata == NULL) || (pdata->regulator == NULL))
|
||||||
return;
|
return;
|
||||||
|
@ -586,40 +586,21 @@ static void __devinit device_regulator_init(struct pm860x_chip *chip,
|
||||||
if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
|
if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
|
||||||
pdata->num_regulators = ARRAY_SIZE(regulator_devs);
|
pdata->num_regulators = ARRAY_SIZE(regulator_devs);
|
||||||
|
|
||||||
for (i = 0, j = -1; i < pdata->num_regulators; i++) {
|
for (i = 0, seq = -1; i < pdata->num_regulators; i++) {
|
||||||
initdata = &pdata->regulator[i];
|
initdata = &pdata->regulator[i];
|
||||||
if (strstr(initdata->constraints.name, "BUCK")) {
|
seq = *(unsigned int *)initdata->driver_data;
|
||||||
sscanf(initdata->constraints.name, "BUCK%d", &j);
|
if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) {
|
||||||
/* BUCK1 ~ BUCK3 */
|
dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
|
||||||
if ((j < 1) || (j > 3)) {
|
seq, initdata->constraints.name);
|
||||||
dev_err(chip->dev, "Failed to add constraint "
|
|
||||||
"(%s)\n", initdata->constraints.name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
j = (j - 1) + PM8607_ID_BUCK1;
|
|
||||||
}
|
|
||||||
if (strstr(initdata->constraints.name, "LDO")) {
|
|
||||||
sscanf(initdata->constraints.name, "LDO%d", &j);
|
|
||||||
/* LDO1 ~ LDO15 */
|
|
||||||
if ((j < 1) || (j > 15)) {
|
|
||||||
dev_err(chip->dev, "Failed to add constraint "
|
|
||||||
"(%s)\n", initdata->constraints.name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
j = (j - 1) + PM8607_ID_LDO1;
|
|
||||||
}
|
|
||||||
if (j == -1) {
|
|
||||||
dev_err(chip->dev, "Failed to add constraint (%s)\n",
|
|
||||||
initdata->constraints.name);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
regulator_devs[i].platform_data = &pdata->regulator[i];
|
regulator_devs[i].platform_data = &pdata->regulator[i];
|
||||||
regulator_devs[i].pdata_size = sizeof(struct regulator_init_data);
|
regulator_devs[i].pdata_size = sizeof(struct regulator_init_data);
|
||||||
regulator_devs[i].num_resources = 1;
|
regulator_devs[i].num_resources = 1;
|
||||||
regulator_devs[i].resources = ®ulator_resources[j];
|
regulator_devs[i].resources = ®ulator_resources[seq];
|
||||||
|
|
||||||
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
|
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
|
||||||
®ulator_resources[j], 0);
|
®ulator_resources[seq], 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(chip->dev, "Failed to add regulator subdev\n");
|
dev_err(chip->dev, "Failed to add regulator subdev\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -398,32 +398,33 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
|
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
|
||||||
struct pm8607_regulator_info *info = NULL;
|
struct pm8607_regulator_info *info = NULL;
|
||||||
struct regulator_init_data *pdata;
|
struct regulator_init_data *pdata = pdev->dev.platform_data;
|
||||||
|
struct resource *res;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pdata = pdev->dev.platform_data;
|
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||||
if (pdata == NULL)
|
if (res == NULL) {
|
||||||
|
dev_err(&pdev->dev, "No I/O resource!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
|
for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
|
||||||
info = &pm8607_regulator_info[i];
|
info = &pm8607_regulator_info[i];
|
||||||
if (!strcmp(info->desc.name, pdata->constraints.name))
|
if (info->desc.id == res->start)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i > ARRAY_SIZE(pm8607_regulator_info)) {
|
if ((i < 0) || (i > PM8607_ID_RG_MAX)) {
|
||||||
dev_err(&pdev->dev, "Failed to find regulator %s\n",
|
dev_err(&pdev->dev, "Failed to find regulator %d\n",
|
||||||
pdata->constraints.name);
|
res->start);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
|
info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
|
||||||
info->chip = chip;
|
info->chip = chip;
|
||||||
|
|
||||||
/* check DVC ramp slope double */
|
/* check DVC ramp slope double */
|
||||||
if (!strcmp(info->desc.name, "BUCK3"))
|
if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
|
||||||
if (info->chip->buck3_double)
|
|
||||||
info->slope_double = 1;
|
info->slope_double = 1;
|
||||||
|
|
||||||
|
/* replace driver_data with info */
|
||||||
info->regulator = regulator_register(&info->desc, &pdev->dev,
|
info->regulator = regulator_register(&info->desc, &pdev->dev,
|
||||||
pdata, info);
|
pdata, info);
|
||||||
if (IS_ERR(info->regulator)) {
|
if (IS_ERR(info->regulator)) {
|
||||||
|
|
Loading…
Reference in New Issue