mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-29 11:42:36 +00:00
power: supply: rt5033: Use devm_power_supply_register() helper
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-12-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
e90a67f618
commit
3a93da231c
@ -159,12 +159,12 @@ static int rt5033_battery_probe(struct i2c_client *client)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_set_clientdata(client, battery);
|
|
||||||
psy_cfg.of_node = client->dev.of_node;
|
psy_cfg.of_node = client->dev.of_node;
|
||||||
psy_cfg.drv_data = battery;
|
psy_cfg.drv_data = battery;
|
||||||
|
|
||||||
battery->psy = power_supply_register(&client->dev,
|
battery->psy = devm_power_supply_register(&client->dev,
|
||||||
&rt5033_battery_desc, &psy_cfg);
|
&rt5033_battery_desc,
|
||||||
|
&psy_cfg);
|
||||||
if (IS_ERR(battery->psy))
|
if (IS_ERR(battery->psy))
|
||||||
return dev_err_probe(&client->dev, PTR_ERR(battery->psy),
|
return dev_err_probe(&client->dev, PTR_ERR(battery->psy),
|
||||||
"Failed to register power supply\n");
|
"Failed to register power supply\n");
|
||||||
@ -172,13 +172,6 @@ static int rt5033_battery_probe(struct i2c_client *client)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rt5033_battery_remove(struct i2c_client *client)
|
|
||||||
{
|
|
||||||
struct rt5033_battery *battery = i2c_get_clientdata(client);
|
|
||||||
|
|
||||||
power_supply_unregister(battery->psy);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct i2c_device_id rt5033_battery_id[] = {
|
static const struct i2c_device_id rt5033_battery_id[] = {
|
||||||
{ "rt5033-battery", },
|
{ "rt5033-battery", },
|
||||||
{ }
|
{ }
|
||||||
@ -197,7 +190,6 @@ static struct i2c_driver rt5033_battery_driver = {
|
|||||||
.of_match_table = rt5033_battery_of_match,
|
.of_match_table = rt5033_battery_of_match,
|
||||||
},
|
},
|
||||||
.probe = rt5033_battery_probe,
|
.probe = rt5033_battery_probe,
|
||||||
.remove = rt5033_battery_remove,
|
|
||||||
.id_table = rt5033_battery_id,
|
.id_table = rt5033_battery_id,
|
||||||
};
|
};
|
||||||
module_i2c_driver(rt5033_battery_driver);
|
module_i2c_driver(rt5033_battery_driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user