diff options
author | Vaishali Thakkar <vthakkar1994@gmail.com> | 2015-08-13 10:24:41 +0530 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-09-22 16:20:10 +0200 |
commit | 5e5822f670c2c61953b5d4d18b4cc3e66744865c (patch) | |
tree | 48ab3f28eb14bf81bc4eb49446d90813c2aa4c3e /drivers/power/max8998_charger.c | |
parent | 75ea8ca844fd35ce365e35e1617b239892d31f72 (diff) | |
download | lwn-5e5822f670c2c61953b5d4d18b4cc3e66744865c.tar.gz lwn-5e5822f670c2c61953b5d4d18b4cc3e66744865c.zip |
power_supply: max8998: Use devm_power_supply_register
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>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/max8998_charger.c')
-rw-r--r-- | drivers/power/max8998_charger.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/power/max8998_charger.c b/drivers/power/max8998_charger.c index 47448d4bc6cd..b64cf0f14142 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[] = { @@ -205,7 +191,6 @@ static struct platform_driver max8998_battery_driver = { .name = "max8998-battery", }, .probe = max8998_battery_probe, - .remove = max8998_battery_remove, .id_table = max8998_battery_id, }; |