提交 9239a86f 编写于 作者: P Phil Reid 提交者: Sebastian Reichel

power: sbs-battery: Use devm_kzalloc to alloc data

Use devm_kzalloc to allow memory to be freed automatically on
driver probe failure or removal.
Signed-off-by: NPhil Reid <preid@electromag.com.au>
Signed-off-by: NSebastian Reichel <sre@kernel.org>
上级 e4a404a0
...@@ -819,7 +819,7 @@ static int sbs_probe(struct i2c_client *client, ...@@ -819,7 +819,7 @@ static int sbs_probe(struct i2c_client *client,
if (!sbs_desc->name) if (!sbs_desc->name)
return -ENOMEM; return -ENOMEM;
chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); chip = devm_kzalloc(&client->dev, sizeof(struct sbs_info), GFP_KERNEL);
if (!chip) if (!chip)
return -ENOMEM; return -ENOMEM;
...@@ -920,8 +920,6 @@ static int sbs_probe(struct i2c_client *client, ...@@ -920,8 +920,6 @@ static int sbs_probe(struct i2c_client *client,
if (chip->gpio_detect) if (chip->gpio_detect)
gpio_free(pdata->battery_detect); gpio_free(pdata->battery_detect);
kfree(chip);
return rc; return rc;
} }
...@@ -938,9 +936,6 @@ static int sbs_remove(struct i2c_client *client) ...@@ -938,9 +936,6 @@ static int sbs_remove(struct i2c_client *client)
cancel_delayed_work_sync(&chip->work); cancel_delayed_work_sync(&chip->work);
kfree(chip);
chip = NULL;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册