提交 91cdb239 编写于 作者: J Jingoo Han 提交者: Linus Torvalds

backlight: adp8870: use devm_ functions

The devm_ functions allocate memory that is released when a driver
detaches.  This patch uses devm_kzalloc of these functions.
Signed-off-by: NJingoo Han <jg1.han@samsung.com>
Acked-by: NMichael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 58875ea9
...@@ -244,8 +244,8 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) ...@@ -244,8 +244,8 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
struct led_info *cur_led; struct led_info *cur_led;
int ret, i; int ret, i;
led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led),
led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); GFP_KERNEL);
if (led == NULL) { if (led == NULL) {
dev_err(&client->dev, "failed to alloc memory\n"); dev_err(&client->dev, "failed to alloc memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -253,17 +253,17 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) ...@@ -253,17 +253,17 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law); ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law);
if (ret) if (ret)
goto err_free; return ret;
ret = adp8870_write(client, ADP8870_ISCT1, ret = adp8870_write(client, ADP8870_ISCT1,
(pdata->led_on_time & 0x3) << 6); (pdata->led_on_time & 0x3) << 6);
if (ret) if (ret)
goto err_free; return ret;
ret = adp8870_write(client, ADP8870_ISCF, ret = adp8870_write(client, ADP8870_ISCF,
FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); FADE_VAL(pdata->led_fade_in, pdata->led_fade_out));
if (ret) if (ret)
goto err_free; return ret;
for (i = 0; i < pdata->num_leds; ++i) { for (i = 0; i < pdata->num_leds; ++i) {
cur_led = &pdata->leds[i]; cur_led = &pdata->leds[i];
...@@ -317,9 +317,6 @@ static int __devinit adp8870_led_probe(struct i2c_client *client) ...@@ -317,9 +317,6 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
cancel_work_sync(&led[i].work); cancel_work_sync(&led[i].work);
} }
err_free:
kfree(led);
return ret; return ret;
} }
...@@ -335,7 +332,6 @@ static int __devexit adp8870_led_remove(struct i2c_client *client) ...@@ -335,7 +332,6 @@ static int __devexit adp8870_led_remove(struct i2c_client *client)
cancel_work_sync(&data->led[i].work); cancel_work_sync(&data->led[i].work);
} }
kfree(data->led);
return 0; return 0;
} }
#else #else
...@@ -874,7 +870,7 @@ static int __devinit adp8870_probe(struct i2c_client *client, ...@@ -874,7 +870,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
return -ENODEV; return -ENODEV;
} }
data = kzalloc(sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (data == NULL) if (data == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -894,8 +890,7 @@ static int __devinit adp8870_probe(struct i2c_client *client, ...@@ -894,8 +890,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
&client->dev, data, &adp8870_bl_ops, &props); &client->dev, data, &adp8870_bl_ops, &props);
if (IS_ERR(bl)) { if (IS_ERR(bl)) {
dev_err(&client->dev, "failed to register backlight\n"); dev_err(&client->dev, "failed to register backlight\n");
ret = PTR_ERR(bl); return PTR_ERR(bl);
goto out2;
} }
data->bl = bl; data->bl = bl;
...@@ -930,8 +925,6 @@ static int __devinit adp8870_probe(struct i2c_client *client, ...@@ -930,8 +925,6 @@ static int __devinit adp8870_probe(struct i2c_client *client,
&adp8870_bl_attr_group); &adp8870_bl_attr_group);
out1: out1:
backlight_device_unregister(bl); backlight_device_unregister(bl);
out2:
kfree(data);
return ret; return ret;
} }
...@@ -950,7 +943,6 @@ static int __devexit adp8870_remove(struct i2c_client *client) ...@@ -950,7 +943,6 @@ static int __devexit adp8870_remove(struct i2c_client *client)
&adp8870_bl_attr_group); &adp8870_bl_attr_group);
backlight_device_unregister(data->bl); backlight_device_unregister(data->bl);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册