Commit 2f3b4342 authored by Karol Lewandowski's avatar Karol Lewandowski Committed by Anton Vorontsov

max17042_battery: Use devm_kzalloc() where applicable

This allows us to simplify probe and exit function.
Signed-off-by: default avatarKarol Lewandowski <k.lewandowsk@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent 13e0aa46
...@@ -619,7 +619,7 @@ static int __devinit max17042_probe(struct i2c_client *client, ...@@ -619,7 +619,7 @@ static int __devinit max17042_probe(struct i2c_client *client,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
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;
...@@ -676,10 +676,8 @@ static int __devinit max17042_probe(struct i2c_client *client, ...@@ -676,10 +676,8 @@ static int __devinit max17042_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;
} }
...@@ -688,7 +686,6 @@ static int __devexit max17042_remove(struct i2c_client *client) ...@@ -688,7 +686,6 @@ static int __devexit max17042_remove(struct i2c_client *client)
struct max17042_chip *chip = i2c_get_clientdata(client); struct max17042_chip *chip = i2c_get_clientdata(client);
power_supply_unregister(&chip->battery); power_supply_unregister(&chip->battery);
kfree(chip);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment