summaryrefslogtreecommitdiff
path: root/drivers/power/max17042_battery.c
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2012-02-22 22:06:20 +0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-03-26 20:40:50 +0400
commit2f3b43423c70a340b715396f15096c496da959bb (patch)
tree2f854dea3fd0bd0b465eb7e31eb09987332336af /drivers/power/max17042_battery.c
parent13e0aa469e11f31a83f32f614c1331630851af28 (diff)
downloadlinux-2f3b43423c70a340b715396f15096c496da959bb.tar.xz
max17042_battery: Use devm_kzalloc() where applicable
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>
Diffstat (limited to 'drivers/power/max17042_battery.c')
-rw-r--r--drivers/power/max17042_battery.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index bd88debf9d52..872e9b4a5ade 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -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;
}