* [PATCH] power: max8997_charger: Using device managed API and remove OOM print
@ 2016-12-08 9:12 Srikant Ritolia
2016-12-17 16:09 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Srikant Ritolia @ 2016-12-08 9:12 UTC (permalink / raw)
To: Sebastian Reichel, Srikant Ritolia
Cc: linux-pm, vidushi.koul, srikant.ritolia
Use managed resource function devm_power_supply_register instead of
power_supply_register to simplify the error path by allowing unregistering
to happen automatically on error and remove.
Removing max8997_battery_remove function also as it is now redundant.
Also removing out of memory printk message after kzalloc as there is
already enough information on failure.
Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
---
drivers/power/max8997_charger.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/power/max8997_charger.c b/drivers/power/max8997_charger.c
index 0b2eab5..66567bb 100644
--- a/drivers/power/max8997_charger.c
+++ b/drivers/power/max8997_charger.c
@@ -148,10 +148,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
GFP_KERNEL);
- if (charger == NULL) {
- dev_err(&pdev->dev, "Cannot allocate memory.\n");
+ if (!charger)
return -ENOMEM;
- }
platform_set_drvdata(pdev, charger);
@@ -161,7 +159,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
psy_cfg.drv_data = charger;
- charger->battery = power_supply_register(&pdev->dev,
+ charger->battery = devm_power_supply_register(&pdev->dev,
&max8997_battery_desc,
&psy_cfg);
if (IS_ERR(charger->battery)) {
@@ -172,14 +170,6 @@ static int max8997_battery_probe(struct platform_device *pdev)
return 0;
}
-static int max8997_battery_remove(struct platform_device *pdev)
-{
- struct charger_data *charger = platform_get_drvdata(pdev);
-
- power_supply_unregister(charger->battery);
- return 0;
-}
-
static const struct platform_device_id max8997_battery_id[] = {
{ "max8997-battery", 0 },
{ }
@@ -190,7 +180,6 @@ static struct platform_driver max8997_battery_driver = {
.name = "max8997-battery",
},
.probe = max8997_battery_probe,
- .remove = max8997_battery_remove,
.id_table = max8997_battery_id,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: max8997_charger: Using device managed API and remove OOM print
2016-12-08 9:12 [PATCH] power: max8997_charger: Using device managed API and remove OOM print Srikant Ritolia
@ 2016-12-17 16:09 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2016-12-17 16:09 UTC (permalink / raw)
To: Srikant Ritolia; +Cc: linux-pm, vidushi.koul, srikant.ritolia
[-- Attachment #1: Type: text/plain, Size: 834 bytes --]
Hi,
On Thu, Dec 08, 2016 at 02:42:37PM +0530, Srikant Ritolia wrote:
> Use managed resource function devm_power_supply_register instead of
> power_supply_register to simplify the error path by allowing unregistering
> to happen automatically on error and remove.
> Removing max8997_battery_remove function also as it is now redundant.
>
> Also removing out of memory printk message after kzalloc as there is
> already enough information on failure.
>
> Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
Thanks for your patch. We are currently in the merge
window and your patch will appear in linux-next once
4.10-rc1 has been tagged by Linus Torvalds.
Until then I queued it into this branch:
https://git.kernel.org/cgit/linux/kernel/git/sre/linux-power-supply.git/log/?h=for-next-next
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-17 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-08 9:12 [PATCH] power: max8997_charger: Using device managed API and remove OOM print Srikant Ritolia
2016-12-17 16:09 ` 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).