Commit 2a9123f1 authored by Vaishali Thakkar's avatar Vaishali Thakkar Committed by Sebastian Reichel

88pm860x_battery: Convert to using managed resources

Use managed resource functions devm_request_threaded_irq and
devm_power_supply_register to simplify error handling.

To be compatible with the change, various gotos are replaced
with direct returns and unneeded labels are dropped. Also,
remove pm860x_battery_remove as it is now redundant.
Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 56d7df87
......@@ -954,46 +954,32 @@ static int pm860x_battery_probe(struct platform_device *pdev)
else
info->resistor = 300; /* set default internal resistor */
info->battery = power_supply_register(&pdev->dev, &pm860x_battery_desc,
NULL);
info->battery = devm_power_supply_register(&pdev->dev,
&pm860x_battery_desc,
NULL);
if (IS_ERR(info->battery))
return PTR_ERR(info->battery);
info->battery->dev.parent = &pdev->dev;
ret = request_threaded_irq(info->irq_cc, NULL,
pm860x_coulomb_handler, IRQF_ONESHOT,
"coulomb", info);
ret = devm_request_threaded_irq(chip->dev, info->irq_cc, NULL,
pm860x_coulomb_handler, IRQF_ONESHOT,
"coulomb", info);
if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
info->irq_cc, ret);
goto out_reg;
return ret;
}
ret = request_threaded_irq(info->irq_batt, NULL, pm860x_batt_handler,
IRQF_ONESHOT, "battery", info);
ret = devm_request_threaded_irq(chip->dev, info->irq_batt, NULL,
pm860x_batt_handler,
IRQF_ONESHOT, "battery", info);
if (ret < 0) {
dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
info->irq_batt, ret);
goto out_coulomb;
return ret;
}
return 0;
out_coulomb:
free_irq(info->irq_cc, info);
out_reg:
power_supply_unregister(info->battery);
return ret;
}
static int pm860x_battery_remove(struct platform_device *pdev)
{
struct pm860x_battery_info *info = platform_get_drvdata(pdev);
free_irq(info->irq_batt, info);
free_irq(info->irq_cc, info);
power_supply_unregister(info->battery);
return 0;
}
......@@ -1028,7 +1014,6 @@ static struct platform_driver pm860x_battery_driver = {
.pm = &pm860x_battery_pm_ops,
},
.probe = pm860x_battery_probe,
.remove = pm860x_battery_remove,
};
module_platform_driver(pm860x_battery_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment