mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 18:23:53 +08:00
regulator: fixed: update to devm_* API
Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
e31108cad3
commit
84d0ffbe28
@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (drvdata == NULL) {
|
if (drvdata == NULL) {
|
||||||
dev_err(&pdev->dev, "Failed to allocate device data\n");
|
dev_err(&pdev->dev, "Failed to allocate device data\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
|
drvdata->desc.name = devm_kstrdup(&pdev->dev,
|
||||||
|
config->supply_name,
|
||||||
|
GFP_KERNEL);
|
||||||
if (drvdata->desc.name == NULL) {
|
if (drvdata->desc.name == NULL) {
|
||||||
dev_err(&pdev->dev, "Failed to allocate supply name\n");
|
dev_err(&pdev->dev, "Failed to allocate supply name\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
drvdata->desc.type = REGULATOR_VOLTAGE;
|
drvdata->desc.type = REGULATOR_VOLTAGE;
|
||||||
drvdata->desc.owner = THIS_MODULE;
|
drvdata->desc.owner = THIS_MODULE;
|
||||||
@ -149,13 +149,13 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
drvdata->desc.enable_time = config->startup_delay;
|
drvdata->desc.enable_time = config->startup_delay;
|
||||||
|
|
||||||
if (config->input_supply) {
|
if (config->input_supply) {
|
||||||
drvdata->desc.supply_name = kstrdup(config->input_supply,
|
drvdata->desc.supply_name = devm_kstrdup(&pdev->dev,
|
||||||
GFP_KERNEL);
|
config->input_supply,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!drvdata->desc.supply_name) {
|
if (!drvdata->desc.supply_name) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"Failed to allocate input supply\n");
|
"Failed to allocate input supply\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +186,12 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
cfg.driver_data = drvdata;
|
cfg.driver_data = drvdata;
|
||||||
cfg.of_node = pdev->dev.of_node;
|
cfg.of_node = pdev->dev.of_node;
|
||||||
|
|
||||||
drvdata->dev = regulator_register(&drvdata->desc, &cfg);
|
drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
|
||||||
|
&cfg);
|
||||||
if (IS_ERR(drvdata->dev)) {
|
if (IS_ERR(drvdata->dev)) {
|
||||||
ret = PTR_ERR(drvdata->dev);
|
ret = PTR_ERR(drvdata->dev);
|
||||||
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
|
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
|
||||||
goto err_input;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, drvdata);
|
platform_set_drvdata(pdev, drvdata);
|
||||||
@ -199,24 +200,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
drvdata->desc.fixed_uV);
|
drvdata->desc.fixed_uV);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_input:
|
|
||||||
kfree(drvdata->desc.supply_name);
|
|
||||||
err_name:
|
|
||||||
kfree(drvdata->desc.name);
|
|
||||||
err:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reg_fixed_voltage_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
regulator_unregister(drvdata->dev);
|
|
||||||
kfree(drvdata->desc.supply_name);
|
|
||||||
kfree(drvdata->desc.name);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_OF)
|
#if defined(CONFIG_OF)
|
||||||
@ -229,7 +212,6 @@ MODULE_DEVICE_TABLE(of, fixed_of_match);
|
|||||||
|
|
||||||
static struct platform_driver regulator_fixed_voltage_driver = {
|
static struct platform_driver regulator_fixed_voltage_driver = {
|
||||||
.probe = reg_fixed_voltage_probe,
|
.probe = reg_fixed_voltage_probe,
|
||||||
.remove = reg_fixed_voltage_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "reg-fixed-voltage",
|
.name = "reg-fixed-voltage",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
Loading…
Reference in New Issue
Block a user