diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-04-18 17:46:52 +0300 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2019-04-18 22:53:21 +0300 |
commit | b0280d05804ae86514f5abca427e360e33fed1bb (patch) | |
tree | f915bb1498e3d06cf02b61217c83f7d02ce4cdc7 /drivers/power | |
parent | 33554d818a9562f47ba0de3edb35346ccf7c8c1b (diff) | |
download | linux-b0280d05804ae86514f5abca427e360e33fed1bb.tar.xz |
power: supply: olpc_battery: Use devm_power_supply_register()
This simplifies the error handling.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/olpc_battery.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index f7bb9bedd893..d83c77c2a0ec 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -634,7 +634,7 @@ static int olpc_battery_probe(struct platform_device *pdev) psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = data; - data->olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); + data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); if (IS_ERR(data->olpc_ac)) return PTR_ERR(data->olpc_ac); @@ -648,15 +648,13 @@ static int olpc_battery_probe(struct platform_device *pdev) olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); } - data->olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); - if (IS_ERR(data->olpc_bat)) { - ret = PTR_ERR(data->olpc_bat); - goto battery_failed; - } + data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); + if (IS_ERR(data->olpc_bat)) + return PTR_ERR(data->olpc_bat); ret = device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); if (ret) - goto eeprom_failed; + return ret; ret = device_create_file(&data->olpc_bat->dev, &olpc_bat_error); if (ret) @@ -671,10 +669,6 @@ static int olpc_battery_probe(struct platform_device *pdev) error_failed: device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); -eeprom_failed: - power_supply_unregister(data->olpc_bat); -battery_failed: - power_supply_unregister(data->olpc_ac); return ret; } @@ -684,9 +678,6 @@ static int olpc_battery_remove(struct platform_device *pdev) device_remove_file(&data->olpc_bat->dev, &olpc_bat_error); device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); - power_supply_unregister(data->olpc_bat); - power_supply_unregister(data->olpc_ac); - return 0; } |