mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
max17042_battery: Use devm_kzalloc() where applicable
This allows us to simplify probe and exit function. Signed-off-by: Karol Lewandowski <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Signed-off-by: Anton Vorontsov <[email protected]>
This commit is contained in:
parent
13e0aa469e
commit
2f3b43423c
1 changed files with 2 additions and 5 deletions
|
|
@ -619,7 +619,7 @@ static int __devinit max17042_probe(struct i2c_client *client,
|
|||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -EIO;
|
||||
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
||||
if (!chip)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -676,10 +676,8 @@ static int __devinit max17042_probe(struct i2c_client *client,
|
|||
}
|
||||
|
||||
ret = power_supply_register(&client->dev, &chip->battery);
|
||||
if (ret) {
|
||||
if (ret)
|
||||
dev_err(&client->dev, "failed: power supply register\n");
|
||||
kfree(chip);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +686,6 @@ static int __devexit max17042_remove(struct i2c_client *client)
|
|||
struct max17042_chip *chip = i2c_get_clientdata(client);
|
||||
|
||||
power_supply_unregister(&chip->battery);
|
||||
kfree(chip);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue