Skip to content

Commit

Permalink
max17040_battery: Use devm_kzalloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Devendra Naga authored and Anton Vorontsov committed Jan 6, 2013
1 parent d5c2b14 commit 00edfc6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/power/max17040_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int max17040_probe(struct i2c_client *client,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
return -EIO;

chip = kzalloc(sizeof(*chip), GFP_KERNEL);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;

Expand All @@ -225,7 +225,6 @@ static int max17040_probe(struct i2c_client *client,
ret = power_supply_register(&client->dev, &chip->battery);
if (ret) {
dev_err(&client->dev, "failed: power supply register\n");
kfree(chip);
return ret;
}

Expand All @@ -244,7 +243,6 @@ static int max17040_remove(struct i2c_client *client)

power_supply_unregister(&chip->battery);
cancel_delayed_work(&chip->work);
kfree(chip);
return 0;
}

Expand Down

0 comments on commit 00edfc6

Please sign in to comment.