twl4030_charger: use devres for power_supply_register and kzalloc.
Final allocations/registrations are now managed by devres. Signed-off-by: NeilBrown <neilb@suse.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
1b7cac2341
commit
325b50aa5d
|
@ -581,7 +581,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
int ret;
|
int ret;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
bci = kzalloc(sizeof(*bci), GFP_KERNEL);
|
bci = devm_kzalloc(&pdev->dev, sizeof(*bci), GFP_KERNEL);
|
||||||
if (bci == NULL)
|
if (bci == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -596,27 +596,27 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
ret = twl4030_is_battery_present(bci);
|
ret = twl4030_is_battery_present(bci);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_crit(&pdev->dev, "Battery was not detected:%d\n", ret);
|
dev_crit(&pdev->dev, "Battery was not detected:%d\n", ret);
|
||||||
goto fail_no_battery;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, bci);
|
platform_set_drvdata(pdev, bci);
|
||||||
|
|
||||||
bci->ac = power_supply_register(&pdev->dev, &twl4030_bci_ac_desc,
|
bci->ac = devm_power_supply_register(&pdev->dev, &twl4030_bci_ac_desc,
|
||||||
NULL);
|
NULL);
|
||||||
if (IS_ERR(bci->ac)) {
|
if (IS_ERR(bci->ac)) {
|
||||||
ret = PTR_ERR(bci->ac);
|
ret = PTR_ERR(bci->ac);
|
||||||
dev_err(&pdev->dev, "failed to register ac: %d\n", ret);
|
dev_err(&pdev->dev, "failed to register ac: %d\n", ret);
|
||||||
goto fail_register_ac;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bci->usb_reg = regulator_get(bci->dev, "bci3v1");
|
bci->usb_reg = regulator_get(bci->dev, "bci3v1");
|
||||||
|
|
||||||
bci->usb = power_supply_register(&pdev->dev, &twl4030_bci_usb_desc,
|
bci->usb = devm_power_supply_register(&pdev->dev, &twl4030_bci_usb_desc,
|
||||||
NULL);
|
NULL);
|
||||||
if (IS_ERR(bci->usb)) {
|
if (IS_ERR(bci->usb)) {
|
||||||
ret = PTR_ERR(bci->usb);
|
ret = PTR_ERR(bci->usb);
|
||||||
dev_err(&pdev->dev, "failed to register usb: %d\n", ret);
|
dev_err(&pdev->dev, "failed to register usb: %d\n", ret);
|
||||||
goto fail_register_usb;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL,
|
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL,
|
||||||
|
@ -625,7 +625,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
|
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
|
||||||
bci->irq_chg, ret);
|
bci->irq_chg, ret);
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_bci, NULL,
|
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_bci, NULL,
|
||||||
|
@ -633,7 +633,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
|
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
|
||||||
bci->irq_bci, ret);
|
bci->irq_bci, ret);
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_WORK(&bci->work, twl4030_bci_usb_work);
|
INIT_WORK(&bci->work, twl4030_bci_usb_work);
|
||||||
|
@ -656,7 +656,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
TWL4030_INTERRUPTS_BCIIMR1A);
|
TWL4030_INTERRUPTS_BCIIMR1A);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
|
dev_err(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = ~(u32)(TWL4030_VBATOV | TWL4030_VBUSOV | TWL4030_ACCHGOV);
|
reg = ~(u32)(TWL4030_VBATOV | TWL4030_VBUSOV | TWL4030_ACCHGOV);
|
||||||
|
@ -674,16 +674,6 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
|
||||||
twl4030_charger_enable_backup(0, 0);
|
twl4030_charger_enable_backup(0, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
power_supply_unregister(bci->usb);
|
|
||||||
fail_register_usb:
|
|
||||||
power_supply_unregister(bci->ac);
|
|
||||||
fail_register_ac:
|
|
||||||
fail_no_battery:
|
|
||||||
kfree(bci);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit twl4030_bci_remove(struct platform_device *pdev)
|
static int __exit twl4030_bci_remove(struct platform_device *pdev)
|
||||||
|
@ -700,10 +690,6 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
|
||||||
twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
|
twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
|
||||||
TWL4030_INTERRUPTS_BCIIMR2A);
|
TWL4030_INTERRUPTS_BCIIMR2A);
|
||||||
|
|
||||||
power_supply_unregister(bci->usb);
|
|
||||||
power_supply_unregister(bci->ac);
|
|
||||||
kfree(bci);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue