aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight/adp8870_bl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/backlight/adp8870_bl.c')
-rw-r--r--drivers/video/backlight/adp8870_bl.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 9be58c6f18f1..edf7f91c8e61 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -244,8 +244,8 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
244 struct led_info *cur_led; 244 struct led_info *cur_led;
245 int ret, i; 245 int ret, i;
246 246
247 247 led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led),
248 led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); 248 GFP_KERNEL);
249 if (led == NULL) { 249 if (led == NULL) {
250 dev_err(&client->dev, "failed to alloc memory\n"); 250 dev_err(&client->dev, "failed to alloc memory\n");
251 return -ENOMEM; 251 return -ENOMEM;
@@ -253,17 +253,17 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
253 253
254 ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law); 254 ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law);
255 if (ret) 255 if (ret)
256 goto err_free; 256 return ret;
257 257
258 ret = adp8870_write(client, ADP8870_ISCT1, 258 ret = adp8870_write(client, ADP8870_ISCT1,
259 (pdata->led_on_time & 0x3) << 6); 259 (pdata->led_on_time & 0x3) << 6);
260 if (ret) 260 if (ret)
261 goto err_free; 261 return ret;
262 262
263 ret = adp8870_write(client, ADP8870_ISCF, 263 ret = adp8870_write(client, ADP8870_ISCF,
264 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); 264 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out));
265 if (ret) 265 if (ret)
266 goto err_free; 266 return ret;
267 267
268 for (i = 0; i < pdata->num_leds; ++i) { 268 for (i = 0; i < pdata->num_leds; ++i) {
269 cur_led = &pdata->leds[i]; 269 cur_led = &pdata->leds[i];
@@ -317,9 +317,6 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
317 cancel_work_sync(&led[i].work); 317 cancel_work_sync(&led[i].work);
318 } 318 }
319 319
320 err_free:
321 kfree(led);
322
323 return ret; 320 return ret;
324} 321}
325 322
@@ -335,7 +332,6 @@ static int __devexit adp8870_led_remove(struct i2c_client *client)
335 cancel_work_sync(&data->led[i].work); 332 cancel_work_sync(&data->led[i].work);
336 } 333 }
337 334
338 kfree(data->led);
339 return 0; 335 return 0;
340} 336}
341#else 337#else
@@ -572,7 +568,7 @@ static ssize_t adp8870_store(struct device *dev, const char *buf,
572 unsigned long val; 568 unsigned long val;
573 int ret; 569 int ret;
574 570
575 ret = strict_strtoul(buf, 10, &val); 571 ret = kstrtoul(buf, 10, &val);
576 if (ret) 572 if (ret)
577 return ret; 573 return ret;
578 574
@@ -652,7 +648,7 @@ static ssize_t adp8870_bl_l1_daylight_max_store(struct device *dev,
652 struct device_attribute *attr, const char *buf, size_t count) 648 struct device_attribute *attr, const char *buf, size_t count)
653{ 649{
654 struct adp8870_bl *data = dev_get_drvdata(dev); 650 struct adp8870_bl *data = dev_get_drvdata(dev);
655 int ret = strict_strtoul(buf, 10, &data->cached_daylight_max); 651 int ret = kstrtoul(buf, 10, &data->cached_daylight_max);
656 if (ret) 652 if (ret)
657 return ret; 653 return ret;
658 654
@@ -794,7 +790,7 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
794 uint8_t reg_val; 790 uint8_t reg_val;
795 int ret; 791 int ret;
796 792
797 ret = strict_strtoul(buf, 10, &val); 793 ret = kstrtoul(buf, 10, &val);
798 if (ret) 794 if (ret)
799 return ret; 795 return ret;
800 796
@@ -874,7 +870,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
874 return -ENODEV; 870 return -ENODEV;
875 } 871 }
876 872
877 data = kzalloc(sizeof(*data), GFP_KERNEL); 873 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
878 if (data == NULL) 874 if (data == NULL)
879 return -ENOMEM; 875 return -ENOMEM;
880 876
@@ -894,8 +890,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
894 &client->dev, data, &adp8870_bl_ops, &props); 890 &client->dev, data, &adp8870_bl_ops, &props);
895 if (IS_ERR(bl)) { 891 if (IS_ERR(bl)) {
896 dev_err(&client->dev, "failed to register backlight\n"); 892 dev_err(&client->dev, "failed to register backlight\n");
897 ret = PTR_ERR(bl); 893 return PTR_ERR(bl);
898 goto out2;
899 } 894 }
900 895
901 data->bl = bl; 896 data->bl = bl;
@@ -930,8 +925,6 @@ out:
930 &adp8870_bl_attr_group); 925 &adp8870_bl_attr_group);
931out1: 926out1:
932 backlight_device_unregister(bl); 927 backlight_device_unregister(bl);
933out2:
934 kfree(data);
935 928
936 return ret; 929 return ret;
937} 930}
@@ -950,7 +943,6 @@ static int __devexit adp8870_remove(struct i2c_client *client)
950 &adp8870_bl_attr_group); 943 &adp8870_bl_attr_group);
951 944
952 backlight_device_unregister(data->bl); 945 backlight_device_unregister(data->bl);
953 kfree(data);
954 946
955 return 0; 947 return 0;
956} 948}