summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-bd2802.c
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-04 07:35:03 +0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-24 03:52:38 +0400
commitac63ff50ad37369b838e1416665ff8ca7e9c9b1b (patch)
tree8cd6c45183623efdf60f221d93b50de0728c9966 /drivers/leds/leds-bd2802.c
parente430dc003f023f3f5244418aa26cc64e78ab8b6e (diff)
downloadlinux-ac63ff50ad37369b838e1416665ff8ca7e9c9b1b.tar.xz
leds: convert BD2802 RGB LED driver to devm_kzalloc() and cleanup error exit path
Cc: Kim Kyuwon <q1.kim@samsung.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-bd2802.c')
-rw-r--r--drivers/leds/leds-bd2802.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 591cbdf5a046..89ca6a2a19d1 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -677,7 +677,7 @@ static int __devinit bd2802_probe(struct i2c_client *client,
struct bd2802_led_platform_data *pdata;
int ret, i;
- led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL);
+ led = devm_kzalloc(&client->dev, sizeof(struct bd2802_led), GFP_KERNEL);
if (!led) {
dev_err(&client->dev, "failed to allocate driver data\n");
return -ENOMEM;
@@ -697,7 +697,7 @@ static int __devinit bd2802_probe(struct i2c_client *client,
ret = bd2802_write_byte(client, BD2802_REG_CLKSETUP, 0x00);
if (ret < 0) {
dev_err(&client->dev, "failed to detect device\n");
- goto failed_free;
+ return ret;
} else
dev_info(&client->dev, "return 0x%02x\n", ret);
@@ -729,9 +729,6 @@ static int __devinit bd2802_probe(struct i2c_client *client,
failed_unregister_dev_file:
for (i--; i >= 0; i--)
device_remove_file(&led->client->dev, bd2802_attributes[i]);
-failed_free:
- kfree(led);
-
return ret;
}
@@ -746,7 +743,6 @@ static int __exit bd2802_remove(struct i2c_client *client)
bd2802_disable_adv_conf(led);
for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++)
device_remove_file(&led->client->dev, bd2802_attributes[i]);
- kfree(led);
return 0;
}