* [PATCH v2] power_supply: max8998: Use devm_power_supply_register
@ 2015-08-13 4:54 Vaishali Thakkar
2015-09-22 15:14 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Vaishali Thakkar @ 2015-08-13 4:54 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel,
Krzysztof Kozlowski
Use managed resource function devm_power_supply_register instead
of power_supply_register to simplify the error path by allowing
unregister to happen automatically on error. To be compatible with
the change, replace various gotos by direct returns and remove
unneeded label err.
Also, remove max8998_battery_remove as it is now redundant.
Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
Changes since v1:
- Make commit log more reasonable
---
drivers/power/max8998_charger.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/drivers/power/max8998_charger.c b/drivers/power/max8998_charger.c
index 47448d4..6014df5 100644
--- a/drivers/power/max8998_charger.c
+++ b/drivers/power/max8998_charger.c
@@ -117,8 +117,7 @@ static int max8998_battery_probe(struct platform_device *pdev)
"EOC value not set: leave it unchanged.\n");
} else {
dev_err(max8998->dev, "Invalid EOC value\n");
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
/* Setup Charge Restart Level */
@@ -141,8 +140,7 @@ static int max8998_battery_probe(struct platform_device *pdev)
break;
default:
dev_err(max8998->dev, "Invalid Restart Level\n");
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
/* Setup Charge Full Timeout */
@@ -165,34 +163,22 @@ static int max8998_battery_probe(struct platform_device *pdev)
break;
default:
dev_err(max8998->dev, "Invalid Full Timeout value\n");
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
psy_cfg.drv_data = max8998;
- max8998->battery = power_supply_register(max8998->dev,
- &max8998_battery_desc,
- &psy_cfg);
+ max8998->battery = devm_power_supply_register(max8998->dev,
+ &max8998_battery_desc,
+ &psy_cfg);
if (IS_ERR(max8998->battery)) {
ret = PTR_ERR(max8998->battery);
dev_err(max8998->dev, "failed: power supply register: %d\n",
ret);
- goto err;
+ return ret;
}
return 0;
-err:
- return ret;
-}
-
-static int max8998_battery_remove(struct platform_device *pdev)
-{
- struct max8998_battery_data *max8998 = platform_get_drvdata(pdev);
-
- power_supply_unregister(max8998->battery);
-
- return 0;
}
static const struct platform_device_id max8998_battery_id[] = {
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] power_supply: max8998: Use devm_power_supply_register
2015-08-13 4:54 [PATCH v2] power_supply: max8998: Use devm_power_supply_register Vaishali Thakkar
@ 2015-09-22 15:14 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2015-09-22 15:14 UTC (permalink / raw)
To: Vaishali Thakkar
Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel,
Krzysztof Kozlowski
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
Hi,
On Thu, Aug 13, 2015 at 10:24:41AM +0530, Vaishali Thakkar wrote:
> Use managed resource function devm_power_supply_register instead
> of power_supply_register to simplify the error path by allowing
> unregister to happen automatically on error. To be compatible with
> the change, replace various gotos by direct returns and remove
> unneeded label err.
>
> Also, remove max8998_battery_remove as it is now redundant.
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 15:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 4:54 [PATCH v2] power_supply: max8998: Use devm_power_supply_register Vaishali Thakkar
2015-09-22 15:14 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox