mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
max17040_battery: Use devm_kzalloc
use devm_kzalloc and no need of error path and unload frees. Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
This commit is contained in:
parent
d5c2b14cb2
commit
00edfc65c2
@ -207,7 +207,7 @@ static int max17040_probe(struct i2c_client *client,
|
|||||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
|
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
||||||
if (!chip)
|
if (!chip)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -225,7 +225,6 @@ static int max17040_probe(struct i2c_client *client,
|
|||||||
ret = power_supply_register(&client->dev, &chip->battery);
|
ret = power_supply_register(&client->dev, &chip->battery);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&client->dev, "failed: power supply register\n");
|
dev_err(&client->dev, "failed: power supply register\n");
|
||||||
kfree(chip);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +243,6 @@ static int max17040_remove(struct i2c_client *client)
|
|||||||
|
|
||||||
power_supply_unregister(&chip->battery);
|
power_supply_unregister(&chip->battery);
|
||||||
cancel_delayed_work(&chip->work);
|
cancel_delayed_work(&chip->work);
|
||||||
kfree(chip);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user