summaryrefslogtreecommitdiff
path: root/drivers/power/supply/max8997_charger.c
diff options
context:
space:
mode:
authorSrikant Ritolia <s.ritolia@samsung.com>2016-12-08 12:12:37 +0300
committerSebastian Reichel <sre@kernel.org>2017-01-04 23:59:56 +0300
commita50b0dbbaf49521cc47a0bcfd20a6f658258541c (patch)
tree710a71a43f61933d60132209004199dd909d8b8b /drivers/power/supply/max8997_charger.c
parent50111d3f886ac95cb76aefb6ceb0d1b6e78eefc0 (diff)
downloadlinux-a50b0dbbaf49521cc47a0bcfd20a6f658258541c.tar.xz
power: supply: max8997_charger: Using device managed API and remove OOM print
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> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/supply/max8997_charger.c')
-rw-r--r--drivers/power/supply/max8997_charger.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index 290ddc12b040..fa861003fece 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/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 },
{ }
@@ -191,7 +181,6 @@ static struct platform_driver max8997_battery_driver = {
.name = "max8997-battery",
},
.probe = max8997_battery_probe,
- .remove = max8997_battery_remove,
.id_table = max8997_battery_id,
};