Skip to content

Commit

Permalink
max17042_battery: Use devm_kzalloc() where applicable
Browse files Browse the repository at this point in the history
This allows us to simplify probe and exit function.

Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Karol Lewandowski authored and Anton Vorontsov committed Mar 26, 2012
1 parent 13e0aa4 commit 2f3b434
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/power/max17042_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 2f3b434

Please sign in to comment.