aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-05-29 18:07:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:30 -0400
commit58875ea925763e99b8862dc07bcdebde774d830b (patch)
treecbdb92236f13e5a4fed912adc0574ee5feb13a02 /drivers
parentf5f4fd451634e5295cc807684a0eabd264b9db4d (diff)
backlight: adp8860: 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: Jingoo Han <jg1.han@samsung.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/adp8860_bl.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 6c0951c931d4..77d1fdba597f 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -222,7 +222,8 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
222 struct led_info *cur_led; 222 struct led_info *cur_led;
223 int ret, i; 223 int ret, i;
224 224
225 led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); 225 led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
226 GFP_KERNEL);
226 if (led == NULL) { 227 if (led == NULL) {
227 dev_err(&client->dev, "failed to alloc memory\n"); 228 dev_err(&client->dev, "failed to alloc memory\n");
228 return -ENOMEM; 229 return -ENOMEM;
@@ -236,7 +237,7 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
236 237
237 if (ret) { 238 if (ret) {
238 dev_err(&client->dev, "failed to write\n"); 239 dev_err(&client->dev, "failed to write\n");
239 goto err_free; 240 return ret;
240 } 241 }
241 242
242 for (i = 0; i < pdata->num_leds; ++i) { 243 for (i = 0; i < pdata->num_leds; ++i) {
@@ -291,9 +292,6 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
291 cancel_work_sync(&led[i].work); 292 cancel_work_sync(&led[i].work);
292 } 293 }
293 294
294 err_free:
295 kfree(led);
296
297 return ret; 295 return ret;
298} 296}
299 297
@@ -309,7 +307,6 @@ static int __devexit adp8860_led_remove(struct i2c_client *client)
309 cancel_work_sync(&data->led[i].work); 307 cancel_work_sync(&data->led[i].work);
310 } 308 }
311 309
312 kfree(data->led);
313 return 0; 310 return 0;
314} 311}
315#else 312#else
@@ -675,13 +672,13 @@ static int __devinit adp8860_probe(struct i2c_client *client,
675 return -EINVAL; 672 return -EINVAL;
676 } 673 }
677 674
678 data = kzalloc(sizeof(*data), GFP_KERNEL); 675 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
679 if (data == NULL) 676 if (data == NULL)
680 return -ENOMEM; 677 return -ENOMEM;
681 678
682 ret = adp8860_read(client, ADP8860_MFDVID, &reg_val); 679 ret = adp8860_read(client, ADP8860_MFDVID, &reg_val);
683 if (ret < 0) 680 if (ret < 0)
684 goto out2; 681 return ret;
685 682
686 switch (ADP8860_MANID(reg_val)) { 683 switch (ADP8860_MANID(reg_val)) {
687 case ADP8863_MANUFID: 684 case ADP8863_MANUFID:
@@ -694,8 +691,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
694 break; 691 break;
695 default: 692 default:
696 dev_err(&client->dev, "failed to probe\n"); 693 dev_err(&client->dev, "failed to probe\n");
697 ret = -ENODEV; 694 return -ENODEV;
698 goto out2;
699 } 695 }
700 696
701 /* It's confirmed that the DEVID field is actually a REVID */ 697 /* It's confirmed that the DEVID field is actually a REVID */
@@ -717,8 +713,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
717 &client->dev, data, &adp8860_bl_ops, &props); 713 &client->dev, data, &adp8860_bl_ops, &props);
718 if (IS_ERR(bl)) { 714 if (IS_ERR(bl)) {
719 dev_err(&client->dev, "failed to register backlight\n"); 715 dev_err(&client->dev, "failed to register backlight\n");
720 ret = PTR_ERR(bl); 716 return PTR_ERR(bl);
721 goto out2;
722 } 717 }
723 718
724 bl->props.brightness = ADP8860_MAX_BRIGHTNESS; 719 bl->props.brightness = ADP8860_MAX_BRIGHTNESS;
@@ -756,8 +751,6 @@ out:
756 &adp8860_bl_attr_group); 751 &adp8860_bl_attr_group);
757out1: 752out1:
758 backlight_device_unregister(bl); 753 backlight_device_unregister(bl);
759out2:
760 kfree(data);
761 754
762 return ret; 755 return ret;
763} 756}
@@ -776,7 +769,6 @@ static int __devexit adp8860_remove(struct i2c_client *client)
776 &adp8860_bl_attr_group); 769 &adp8860_bl_attr_group);
777 770
778 backlight_device_unregister(data->bl); 771 backlight_device_unregister(data->bl);
779 kfree(data);
780 772
781 return 0; 773 return 0;
782} 774}