* [PATCH] 88pm860x_battery: Convert to using managed resources
@ 2015-09-17 12:33 Vaishali Thakkar
2015-09-22 13:17 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Vaishali Thakkar @ 2015-09-17 12:33 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel
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: Vaishali Thakkar <vthakkar1994@gmail.com>
---
drivers/power/88pm860x_battery.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c
index d49579b..63c57dc 100644
--- a/drivers/power/88pm860x_battery.c
+++ b/drivers/power/88pm860x_battery.c
@@ -954,47 +954,33 @@ 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;
}
#ifdef CONFIG_PM_SLEEP
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] 88pm860x_battery: Convert to using managed resources
2015-09-17 12:33 [PATCH] 88pm860x_battery: Convert to using managed resources Vaishali Thakkar
@ 2015-09-22 13:17 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2015-09-22 13:17 UTC (permalink / raw)
To: Vaishali Thakkar
Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
Hi,
On Thu, Sep 17, 2015 at 06:03:40PM +0530, Vaishali Thakkar wrote:
> 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: Vaishali Thakkar <vthakkar1994@gmail.com>
Thanks, queued.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-22 13:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 12:33 [PATCH] 88pm860x_battery: Convert to using managed resources Vaishali Thakkar
2015-09-22 13:17 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).