mirror of https://gitee.com/openkylin/linux.git
regulator: max8997: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
8d581fd01c
commit
4177f95b84
|
@ -1081,7 +1081,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
|
|||
pdata->buck1_voltage[i] +
|
||||
buck1245_voltage_map_desc.step);
|
||||
if (ret < 0)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
max8997->buck2_vol[i] = ret =
|
||||
max8997_get_voltage_proper_val(
|
||||
|
@ -1090,7 +1090,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
|
|||
pdata->buck2_voltage[i] +
|
||||
buck1245_voltage_map_desc.step);
|
||||
if (ret < 0)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
max8997->buck5_vol[i] = ret =
|
||||
max8997_get_voltage_proper_val(
|
||||
|
@ -1099,7 +1099,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
|
|||
pdata->buck5_voltage[i] +
|
||||
buck1245_voltage_map_desc.step);
|
||||
if (ret < 0)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
if (max_buck1 < max8997->buck1_vol[i])
|
||||
max_buck1 = max8997->buck1_vol[i];
|
||||
|
@ -1143,24 +1143,23 @@ static int max8997_pmic_probe(struct platform_device *pdev)
|
|||
!gpio_is_valid(pdata->buck125_gpios[1]) ||
|
||||
!gpio_is_valid(pdata->buck125_gpios[2])) {
|
||||
dev_err(&pdev->dev, "GPIO NOT VALID\n");
|
||||
ret = -EINVAL;
|
||||
goto err_out;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0],
|
||||
"MAX8997 SET1");
|
||||
if (ret)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1],
|
||||
"MAX8997 SET2");
|
||||
if (ret)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2],
|
||||
"MAX8997 SET3");
|
||||
if (ret)
|
||||
goto err_out;
|
||||
return ret;
|
||||
|
||||
gpio_direction_output(pdata->buck125_gpios[0],
|
||||
(max8997->buck125_gpioindex >> 2)
|
||||
|
@ -1205,33 +1204,17 @@ static int max8997_pmic_probe(struct platform_device *pdev)
|
|||
config.driver_data = max8997;
|
||||
config.of_node = pdata->regulators[i].reg_node;
|
||||
|
||||
rdev[i] = regulator_register(®ulators[id], &config);
|
||||
rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id],
|
||||
&config);
|
||||
if (IS_ERR(rdev[i])) {
|
||||
ret = PTR_ERR(rdev[i]);
|
||||
dev_err(max8997->dev, "regulator init failed for %d\n",
|
||||
id);
|
||||
rdev[i] = NULL;
|
||||
goto err;
|
||||
return PTR_ERR(rdev[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
while (--i >= 0)
|
||||
regulator_unregister(rdev[i]);
|
||||
err_out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int max8997_pmic_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct max8997_data *max8997 = platform_get_drvdata(pdev);
|
||||
struct regulator_dev **rdev = max8997->rdev;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < max8997->num_regulators; i++)
|
||||
regulator_unregister(rdev[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct platform_device_id max8997_pmic_id[] = {
|
||||
|
@ -1246,7 +1229,6 @@ static struct platform_driver max8997_pmic_driver = {
|
|||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = max8997_pmic_probe,
|
||||
.remove = max8997_pmic_remove,
|
||||
.id_table = max8997_pmic_id,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue