diff options
| author | Waqar Hameed <waqar.hameed@axis.com> | 2026-01-23 11:55:43 +0300 |
|---|---|---|
| committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2026-01-30 22:57:32 +0300 |
| commit | 72db889394d89ffde61e7438f0cdfc0135c9da48 (patch) | |
| tree | fe441cc0f637058ff9e69b4e346e24d3bbc9a6fb | |
| parent | 23067259919663580c6f81801847cfc7bd54fd1f (diff) | |
| download | linux-72db889394d89ffde61e7438f0cdfc0135c9da48.tar.xz | |
power: supply: wm97xx: Use devm_kcalloc()
Instead of handling the memory allocation manually, use the automatic
`devres` variant `devm_kcalloc()`. This is less error prone and
eliminates the `goto`-path.
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/5ac93f5b0fa417bb5d9e93b9302a18f2c04d4077.1769158280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| -rw-r--r-- | drivers/power/supply/wm97xx_battery.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/power/supply/wm97xx_battery.c b/drivers/power/supply/wm97xx_battery.c index f00722c88c6f..c30c347b48f9 100644 --- a/drivers/power/supply/wm97xx_battery.c +++ b/drivers/power/supply/wm97xx_battery.c @@ -192,7 +192,7 @@ static int wm97xx_bat_probe(struct platform_device *dev) if (pdata->min_voltage >= 0) props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ - prop = kcalloc(props, sizeof(*prop), GFP_KERNEL); + prop = devm_kcalloc(&dev->dev, props, sizeof(*prop), GFP_KERNEL); if (!prop) return -ENOMEM; @@ -224,12 +224,10 @@ static int wm97xx_bat_probe(struct platform_device *dev) bat_psy_desc.num_properties = props; bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg); - if (!IS_ERR(bat_psy)) { - schedule_work(&bat_work); - } else { - ret = PTR_ERR(bat_psy); - goto free; - } + if (IS_ERR(bat_psy)) + return PTR_ERR(bat_psy); + + schedule_work(&bat_work); if (charge_gpiod) { ret = request_irq(gpiod_to_irq(charge_gpiod), wm97xx_chrg_irq, @@ -246,9 +244,6 @@ static int wm97xx_bat_probe(struct platform_device *dev) unregister: power_supply_unregister(bat_psy); -free: - kfree(prop); - return ret; } @@ -258,7 +253,6 @@ static void wm97xx_bat_remove(struct platform_device *dev) free_irq(gpiod_to_irq(charge_gpiod), dev); cancel_work_sync(&bat_work); power_supply_unregister(bat_psy); - kfree(prop); } static struct platform_driver wm97xx_bat_driver = { |
