summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPhil Reid <preid@electromag.com.au>2016-07-25 05:42:57 +0300
committerSebastian Reichel <sre@kernel.org>2016-08-15 22:51:30 +0300
commit9239a86f0976b58d3da7a2261ed659ac9eba0f25 (patch)
tree917d0919326c49f6625eb48ba2b374b95076e06a /drivers
parente4a404a081df1abe95a06ab24b7c76d8cf02402f (diff)
downloadlinux-9239a86f0976b58d3da7a2261ed659ac9eba0f25.tar.xz
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: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/supply/sbs-battery.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 768b9fcb58ea..20f3be6f5b9a 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -819,7 +819,7 @@ static int sbs_probe(struct i2c_client *client,
if (!sbs_desc->name)
return -ENOMEM;
- chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL);
+ chip = devm_kzalloc(&client->dev, sizeof(struct sbs_info), GFP_KERNEL);
if (!chip)
return -ENOMEM;
@@ -920,8 +920,6 @@ exit_psupply:
if (chip->gpio_detect)
gpio_free(pdata->battery_detect);
- kfree(chip);
-
return rc;
}
@@ -938,9 +936,6 @@ static int sbs_remove(struct i2c_client *client)
cancel_delayed_work_sync(&chip->work);
- kfree(chip);
- chip = NULL;
-
return 0;
}