diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-05-02 07:29:43 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-05-21 06:52:15 -0400 |
commit | c02b211df6fc54e51ee554c27a6736a11255a764 (patch) | |
tree | a2b78b3a7a0400550fdd89da110d1b21a9e1acb1 | |
parent | 95323361e5313733a54771c5059f5b352adbf32c (diff) |
[media] media: i2c: Convert to devm_kzalloc()
Using the managed function the kfree() calls can be removed from the
probe error path and the remove handler.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
56 files changed, 79 insertions, 202 deletions
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 58344b6c3a55..15043554cc8b 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c | |||
@@ -1188,15 +1188,14 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * | |||
1188 | v4l_dbg(1, debug, client, "detecting ad9389b client on address 0x%x\n", | 1188 | v4l_dbg(1, debug, client, "detecting ad9389b client on address 0x%x\n", |
1189 | client->addr << 1); | 1189 | client->addr << 1); |
1190 | 1190 | ||
1191 | state = kzalloc(sizeof(struct ad9389b_state), GFP_KERNEL); | 1191 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
1192 | if (!state) | 1192 | if (!state) |
1193 | return -ENOMEM; | 1193 | return -ENOMEM; |
1194 | 1194 | ||
1195 | /* Platform data */ | 1195 | /* Platform data */ |
1196 | if (pdata == NULL) { | 1196 | if (pdata == NULL) { |
1197 | v4l_err(client, "No platform data!\n"); | 1197 | v4l_err(client, "No platform data!\n"); |
1198 | err = -ENODEV; | 1198 | return -ENODEV; |
1199 | goto err_free; | ||
1200 | } | 1199 | } |
1201 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); | 1200 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); |
1202 | 1201 | ||
@@ -1276,8 +1275,6 @@ err_entity: | |||
1276 | media_entity_cleanup(&sd->entity); | 1275 | media_entity_cleanup(&sd->entity); |
1277 | err_hdl: | 1276 | err_hdl: |
1278 | v4l2_ctrl_handler_free(&state->hdl); | 1277 | v4l2_ctrl_handler_free(&state->hdl); |
1279 | err_free: | ||
1280 | kfree(state); | ||
1281 | return err; | 1278 | return err; |
1282 | } | 1279 | } |
1283 | 1280 | ||
@@ -1302,7 +1299,6 @@ static int ad9389b_remove(struct i2c_client *client) | |||
1302 | v4l2_device_unregister_subdev(sd); | 1299 | v4l2_device_unregister_subdev(sd); |
1303 | media_entity_cleanup(&sd->entity); | 1300 | media_entity_cleanup(&sd->entity); |
1304 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 1301 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
1305 | kfree(get_ad9389b_state(sd)); | ||
1306 | return 0; | 1302 | return 0; |
1307 | } | 1303 | } |
1308 | 1304 | ||
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index ef75abe5984c..873fe1949e98 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c | |||
@@ -417,7 +417,7 @@ static int adp1653_probe(struct i2c_client *client, | |||
417 | if (client->dev.platform_data == NULL) | 417 | if (client->dev.platform_data == NULL) |
418 | return -ENODEV; | 418 | return -ENODEV; |
419 | 419 | ||
420 | flash = kzalloc(sizeof(*flash), GFP_KERNEL); | 420 | flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); |
421 | if (flash == NULL) | 421 | if (flash == NULL) |
422 | return -ENOMEM; | 422 | return -ENOMEM; |
423 | 423 | ||
@@ -443,7 +443,6 @@ static int adp1653_probe(struct i2c_client *client, | |||
443 | 443 | ||
444 | free_and_quit: | 444 | free_and_quit: |
445 | v4l2_ctrl_handler_free(&flash->ctrls); | 445 | v4l2_ctrl_handler_free(&flash->ctrls); |
446 | kfree(flash); | ||
447 | return ret; | 446 | return ret; |
448 | } | 447 | } |
449 | 448 | ||
@@ -455,7 +454,7 @@ static int adp1653_remove(struct i2c_client *client) | |||
455 | v4l2_device_unregister_subdev(&flash->subdev); | 454 | v4l2_device_unregister_subdev(&flash->subdev); |
456 | v4l2_ctrl_handler_free(&flash->ctrls); | 455 | v4l2_ctrl_handler_free(&flash->ctrls); |
457 | media_entity_cleanup(&flash->subdev.entity); | 456 | media_entity_cleanup(&flash->subdev.entity); |
458 | kfree(flash); | 457 | |
459 | return 0; | 458 | return 0; |
460 | } | 459 | } |
461 | 460 | ||
diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c index 6bc01fb98ff8..d07689d44354 100644 --- a/drivers/media/i2c/adv7170.c +++ b/drivers/media/i2c/adv7170.c | |||
@@ -359,7 +359,7 @@ static int adv7170_probe(struct i2c_client *client, | |||
359 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 359 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
360 | client->addr << 1, client->adapter->name); | 360 | client->addr << 1, client->adapter->name); |
361 | 361 | ||
362 | encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); | 362 | encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); |
363 | if (encoder == NULL) | 363 | if (encoder == NULL) |
364 | return -ENOMEM; | 364 | return -ENOMEM; |
365 | sd = &encoder->sd; | 365 | sd = &encoder->sd; |
@@ -384,7 +384,6 @@ static int adv7170_remove(struct i2c_client *client) | |||
384 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 384 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
385 | 385 | ||
386 | v4l2_device_unregister_subdev(sd); | 386 | v4l2_device_unregister_subdev(sd); |
387 | kfree(to_adv7170(sd)); | ||
388 | return 0; | 387 | return 0; |
389 | } | 388 | } |
390 | 389 | ||
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c index c7640fab5730..eaefa50b8d28 100644 --- a/drivers/media/i2c/adv7175.c +++ b/drivers/media/i2c/adv7175.c | |||
@@ -409,7 +409,7 @@ static int adv7175_probe(struct i2c_client *client, | |||
409 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 409 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
410 | client->addr << 1, client->adapter->name); | 410 | client->addr << 1, client->adapter->name); |
411 | 411 | ||
412 | encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); | 412 | encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); |
413 | if (encoder == NULL) | 413 | if (encoder == NULL) |
414 | return -ENOMEM; | 414 | return -ENOMEM; |
415 | sd = &encoder->sd; | 415 | sd = &encoder->sd; |
@@ -434,7 +434,6 @@ static int adv7175_remove(struct i2c_client *client) | |||
434 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 434 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
435 | 435 | ||
436 | v4l2_device_unregister_subdev(sd); | 436 | v4l2_device_unregister_subdev(sd); |
437 | kfree(to_adv7175(sd)); | ||
438 | return 0; | 437 | return 0; |
439 | } | 438 | } |
440 | 439 | ||
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index afd561ab190d..3d1456780318 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c | |||
@@ -555,7 +555,7 @@ static int adv7180_probe(struct i2c_client *client, | |||
555 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 555 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
556 | client->addr, client->adapter->name); | 556 | client->addr, client->adapter->name); |
557 | 557 | ||
558 | state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); | 558 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
559 | if (state == NULL) { | 559 | if (state == NULL) { |
560 | ret = -ENOMEM; | 560 | ret = -ENOMEM; |
561 | goto err; | 561 | goto err; |
@@ -582,7 +582,6 @@ err_free_ctrl: | |||
582 | err_unreg_subdev: | 582 | err_unreg_subdev: |
583 | mutex_destroy(&state->mutex); | 583 | mutex_destroy(&state->mutex); |
584 | v4l2_device_unregister_subdev(sd); | 584 | v4l2_device_unregister_subdev(sd); |
585 | kfree(state); | ||
586 | err: | 585 | err: |
587 | printk(KERN_ERR KBUILD_MODNAME ": Failed to probe: %d\n", ret); | 586 | printk(KERN_ERR KBUILD_MODNAME ": Failed to probe: %d\n", ret); |
588 | return ret; | 587 | return ret; |
@@ -607,7 +606,6 @@ static int adv7180_remove(struct i2c_client *client) | |||
607 | 606 | ||
608 | mutex_destroy(&state->mutex); | 607 | mutex_destroy(&state->mutex); |
609 | v4l2_device_unregister_subdev(sd); | 608 | v4l2_device_unregister_subdev(sd); |
610 | kfree(to_state(sd)); | ||
611 | return 0; | 609 | return 0; |
612 | } | 610 | } |
613 | 611 | ||
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 2bc032894bae..56904174abc3 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c | |||
@@ -573,7 +573,7 @@ static int adv7183_probe(struct i2c_client *client, | |||
573 | if (pin_array == NULL) | 573 | if (pin_array == NULL) |
574 | return -EINVAL; | 574 | return -EINVAL; |
575 | 575 | ||
576 | decoder = kzalloc(sizeof(struct adv7183), GFP_KERNEL); | 576 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
577 | if (decoder == NULL) | 577 | if (decoder == NULL) |
578 | return -ENOMEM; | 578 | return -ENOMEM; |
579 | 579 | ||
@@ -583,8 +583,7 @@ static int adv7183_probe(struct i2c_client *client, | |||
583 | if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW, | 583 | if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW, |
584 | "ADV7183 Reset")) { | 584 | "ADV7183 Reset")) { |
585 | v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin); | 585 | v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin); |
586 | ret = -EBUSY; | 586 | return -EBUSY; |
587 | goto err_free_decoder; | ||
588 | } | 587 | } |
589 | 588 | ||
590 | if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH, | 589 | if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH, |
@@ -646,8 +645,6 @@ err_free_oe: | |||
646 | gpio_free(decoder->oe_pin); | 645 | gpio_free(decoder->oe_pin); |
647 | err_free_reset: | 646 | err_free_reset: |
648 | gpio_free(decoder->reset_pin); | 647 | gpio_free(decoder->reset_pin); |
649 | err_free_decoder: | ||
650 | kfree(decoder); | ||
651 | return ret; | 648 | return ret; |
652 | } | 649 | } |
653 | 650 | ||
@@ -660,7 +657,6 @@ static int adv7183_remove(struct i2c_client *client) | |||
660 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 657 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
661 | gpio_free(decoder->oe_pin); | 658 | gpio_free(decoder->oe_pin); |
662 | gpio_free(decoder->reset_pin); | 659 | gpio_free(decoder->reset_pin); |
663 | kfree(decoder); | ||
664 | return 0; | 660 | return 0; |
665 | } | 661 | } |
666 | 662 | ||
diff --git a/drivers/media/i2c/adv7393.c b/drivers/media/i2c/adv7393.c index 3dc6098c7267..ec505098598a 100644 --- a/drivers/media/i2c/adv7393.c +++ b/drivers/media/i2c/adv7393.c | |||
@@ -410,7 +410,7 @@ static int adv7393_probe(struct i2c_client *client, | |||
410 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 410 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
411 | client->addr << 1, client->adapter->name); | 411 | client->addr << 1, client->adapter->name); |
412 | 412 | ||
413 | state = kzalloc(sizeof(struct adv7393_state), GFP_KERNEL); | 413 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
414 | if (state == NULL) | 414 | if (state == NULL) |
415 | return -ENOMEM; | 415 | return -ENOMEM; |
416 | 416 | ||
@@ -444,16 +444,13 @@ static int adv7393_probe(struct i2c_client *client, | |||
444 | int err = state->hdl.error; | 444 | int err = state->hdl.error; |
445 | 445 | ||
446 | v4l2_ctrl_handler_free(&state->hdl); | 446 | v4l2_ctrl_handler_free(&state->hdl); |
447 | kfree(state); | ||
448 | return err; | 447 | return err; |
449 | } | 448 | } |
450 | v4l2_ctrl_handler_setup(&state->hdl); | 449 | v4l2_ctrl_handler_setup(&state->hdl); |
451 | 450 | ||
452 | err = adv7393_initialize(&state->sd); | 451 | err = adv7393_initialize(&state->sd); |
453 | if (err) { | 452 | if (err) |
454 | v4l2_ctrl_handler_free(&state->hdl); | 453 | v4l2_ctrl_handler_free(&state->hdl); |
455 | kfree(state); | ||
456 | } | ||
457 | return err; | 454 | return err; |
458 | } | 455 | } |
459 | 456 | ||
@@ -464,7 +461,6 @@ static int adv7393_remove(struct i2c_client *client) | |||
464 | 461 | ||
465 | v4l2_device_unregister_subdev(sd); | 462 | v4l2_device_unregister_subdev(sd); |
466 | v4l2_ctrl_handler_free(&state->hdl); | 463 | v4l2_ctrl_handler_free(&state->hdl); |
467 | kfree(state); | ||
468 | 464 | ||
469 | return 0; | 465 | return 0; |
470 | } | 466 | } |
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 31a63c9324fe..4cdcfc96aa56 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c | |||
@@ -1968,7 +1968,7 @@ static int adv7604_probe(struct i2c_client *client, | |||
1968 | v4l_dbg(1, debug, client, "detecting adv7604 client on address 0x%x\n", | 1968 | v4l_dbg(1, debug, client, "detecting adv7604 client on address 0x%x\n", |
1969 | client->addr << 1); | 1969 | client->addr << 1); |
1970 | 1970 | ||
1971 | state = kzalloc(sizeof(struct adv7604_state), GFP_KERNEL); | 1971 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
1972 | if (!state) { | 1972 | if (!state) { |
1973 | v4l_err(client, "Could not allocate adv7604_state memory!\n"); | 1973 | v4l_err(client, "Could not allocate adv7604_state memory!\n"); |
1974 | return -ENOMEM; | 1974 | return -ENOMEM; |
@@ -1977,8 +1977,7 @@ static int adv7604_probe(struct i2c_client *client, | |||
1977 | /* platform data */ | 1977 | /* platform data */ |
1978 | if (!pdata) { | 1978 | if (!pdata) { |
1979 | v4l_err(client, "No platform data!\n"); | 1979 | v4l_err(client, "No platform data!\n"); |
1980 | err = -ENODEV; | 1980 | return -ENODEV; |
1981 | goto err_state; | ||
1982 | } | 1981 | } |
1983 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); | 1982 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); |
1984 | 1983 | ||
@@ -1991,8 +1990,7 @@ static int adv7604_probe(struct i2c_client *client, | |||
1991 | if (adv_smbus_read_byte_data_check(client, 0xfb, false) != 0x68) { | 1990 | if (adv_smbus_read_byte_data_check(client, 0xfb, false) != 0x68) { |
1992 | v4l2_info(sd, "not an adv7604 on address 0x%x\n", | 1991 | v4l2_info(sd, "not an adv7604 on address 0x%x\n", |
1993 | client->addr << 1); | 1992 | client->addr << 1); |
1994 | err = -ENODEV; | 1993 | return -ENODEV; |
1995 | goto err_state; | ||
1996 | } | 1994 | } |
1997 | 1995 | ||
1998 | /* control handlers */ | 1996 | /* control handlers */ |
@@ -2093,8 +2091,6 @@ err_i2c: | |||
2093 | adv7604_unregister_clients(state); | 2091 | adv7604_unregister_clients(state); |
2094 | err_hdl: | 2092 | err_hdl: |
2095 | v4l2_ctrl_handler_free(hdl); | 2093 | v4l2_ctrl_handler_free(hdl); |
2096 | err_state: | ||
2097 | kfree(state); | ||
2098 | return err; | 2094 | return err; |
2099 | } | 2095 | } |
2100 | 2096 | ||
@@ -2111,7 +2107,6 @@ static int adv7604_remove(struct i2c_client *client) | |||
2111 | media_entity_cleanup(&sd->entity); | 2107 | media_entity_cleanup(&sd->entity); |
2112 | adv7604_unregister_clients(to_state(sd)); | 2108 | adv7604_unregister_clients(to_state(sd)); |
2113 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 2109 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
2114 | kfree(to_state(sd)); | ||
2115 | return 0; | 2110 | return 0; |
2116 | } | 2111 | } |
2117 | 2112 | ||
diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c index fd47465e4f6a..b918c3f29cbe 100644 --- a/drivers/media/i2c/ak881x.c +++ b/drivers/media/i2c/ak881x.c | |||
@@ -264,7 +264,7 @@ static int ak881x_probe(struct i2c_client *client, | |||
264 | return -EIO; | 264 | return -EIO; |
265 | } | 265 | } |
266 | 266 | ||
267 | ak881x = kzalloc(sizeof(struct ak881x), GFP_KERNEL); | 267 | ak881x = devm_kzalloc(&client->dev, sizeof(*ak881x), GFP_KERNEL); |
268 | if (!ak881x) | 268 | if (!ak881x) |
269 | return -ENOMEM; | 269 | return -ENOMEM; |
270 | 270 | ||
@@ -282,7 +282,6 @@ static int ak881x_probe(struct i2c_client *client, | |||
282 | default: | 282 | default: |
283 | dev_err(&client->dev, | 283 | dev_err(&client->dev, |
284 | "No ak881x chip detected, register read %x\n", data); | 284 | "No ak881x chip detected, register read %x\n", data); |
285 | kfree(ak881x); | ||
286 | return -ENODEV; | 285 | return -ENODEV; |
287 | } | 286 | } |
288 | 287 | ||
@@ -331,7 +330,6 @@ static int ak881x_remove(struct i2c_client *client) | |||
331 | struct ak881x *ak881x = to_ak881x(client); | 330 | struct ak881x *ak881x = to_ak881x(client); |
332 | 331 | ||
333 | v4l2_device_unregister_subdev(&ak881x->subdev); | 332 | v4l2_device_unregister_subdev(&ak881x->subdev); |
334 | kfree(ak881x); | ||
335 | 333 | ||
336 | return 0; | 334 | return 0; |
337 | } | 335 | } |
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index 58d523f2648f..301084b07887 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c | |||
@@ -813,7 +813,7 @@ static int as3645a_probe(struct i2c_client *client, | |||
813 | if (client->dev.platform_data == NULL) | 813 | if (client->dev.platform_data == NULL) |
814 | return -ENODEV; | 814 | return -ENODEV; |
815 | 815 | ||
816 | flash = kzalloc(sizeof(*flash), GFP_KERNEL); | 816 | flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); |
817 | if (flash == NULL) | 817 | if (flash == NULL) |
818 | return -ENOMEM; | 818 | return -ENOMEM; |
819 | 819 | ||
@@ -838,10 +838,8 @@ static int as3645a_probe(struct i2c_client *client, | |||
838 | flash->led_mode = V4L2_FLASH_LED_MODE_NONE; | 838 | flash->led_mode = V4L2_FLASH_LED_MODE_NONE; |
839 | 839 | ||
840 | done: | 840 | done: |
841 | if (ret < 0) { | 841 | if (ret < 0) |
842 | v4l2_ctrl_handler_free(&flash->ctrls); | 842 | v4l2_ctrl_handler_free(&flash->ctrls); |
843 | kfree(flash); | ||
844 | } | ||
845 | 843 | ||
846 | return ret; | 844 | return ret; |
847 | } | 845 | } |
@@ -855,7 +853,6 @@ static int as3645a_remove(struct i2c_client *client) | |||
855 | v4l2_ctrl_handler_free(&flash->ctrls); | 853 | v4l2_ctrl_handler_free(&flash->ctrls); |
856 | media_entity_cleanup(&flash->subdev.entity); | 854 | media_entity_cleanup(&flash->subdev.entity); |
857 | mutex_destroy(&flash->power_lock); | 855 | mutex_destroy(&flash->power_lock); |
858 | kfree(flash); | ||
859 | 856 | ||
860 | return 0; | 857 | return 0; |
861 | } | 858 | } |
diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c index 377bf05b1efd..ee9ed67e7910 100644 --- a/drivers/media/i2c/bt819.c +++ b/drivers/media/i2c/bt819.c | |||
@@ -425,7 +425,7 @@ static int bt819_probe(struct i2c_client *client, | |||
425 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 425 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
426 | return -ENODEV; | 426 | return -ENODEV; |
427 | 427 | ||
428 | decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); | 428 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
429 | if (decoder == NULL) | 429 | if (decoder == NULL) |
430 | return -ENOMEM; | 430 | return -ENOMEM; |
431 | sd = &decoder->sd; | 431 | sd = &decoder->sd; |
@@ -476,7 +476,6 @@ static int bt819_probe(struct i2c_client *client, | |||
476 | int err = decoder->hdl.error; | 476 | int err = decoder->hdl.error; |
477 | 477 | ||
478 | v4l2_ctrl_handler_free(&decoder->hdl); | 478 | v4l2_ctrl_handler_free(&decoder->hdl); |
479 | kfree(decoder); | ||
480 | return err; | 479 | return err; |
481 | } | 480 | } |
482 | v4l2_ctrl_handler_setup(&decoder->hdl); | 481 | v4l2_ctrl_handler_setup(&decoder->hdl); |
@@ -490,7 +489,6 @@ static int bt819_remove(struct i2c_client *client) | |||
490 | 489 | ||
491 | v4l2_device_unregister_subdev(sd); | 490 | v4l2_device_unregister_subdev(sd); |
492 | v4l2_ctrl_handler_free(&decoder->hdl); | 491 | v4l2_ctrl_handler_free(&decoder->hdl); |
493 | kfree(decoder); | ||
494 | return 0; | 492 | return 0; |
495 | } | 493 | } |
496 | 494 | ||
diff --git a/drivers/media/i2c/bt856.c b/drivers/media/i2c/bt856.c index 7e5bd365c239..7e5011163b62 100644 --- a/drivers/media/i2c/bt856.c +++ b/drivers/media/i2c/bt856.c | |||
@@ -216,7 +216,7 @@ static int bt856_probe(struct i2c_client *client, | |||
216 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 216 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
217 | client->addr << 1, client->adapter->name); | 217 | client->addr << 1, client->adapter->name); |
218 | 218 | ||
219 | encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); | 219 | encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); |
220 | if (encoder == NULL) | 220 | if (encoder == NULL) |
221 | return -ENOMEM; | 221 | return -ENOMEM; |
222 | sd = &encoder->sd; | 222 | sd = &encoder->sd; |
@@ -250,7 +250,6 @@ static int bt856_remove(struct i2c_client *client) | |||
250 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 250 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
251 | 251 | ||
252 | v4l2_device_unregister_subdev(sd); | 252 | v4l2_device_unregister_subdev(sd); |
253 | kfree(to_bt856(sd)); | ||
254 | return 0; | 253 | return 0; |
255 | } | 254 | } |
256 | 255 | ||
diff --git a/drivers/media/i2c/bt866.c b/drivers/media/i2c/bt866.c index 905320b67a1c..9355b924b471 100644 --- a/drivers/media/i2c/bt866.c +++ b/drivers/media/i2c/bt866.c | |||
@@ -207,7 +207,7 @@ static int bt866_probe(struct i2c_client *client, | |||
207 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 207 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
208 | client->addr << 1, client->adapter->name); | 208 | client->addr << 1, client->adapter->name); |
209 | 209 | ||
210 | encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); | 210 | encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); |
211 | if (encoder == NULL) | 211 | if (encoder == NULL) |
212 | return -ENOMEM; | 212 | return -ENOMEM; |
213 | sd = &encoder->sd; | 213 | sd = &encoder->sd; |
@@ -220,7 +220,6 @@ static int bt866_remove(struct i2c_client *client) | |||
220 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 220 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
221 | 221 | ||
222 | v4l2_device_unregister_subdev(sd); | 222 | v4l2_device_unregister_subdev(sd); |
223 | kfree(to_bt866(sd)); | ||
224 | return 0; | 223 | return 0; |
225 | } | 224 | } |
226 | 225 | ||
diff --git a/drivers/media/i2c/cs5345.c b/drivers/media/i2c/cs5345.c index 1d2f7c8512b5..841b9c49dcfa 100644 --- a/drivers/media/i2c/cs5345.c +++ b/drivers/media/i2c/cs5345.c | |||
@@ -190,7 +190,7 @@ static int cs5345_probe(struct i2c_client *client, | |||
190 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 190 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
191 | client->addr << 1, client->adapter->name); | 191 | client->addr << 1, client->adapter->name); |
192 | 192 | ||
193 | state = kzalloc(sizeof(struct cs5345_state), GFP_KERNEL); | 193 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
194 | if (state == NULL) | 194 | if (state == NULL) |
195 | return -ENOMEM; | 195 | return -ENOMEM; |
196 | sd = &state->sd; | 196 | sd = &state->sd; |
@@ -206,7 +206,6 @@ static int cs5345_probe(struct i2c_client *client, | |||
206 | int err = state->hdl.error; | 206 | int err = state->hdl.error; |
207 | 207 | ||
208 | v4l2_ctrl_handler_free(&state->hdl); | 208 | v4l2_ctrl_handler_free(&state->hdl); |
209 | kfree(state); | ||
210 | return err; | 209 | return err; |
211 | } | 210 | } |
212 | /* set volume/mute */ | 211 | /* set volume/mute */ |
@@ -227,7 +226,6 @@ static int cs5345_remove(struct i2c_client *client) | |||
227 | 226 | ||
228 | v4l2_device_unregister_subdev(sd); | 227 | v4l2_device_unregister_subdev(sd); |
229 | v4l2_ctrl_handler_free(&state->hdl); | 228 | v4l2_ctrl_handler_free(&state->hdl); |
230 | kfree(state); | ||
231 | return 0; | 229 | return 0; |
232 | } | 230 | } |
233 | 231 | ||
diff --git a/drivers/media/i2c/cs53l32a.c b/drivers/media/i2c/cs53l32a.c index b293912206eb..1082fb775ab2 100644 --- a/drivers/media/i2c/cs53l32a.c +++ b/drivers/media/i2c/cs53l32a.c | |||
@@ -175,7 +175,7 @@ static int cs53l32a_probe(struct i2c_client *client, | |||
175 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 175 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
176 | client->addr << 1, client->adapter->name); | 176 | client->addr << 1, client->adapter->name); |
177 | 177 | ||
178 | state = kzalloc(sizeof(struct cs53l32a_state), GFP_KERNEL); | 178 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
179 | if (state == NULL) | 179 | if (state == NULL) |
180 | return -ENOMEM; | 180 | return -ENOMEM; |
181 | sd = &state->sd; | 181 | sd = &state->sd; |
@@ -197,7 +197,6 @@ static int cs53l32a_probe(struct i2c_client *client, | |||
197 | int err = state->hdl.error; | 197 | int err = state->hdl.error; |
198 | 198 | ||
199 | v4l2_ctrl_handler_free(&state->hdl); | 199 | v4l2_ctrl_handler_free(&state->hdl); |
200 | kfree(state); | ||
201 | return err; | 200 | return err; |
202 | } | 201 | } |
203 | 202 | ||
@@ -228,7 +227,6 @@ static int cs53l32a_remove(struct i2c_client *client) | |||
228 | 227 | ||
229 | v4l2_device_unregister_subdev(sd); | 228 | v4l2_device_unregister_subdev(sd); |
230 | v4l2_ctrl_handler_free(&state->hdl); | 229 | v4l2_ctrl_handler_free(&state->hdl); |
231 | kfree(state); | ||
232 | return 0; | 230 | return 0; |
233 | } | 231 | } |
234 | 232 | ||
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 12fb9b2eb887..bdfec4c768fe 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c | |||
@@ -5190,7 +5190,7 @@ static int cx25840_probe(struct i2c_client *client, | |||
5190 | return -ENODEV; | 5190 | return -ENODEV; |
5191 | } | 5191 | } |
5192 | 5192 | ||
5193 | state = kzalloc(sizeof(struct cx25840_state), GFP_KERNEL); | 5193 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
5194 | if (state == NULL) | 5194 | if (state == NULL) |
5195 | return -ENOMEM; | 5195 | return -ENOMEM; |
5196 | 5196 | ||
@@ -5292,7 +5292,6 @@ static int cx25840_probe(struct i2c_client *client, | |||
5292 | int err = state->hdl.error; | 5292 | int err = state->hdl.error; |
5293 | 5293 | ||
5294 | v4l2_ctrl_handler_free(&state->hdl); | 5294 | v4l2_ctrl_handler_free(&state->hdl); |
5295 | kfree(state); | ||
5296 | return err; | 5295 | return err; |
5297 | } | 5296 | } |
5298 | if (!is_cx2583x(state)) | 5297 | if (!is_cx2583x(state)) |
@@ -5317,7 +5316,6 @@ static int cx25840_remove(struct i2c_client *client) | |||
5317 | cx25840_ir_remove(sd); | 5316 | cx25840_ir_remove(sd); |
5318 | v4l2_device_unregister_subdev(sd); | 5317 | v4l2_device_unregister_subdev(sd); |
5319 | v4l2_ctrl_handler_free(&state->hdl); | 5318 | v4l2_ctrl_handler_free(&state->hdl); |
5320 | kfree(state); | ||
5321 | return 0; | 5319 | return 0; |
5322 | } | 5320 | } |
5323 | 5321 | ||
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c index 9ae977b5983a..e6588ee5bdb0 100644 --- a/drivers/media/i2c/cx25840/cx25840-ir.c +++ b/drivers/media/i2c/cx25840/cx25840-ir.c | |||
@@ -1230,16 +1230,14 @@ int cx25840_ir_probe(struct v4l2_subdev *sd) | |||
1230 | if (!(is_cx23885(state) || is_cx23887(state))) | 1230 | if (!(is_cx23885(state) || is_cx23887(state))) |
1231 | return 0; | 1231 | return 0; |
1232 | 1232 | ||
1233 | ir_state = kzalloc(sizeof(struct cx25840_ir_state), GFP_KERNEL); | 1233 | ir_state = devm_kzalloc(&state->c->dev, sizeof(*ir_state), GFP_KERNEL); |
1234 | if (ir_state == NULL) | 1234 | if (ir_state == NULL) |
1235 | return -ENOMEM; | 1235 | return -ENOMEM; |
1236 | 1236 | ||
1237 | spin_lock_init(&ir_state->rx_kfifo_lock); | 1237 | spin_lock_init(&ir_state->rx_kfifo_lock); |
1238 | if (kfifo_alloc(&ir_state->rx_kfifo, | 1238 | if (kfifo_alloc(&ir_state->rx_kfifo, |
1239 | CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) { | 1239 | CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) |
1240 | kfree(ir_state); | ||
1241 | return -ENOMEM; | 1240 | return -ENOMEM; |
1242 | } | ||
1243 | 1241 | ||
1244 | ir_state->c = state->c; | 1242 | ir_state->c = state->c; |
1245 | state->ir_state = ir_state; | 1243 | state->ir_state = ir_state; |
@@ -1273,7 +1271,6 @@ int cx25840_ir_remove(struct v4l2_subdev *sd) | |||
1273 | cx25840_ir_tx_shutdown(sd); | 1271 | cx25840_ir_tx_shutdown(sd); |
1274 | 1272 | ||
1275 | kfifo_free(&ir_state->rx_kfifo); | 1273 | kfifo_free(&ir_state->rx_kfifo); |
1276 | kfree(ir_state); | ||
1277 | state->ir_state = NULL; | 1274 | state->ir_state = NULL; |
1278 | return 0; | 1275 | return 0; |
1279 | } | 1276 | } |
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 8e2f79cb045e..82bf5679da30 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c | |||
@@ -295,7 +295,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
295 | unsigned short addr = client->addr; | 295 | unsigned short addr = client->addr; |
296 | int err; | 296 | int err; |
297 | 297 | ||
298 | ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); | 298 | ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); |
299 | if (!ir) | 299 | if (!ir) |
300 | return -ENOMEM; | 300 | return -ENOMEM; |
301 | 301 | ||
@@ -398,10 +398,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
398 | * internally | 398 | * internally |
399 | */ | 399 | */ |
400 | rc = rc_allocate_device(); | 400 | rc = rc_allocate_device(); |
401 | if (!rc) { | 401 | if (!rc) |
402 | err = -ENOMEM; | 402 | return -ENOMEM; |
403 | goto err_out_free; | ||
404 | } | ||
405 | } | 403 | } |
406 | ir->rc = rc; | 404 | ir->rc = rc; |
407 | 405 | ||
@@ -454,7 +452,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
454 | err_out_free: | 452 | err_out_free: |
455 | /* Only frees rc if it were allocated internally */ | 453 | /* Only frees rc if it were allocated internally */ |
456 | rc_free_device(rc); | 454 | rc_free_device(rc); |
457 | kfree(ir); | ||
458 | return err; | 455 | return err; |
459 | } | 456 | } |
460 | 457 | ||
@@ -470,7 +467,6 @@ static int ir_remove(struct i2c_client *client) | |||
470 | rc_unregister_device(ir->rc); | 467 | rc_unregister_device(ir->rc); |
471 | 468 | ||
472 | /* free memory */ | 469 | /* free memory */ |
473 | kfree(ir); | ||
474 | return 0; | 470 | return 0; |
475 | } | 471 | } |
476 | 472 | ||
diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c index 04a6efa37cc3..c7227763240e 100644 --- a/drivers/media/i2c/ks0127.c +++ b/drivers/media/i2c/ks0127.c | |||
@@ -685,7 +685,7 @@ static int ks0127_probe(struct i2c_client *client, const struct i2c_device_id *i | |||
685 | client->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board", | 685 | client->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board", |
686 | client->addr << 1, client->adapter->name); | 686 | client->addr << 1, client->adapter->name); |
687 | 687 | ||
688 | ks = kzalloc(sizeof(*ks), GFP_KERNEL); | 688 | ks = devm_kzalloc(&client->dev, sizeof(*ks), GFP_KERNEL); |
689 | if (ks == NULL) | 689 | if (ks == NULL) |
690 | return -ENOMEM; | 690 | return -ENOMEM; |
691 | sd = &ks->sd; | 691 | sd = &ks->sd; |
@@ -708,7 +708,6 @@ static int ks0127_remove(struct i2c_client *client) | |||
708 | v4l2_device_unregister_subdev(sd); | 708 | v4l2_device_unregister_subdev(sd); |
709 | ks0127_write(sd, KS_OFMTA, 0x20); /* tristate */ | 709 | ks0127_write(sd, KS_OFMTA, 0x20); /* tristate */ |
710 | ks0127_write(sd, KS_CMDA, 0x2c | 0x80); /* power down */ | 710 | ks0127_write(sd, KS_CMDA, 0x2c | 0x80); /* power down */ |
711 | kfree(to_ks0127(sd)); | ||
712 | return 0; | 711 | return 0; |
713 | } | 712 | } |
714 | 713 | ||
diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c index 39f50fd2b8d2..0d153f3b1a5b 100644 --- a/drivers/media/i2c/m52790.c +++ b/drivers/media/i2c/m52790.c | |||
@@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client, | |||
174 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 174 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
175 | client->addr << 1, client->adapter->name); | 175 | client->addr << 1, client->adapter->name); |
176 | 176 | ||
177 | state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL); | 177 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
178 | if (state == NULL) | 178 | if (state == NULL) |
179 | return -ENOMEM; | 179 | return -ENOMEM; |
180 | 180 | ||
@@ -191,7 +191,6 @@ static int m52790_remove(struct i2c_client *client) | |||
191 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 191 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
192 | 192 | ||
193 | v4l2_device_unregister_subdev(sd); | 193 | v4l2_device_unregister_subdev(sd); |
194 | kfree(to_state(sd)); | ||
195 | return 0; | 194 | return 0; |
196 | } | 195 | } |
197 | 196 | ||
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index f0b870c06376..08ff082242c3 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c | |||
@@ -950,7 +950,7 @@ static int m5mols_probe(struct i2c_client *client, | |||
950 | return -EINVAL; | 950 | return -EINVAL; |
951 | } | 951 | } |
952 | 952 | ||
953 | info = kzalloc(sizeof(struct m5mols_info), GFP_KERNEL); | 953 | info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); |
954 | if (!info) | 954 | if (!info) |
955 | return -ENOMEM; | 955 | return -ENOMEM; |
956 | 956 | ||
@@ -962,7 +962,7 @@ static int m5mols_probe(struct i2c_client *client, | |||
962 | ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST"); | 962 | ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST"); |
963 | if (ret) { | 963 | if (ret) { |
964 | dev_err(&client->dev, "Failed to request gpio: %d\n", ret); | 964 | dev_err(&client->dev, "Failed to request gpio: %d\n", ret); |
965 | goto out_free; | 965 | return ret; |
966 | } | 966 | } |
967 | 967 | ||
968 | ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); | 968 | ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); |
@@ -1015,8 +1015,6 @@ out_reg: | |||
1015 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 1015 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
1016 | out_gpio: | 1016 | out_gpio: |
1017 | gpio_free(pdata->gpio_reset); | 1017 | gpio_free(pdata->gpio_reset); |
1018 | out_free: | ||
1019 | kfree(info); | ||
1020 | return ret; | 1018 | return ret; |
1021 | } | 1019 | } |
1022 | 1020 | ||
@@ -1032,7 +1030,7 @@ static int m5mols_remove(struct i2c_client *client) | |||
1032 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); | 1030 | regulator_bulk_free(ARRAY_SIZE(supplies), supplies); |
1033 | gpio_free(info->pdata->gpio_reset); | 1031 | gpio_free(info->pdata->gpio_reset); |
1034 | media_entity_cleanup(&sd->entity); | 1032 | media_entity_cleanup(&sd->entity); |
1035 | kfree(info); | 1033 | |
1036 | return 0; | 1034 | return 0; |
1037 | } | 1035 | } |
1038 | 1036 | ||
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c index 54a9dd394f45..ae92c20790e3 100644 --- a/drivers/media/i2c/msp3400-driver.c +++ b/drivers/media/i2c/msp3400-driver.c | |||
@@ -707,7 +707,7 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
707 | return -ENODEV; | 707 | return -ENODEV; |
708 | } | 708 | } |
709 | 709 | ||
710 | state = kzalloc(sizeof(*state), GFP_KERNEL); | 710 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
711 | if (!state) | 711 | if (!state) |
712 | return -ENOMEM; | 712 | return -ENOMEM; |
713 | 713 | ||
@@ -732,7 +732,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
732 | if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { | 732 | if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { |
733 | v4l_dbg(1, msp_debug, client, | 733 | v4l_dbg(1, msp_debug, client, |
734 | "not an msp3400 (cannot read chip version)\n"); | 734 | "not an msp3400 (cannot read chip version)\n"); |
735 | kfree(state); | ||
736 | return -ENODEV; | 735 | return -ENODEV; |
737 | } | 736 | } |
738 | 737 | ||
@@ -827,7 +826,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
827 | int err = hdl->error; | 826 | int err = hdl->error; |
828 | 827 | ||
829 | v4l2_ctrl_handler_free(hdl); | 828 | v4l2_ctrl_handler_free(hdl); |
830 | kfree(state); | ||
831 | return err; | 829 | return err; |
832 | } | 830 | } |
833 | 831 | ||
@@ -889,7 +887,6 @@ static int msp_remove(struct i2c_client *client) | |||
889 | msp_reset(client); | 887 | msp_reset(client); |
890 | 888 | ||
891 | v4l2_ctrl_handler_free(&state->hdl); | 889 | v4l2_ctrl_handler_free(&state->hdl); |
892 | kfree(state); | ||
893 | return 0; | 890 | return 0; |
894 | } | 891 | } |
895 | 892 | ||
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index 8edb3d8f7b90..cca704e02f79 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c | |||
@@ -730,7 +730,7 @@ static int mt9m032_probe(struct i2c_client *client, | |||
730 | if (!client->dev.platform_data) | 730 | if (!client->dev.platform_data) |
731 | return -ENODEV; | 731 | return -ENODEV; |
732 | 732 | ||
733 | sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); | 733 | sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); |
734 | if (sensor == NULL) | 734 | if (sensor == NULL) |
735 | return -ENOMEM; | 735 | return -ENOMEM; |
736 | 736 | ||
@@ -860,7 +860,6 @@ error_ctrl: | |||
860 | v4l2_ctrl_handler_free(&sensor->ctrls); | 860 | v4l2_ctrl_handler_free(&sensor->ctrls); |
861 | error_sensor: | 861 | error_sensor: |
862 | mutex_destroy(&sensor->lock); | 862 | mutex_destroy(&sensor->lock); |
863 | kfree(sensor); | ||
864 | return ret; | 863 | return ret; |
865 | } | 864 | } |
866 | 865 | ||
@@ -873,7 +872,6 @@ static int mt9m032_remove(struct i2c_client *client) | |||
873 | v4l2_ctrl_handler_free(&sensor->ctrls); | 872 | v4l2_ctrl_handler_free(&sensor->ctrls); |
874 | media_entity_cleanup(&subdev->entity); | 873 | media_entity_cleanup(&subdev->entity); |
875 | mutex_destroy(&sensor->lock); | 874 | mutex_destroy(&sensor->lock); |
876 | kfree(sensor); | ||
877 | return 0; | 875 | return 0; |
878 | } | 876 | } |
879 | 877 | ||
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index 2e189d8b71bb..796463466ef0 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c | |||
@@ -740,7 +740,7 @@ static int mt9t001_probe(struct i2c_client *client, | |||
740 | if (ret < 0) | 740 | if (ret < 0) |
741 | return ret; | 741 | return ret; |
742 | 742 | ||
743 | mt9t001 = kzalloc(sizeof(*mt9t001), GFP_KERNEL); | 743 | mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL); |
744 | if (!mt9t001) | 744 | if (!mt9t001) |
745 | return -ENOMEM; | 745 | return -ENOMEM; |
746 | 746 | ||
@@ -801,7 +801,6 @@ done: | |||
801 | if (ret < 0) { | 801 | if (ret < 0) { |
802 | v4l2_ctrl_handler_free(&mt9t001->ctrls); | 802 | v4l2_ctrl_handler_free(&mt9t001->ctrls); |
803 | media_entity_cleanup(&mt9t001->subdev.entity); | 803 | media_entity_cleanup(&mt9t001->subdev.entity); |
804 | kfree(mt9t001); | ||
805 | } | 804 | } |
806 | 805 | ||
807 | return ret; | 806 | return ret; |
@@ -815,7 +814,6 @@ static int mt9t001_remove(struct i2c_client *client) | |||
815 | v4l2_ctrl_handler_free(&mt9t001->ctrls); | 814 | v4l2_ctrl_handler_free(&mt9t001->ctrls); |
816 | v4l2_device_unregister_subdev(subdev); | 815 | v4l2_device_unregister_subdev(subdev); |
817 | media_entity_cleanup(&subdev->entity); | 816 | media_entity_cleanup(&subdev->entity); |
818 | kfree(mt9t001); | ||
819 | return 0; | 817 | return 0; |
820 | } | 818 | } |
821 | 819 | ||
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index 3f415fd12de3..c64c9d9e253d 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c | |||
@@ -526,7 +526,7 @@ static int mt9v011_probe(struct i2c_client *c, | |||
526 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | 526 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) |
527 | return -EIO; | 527 | return -EIO; |
528 | 528 | ||
529 | core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL); | 529 | core = devm_kzalloc(&c->dev, sizeof(struct mt9v011), GFP_KERNEL); |
530 | if (!core) | 530 | if (!core) |
531 | return -ENOMEM; | 531 | return -ENOMEM; |
532 | 532 | ||
@@ -539,7 +539,6 @@ static int mt9v011_probe(struct i2c_client *c, | |||
539 | (version != MT9V011_REV_B_VERSION)) { | 539 | (version != MT9V011_REV_B_VERSION)) { |
540 | v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n", | 540 | v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n", |
541 | version); | 541 | version); |
542 | kfree(core); | ||
543 | return -EINVAL; | 542 | return -EINVAL; |
544 | } | 543 | } |
545 | 544 | ||
@@ -562,7 +561,6 @@ static int mt9v011_probe(struct i2c_client *c, | |||
562 | 561 | ||
563 | v4l2_err(sd, "control initialization error %d\n", ret); | 562 | v4l2_err(sd, "control initialization error %d\n", ret); |
564 | v4l2_ctrl_handler_free(&core->ctrls); | 563 | v4l2_ctrl_handler_free(&core->ctrls); |
565 | kfree(core); | ||
566 | return ret; | 564 | return ret; |
567 | } | 565 | } |
568 | core->sd.ctrl_handler = &core->ctrls; | 566 | core->sd.ctrl_handler = &core->ctrls; |
@@ -598,7 +596,7 @@ static int mt9v011_remove(struct i2c_client *c) | |||
598 | 596 | ||
599 | v4l2_device_unregister_subdev(sd); | 597 | v4l2_device_unregister_subdev(sd); |
600 | v4l2_ctrl_handler_free(&core->ctrls); | 598 | v4l2_ctrl_handler_free(&core->ctrls); |
601 | kfree(to_mt9v011(sd)); | 599 | |
602 | return 0; | 600 | return 0; |
603 | } | 601 | } |
604 | 602 | ||
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 24ea6fd3ee81..60c6f6739560 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c | |||
@@ -744,7 +744,7 @@ static int mt9v032_probe(struct i2c_client *client, | |||
744 | return -EIO; | 744 | return -EIO; |
745 | } | 745 | } |
746 | 746 | ||
747 | mt9v032 = kzalloc(sizeof(*mt9v032), GFP_KERNEL); | 747 | mt9v032 = devm_kzalloc(&client->dev, sizeof(*mt9v032), GFP_KERNEL); |
748 | if (!mt9v032) | 748 | if (!mt9v032) |
749 | return -ENOMEM; | 749 | return -ENOMEM; |
750 | 750 | ||
@@ -831,10 +831,8 @@ static int mt9v032_probe(struct i2c_client *client, | |||
831 | mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; | 831 | mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; |
832 | ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); | 832 | ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); |
833 | 833 | ||
834 | if (ret < 0) { | 834 | if (ret < 0) |
835 | v4l2_ctrl_handler_free(&mt9v032->ctrls); | 835 | v4l2_ctrl_handler_free(&mt9v032->ctrls); |
836 | kfree(mt9v032); | ||
837 | } | ||
838 | 836 | ||
839 | return ret; | 837 | return ret; |
840 | } | 838 | } |
@@ -847,7 +845,6 @@ static int mt9v032_remove(struct i2c_client *client) | |||
847 | v4l2_ctrl_handler_free(&mt9v032->ctrls); | 845 | v4l2_ctrl_handler_free(&mt9v032->ctrls); |
848 | v4l2_device_unregister_subdev(subdev); | 846 | v4l2_device_unregister_subdev(subdev); |
849 | media_entity_cleanup(&subdev->entity); | 847 | media_entity_cleanup(&subdev->entity); |
850 | kfree(mt9v032); | ||
851 | 848 | ||
852 | return 0; | 849 | return 0; |
853 | } | 850 | } |
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index a115842ab996..d205522e598e 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c | |||
@@ -712,7 +712,7 @@ static int noon010_probe(struct i2c_client *client, | |||
712 | return -EIO; | 712 | return -EIO; |
713 | } | 713 | } |
714 | 714 | ||
715 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 715 | info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); |
716 | if (!info) | 716 | if (!info) |
717 | return -ENOMEM; | 717 | return -ENOMEM; |
718 | 718 | ||
@@ -796,7 +796,6 @@ np_gpio_err: | |||
796 | np_err: | 796 | np_err: |
797 | v4l2_ctrl_handler_free(&info->hdl); | 797 | v4l2_ctrl_handler_free(&info->hdl); |
798 | v4l2_device_unregister_subdev(sd); | 798 | v4l2_device_unregister_subdev(sd); |
799 | kfree(info); | ||
800 | return ret; | 799 | return ret; |
801 | } | 800 | } |
802 | 801 | ||
@@ -817,7 +816,7 @@ static int noon010_remove(struct i2c_client *client) | |||
817 | gpio_free(info->gpio_nstby); | 816 | gpio_free(info->gpio_nstby); |
818 | 817 | ||
819 | media_entity_cleanup(&sd->entity); | 818 | media_entity_cleanup(&sd->entity); |
820 | kfree(info); | 819 | |
821 | return 0; | 820 | return 0; |
822 | } | 821 | } |
823 | 822 | ||
diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c index b0cc927e8b19..5e117abaa2eb 100644 --- a/drivers/media/i2c/ov7640.c +++ b/drivers/media/i2c/ov7640.c | |||
@@ -59,7 +59,7 @@ static int ov7640_probe(struct i2c_client *client, | |||
59 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 59 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
60 | return -ENODEV; | 60 | return -ENODEV; |
61 | 61 | ||
62 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 62 | sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); |
63 | if (sd == NULL) | 63 | if (sd == NULL) |
64 | return -ENOMEM; | 64 | return -ENOMEM; |
65 | v4l2_i2c_subdev_init(sd, client, &ov7640_ops); | 65 | v4l2_i2c_subdev_init(sd, client, &ov7640_ops); |
@@ -71,7 +71,6 @@ static int ov7640_probe(struct i2c_client *client, | |||
71 | 71 | ||
72 | if (write_regs(client, initial_registers) < 0) { | 72 | if (write_regs(client, initial_registers) < 0) { |
73 | v4l_err(client, "error initializing OV7640\n"); | 73 | v4l_err(client, "error initializing OV7640\n"); |
74 | kfree(sd); | ||
75 | return -ENODEV; | 74 | return -ENODEV; |
76 | } | 75 | } |
77 | 76 | ||
@@ -84,7 +83,7 @@ static int ov7640_remove(struct i2c_client *client) | |||
84 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 83 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
85 | 84 | ||
86 | v4l2_device_unregister_subdev(sd); | 85 | v4l2_device_unregister_subdev(sd); |
87 | kfree(sd); | 86 | |
88 | return 0; | 87 | return 0; |
89 | } | 88 | } |
90 | 89 | ||
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 617ad3fff4aa..d71602f4fb43 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c | |||
@@ -1552,7 +1552,7 @@ static int ov7670_probe(struct i2c_client *client, | |||
1552 | struct ov7670_info *info; | 1552 | struct ov7670_info *info; |
1553 | int ret; | 1553 | int ret; |
1554 | 1554 | ||
1555 | info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); | 1555 | info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); |
1556 | if (info == NULL) | 1556 | if (info == NULL) |
1557 | return -ENOMEM; | 1557 | return -ENOMEM; |
1558 | sd = &info->sd; | 1558 | sd = &info->sd; |
@@ -1590,7 +1590,6 @@ static int ov7670_probe(struct i2c_client *client, | |||
1590 | v4l_dbg(1, debug, client, | 1590 | v4l_dbg(1, debug, client, |
1591 | "chip found @ 0x%x (%s) is not an ov7670 chip.\n", | 1591 | "chip found @ 0x%x (%s) is not an ov7670 chip.\n", |
1592 | client->addr << 1, client->adapter->name); | 1592 | client->addr << 1, client->adapter->name); |
1593 | kfree(info); | ||
1594 | return ret; | 1593 | return ret; |
1595 | } | 1594 | } |
1596 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 1595 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
@@ -1635,7 +1634,6 @@ static int ov7670_probe(struct i2c_client *client, | |||
1635 | int err = info->hdl.error; | 1634 | int err = info->hdl.error; |
1636 | 1635 | ||
1637 | v4l2_ctrl_handler_free(&info->hdl); | 1636 | v4l2_ctrl_handler_free(&info->hdl); |
1638 | kfree(info); | ||
1639 | return err; | 1637 | return err; |
1640 | } | 1638 | } |
1641 | /* | 1639 | /* |
@@ -1659,7 +1657,6 @@ static int ov7670_remove(struct i2c_client *client) | |||
1659 | 1657 | ||
1660 | v4l2_device_unregister_subdev(sd); | 1658 | v4l2_device_unregister_subdev(sd); |
1661 | v4l2_ctrl_handler_free(&info->hdl); | 1659 | v4l2_ctrl_handler_free(&info->hdl); |
1662 | kfree(info); | ||
1663 | return 0; | 1660 | return 0; |
1664 | } | 1661 | } |
1665 | 1662 | ||
diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c index b4e1ccbd87ec..729e78d94222 100644 --- a/drivers/media/i2c/saa6588.c +++ b/drivers/media/i2c/saa6588.c | |||
@@ -478,17 +478,15 @@ static int saa6588_probe(struct i2c_client *client, | |||
478 | v4l_info(client, "saa6588 found @ 0x%x (%s)\n", | 478 | v4l_info(client, "saa6588 found @ 0x%x (%s)\n", |
479 | client->addr << 1, client->adapter->name); | 479 | client->addr << 1, client->adapter->name); |
480 | 480 | ||
481 | s = kzalloc(sizeof(*s), GFP_KERNEL); | 481 | s = devm_kzalloc(&client->dev, sizeof(*s), GFP_KERNEL); |
482 | if (s == NULL) | 482 | if (s == NULL) |
483 | return -ENOMEM; | 483 | return -ENOMEM; |
484 | 484 | ||
485 | s->buf_size = bufblocks * 3; | 485 | s->buf_size = bufblocks * 3; |
486 | 486 | ||
487 | s->buffer = kmalloc(s->buf_size, GFP_KERNEL); | 487 | s->buffer = devm_kzalloc(&client->dev, s->buf_size, GFP_KERNEL); |
488 | if (s->buffer == NULL) { | 488 | if (s->buffer == NULL) |
489 | kfree(s); | ||
490 | return -ENOMEM; | 489 | return -ENOMEM; |
491 | } | ||
492 | sd = &s->sd; | 490 | sd = &s->sd; |
493 | v4l2_i2c_subdev_init(sd, client, &saa6588_ops); | 491 | v4l2_i2c_subdev_init(sd, client, &saa6588_ops); |
494 | spin_lock_init(&s->lock); | 492 | spin_lock_init(&s->lock); |
@@ -516,8 +514,6 @@ static int saa6588_remove(struct i2c_client *client) | |||
516 | 514 | ||
517 | cancel_delayed_work_sync(&s->work); | 515 | cancel_delayed_work_sync(&s->work); |
518 | 516 | ||
519 | kfree(s->buffer); | ||
520 | kfree(s); | ||
521 | return 0; | 517 | return 0; |
522 | } | 518 | } |
523 | 519 | ||
diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c index 51cd4c8f0520..e4026aa93f42 100644 --- a/drivers/media/i2c/saa7110.c +++ b/drivers/media/i2c/saa7110.c | |||
@@ -406,7 +406,7 @@ static int saa7110_probe(struct i2c_client *client, | |||
406 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 406 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
407 | client->addr << 1, client->adapter->name); | 407 | client->addr << 1, client->adapter->name); |
408 | 408 | ||
409 | decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); | 409 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
410 | if (!decoder) | 410 | if (!decoder) |
411 | return -ENOMEM; | 411 | return -ENOMEM; |
412 | sd = &decoder->sd; | 412 | sd = &decoder->sd; |
@@ -428,7 +428,6 @@ static int saa7110_probe(struct i2c_client *client, | |||
428 | int err = decoder->hdl.error; | 428 | int err = decoder->hdl.error; |
429 | 429 | ||
430 | v4l2_ctrl_handler_free(&decoder->hdl); | 430 | v4l2_ctrl_handler_free(&decoder->hdl); |
431 | kfree(decoder); | ||
432 | return err; | 431 | return err; |
433 | } | 432 | } |
434 | v4l2_ctrl_handler_setup(&decoder->hdl); | 433 | v4l2_ctrl_handler_setup(&decoder->hdl); |
@@ -469,7 +468,6 @@ static int saa7110_remove(struct i2c_client *client) | |||
469 | 468 | ||
470 | v4l2_device_unregister_subdev(sd); | 469 | v4l2_device_unregister_subdev(sd); |
471 | v4l2_ctrl_handler_free(&decoder->hdl); | 470 | v4l2_ctrl_handler_free(&decoder->hdl); |
472 | kfree(decoder); | ||
473 | return 0; | 471 | return 0; |
474 | } | 472 | } |
475 | 473 | ||
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 52c717d977c9..eecb92df5d96 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c | |||
@@ -1614,7 +1614,7 @@ static int saa711x_probe(struct i2c_client *client, | |||
1614 | v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name, | 1614 | v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name, |
1615 | client->addr << 1, client->adapter->name); | 1615 | client->addr << 1, client->adapter->name); |
1616 | 1616 | ||
1617 | state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); | 1617 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
1618 | if (state == NULL) | 1618 | if (state == NULL) |
1619 | return -ENOMEM; | 1619 | return -ENOMEM; |
1620 | sd = &state->sd; | 1620 | sd = &state->sd; |
@@ -1640,7 +1640,6 @@ static int saa711x_probe(struct i2c_client *client, | |||
1640 | int err = hdl->error; | 1640 | int err = hdl->error; |
1641 | 1641 | ||
1642 | v4l2_ctrl_handler_free(hdl); | 1642 | v4l2_ctrl_handler_free(hdl); |
1643 | kfree(state); | ||
1644 | return err; | 1643 | return err; |
1645 | } | 1644 | } |
1646 | v4l2_ctrl_auto_cluster(2, &state->agc, 0, true); | 1645 | v4l2_ctrl_auto_cluster(2, &state->agc, 0, true); |
@@ -1712,7 +1711,6 @@ static int saa711x_remove(struct i2c_client *client) | |||
1712 | 1711 | ||
1713 | v4l2_device_unregister_subdev(sd); | 1712 | v4l2_device_unregister_subdev(sd); |
1714 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 1713 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
1715 | kfree(to_state(sd)); | ||
1716 | return 0; | 1714 | return 0; |
1717 | } | 1715 | } |
1718 | 1716 | ||
diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c index 8a47ac10927f..9882c83c1c93 100644 --- a/drivers/media/i2c/saa7127.c +++ b/drivers/media/i2c/saa7127.c | |||
@@ -752,7 +752,7 @@ static int saa7127_probe(struct i2c_client *client, | |||
752 | v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n", | 752 | v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n", |
753 | client->addr << 1); | 753 | client->addr << 1); |
754 | 754 | ||
755 | state = kzalloc(sizeof(struct saa7127_state), GFP_KERNEL); | 755 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
756 | if (state == NULL) | 756 | if (state == NULL) |
757 | return -ENOMEM; | 757 | return -ENOMEM; |
758 | 758 | ||
@@ -767,7 +767,6 @@ static int saa7127_probe(struct i2c_client *client, | |||
767 | if ((saa7127_read(sd, 0) & 0xe4) != 0 || | 767 | if ((saa7127_read(sd, 0) & 0xe4) != 0 || |
768 | (saa7127_read(sd, 0x29) & 0x3f) != 0x1d) { | 768 | (saa7127_read(sd, 0x29) & 0x3f) != 0x1d) { |
769 | v4l2_dbg(1, debug, sd, "saa7127 not found\n"); | 769 | v4l2_dbg(1, debug, sd, "saa7127 not found\n"); |
770 | kfree(state); | ||
771 | return -ENODEV; | 770 | return -ENODEV; |
772 | } | 771 | } |
773 | 772 | ||
@@ -823,7 +822,6 @@ static int saa7127_remove(struct i2c_client *client) | |||
823 | v4l2_device_unregister_subdev(sd); | 822 | v4l2_device_unregister_subdev(sd); |
824 | /* Turn off TV output */ | 823 | /* Turn off TV output */ |
825 | saa7127_set_video_enable(sd, 0); | 824 | saa7127_set_video_enable(sd, 0); |
826 | kfree(to_state(sd)); | ||
827 | return 0; | 825 | return 0; |
828 | } | 826 | } |
829 | 827 | ||
diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c index cf3a0aa7e45e..71328109642e 100644 --- a/drivers/media/i2c/saa717x.c +++ b/drivers/media/i2c/saa717x.c | |||
@@ -1262,7 +1262,7 @@ static int saa717x_probe(struct i2c_client *client, | |||
1262 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1262 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1263 | return -EIO; | 1263 | return -EIO; |
1264 | 1264 | ||
1265 | decoder = kzalloc(sizeof(struct saa717x_state), GFP_KERNEL); | 1265 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
1266 | if (decoder == NULL) | 1266 | if (decoder == NULL) |
1267 | return -ENOMEM; | 1267 | return -ENOMEM; |
1268 | 1268 | ||
@@ -1276,7 +1276,6 @@ static int saa717x_probe(struct i2c_client *client, | |||
1276 | id = saa717x_read(sd, 0x5a0); | 1276 | id = saa717x_read(sd, 0x5a0); |
1277 | if (id != 0xc2 && id != 0x32 && id != 0xf2 && id != 0x6c) { | 1277 | if (id != 0xc2 && id != 0x32 && id != 0xf2 && id != 0x6c) { |
1278 | v4l2_dbg(1, debug, sd, "saa717x not found (id=%02x)\n", id); | 1278 | v4l2_dbg(1, debug, sd, "saa717x not found (id=%02x)\n", id); |
1279 | kfree(decoder); | ||
1280 | return -ENODEV; | 1279 | return -ENODEV; |
1281 | } | 1280 | } |
1282 | if (id == 0xc2) | 1281 | if (id == 0xc2) |
@@ -1316,7 +1315,6 @@ static int saa717x_probe(struct i2c_client *client, | |||
1316 | int err = hdl->error; | 1315 | int err = hdl->error; |
1317 | 1316 | ||
1318 | v4l2_ctrl_handler_free(hdl); | 1317 | v4l2_ctrl_handler_free(hdl); |
1319 | kfree(decoder); | ||
1320 | return err; | 1318 | return err; |
1321 | } | 1319 | } |
1322 | 1320 | ||
@@ -1353,7 +1351,6 @@ static int saa717x_remove(struct i2c_client *client) | |||
1353 | 1351 | ||
1354 | v4l2_device_unregister_subdev(sd); | 1352 | v4l2_device_unregister_subdev(sd); |
1355 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 1353 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
1356 | kfree(to_state(sd)); | ||
1357 | return 0; | 1354 | return 0; |
1358 | } | 1355 | } |
1359 | 1356 | ||
diff --git a/drivers/media/i2c/saa7185.c b/drivers/media/i2c/saa7185.c index 2c6b65c76e2b..e95a0edc7f3e 100644 --- a/drivers/media/i2c/saa7185.c +++ b/drivers/media/i2c/saa7185.c | |||
@@ -326,7 +326,7 @@ static int saa7185_probe(struct i2c_client *client, | |||
326 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 326 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
327 | client->addr << 1, client->adapter->name); | 327 | client->addr << 1, client->adapter->name); |
328 | 328 | ||
329 | encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); | 329 | encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); |
330 | if (encoder == NULL) | 330 | if (encoder == NULL) |
331 | return -ENOMEM; | 331 | return -ENOMEM; |
332 | encoder->norm = V4L2_STD_NTSC; | 332 | encoder->norm = V4L2_STD_NTSC; |
@@ -352,7 +352,6 @@ static int saa7185_remove(struct i2c_client *client) | |||
352 | v4l2_device_unregister_subdev(sd); | 352 | v4l2_device_unregister_subdev(sd); |
353 | /* SW: output off is active */ | 353 | /* SW: output off is active */ |
354 | saa7185_write(sd, 0x61, (encoder->reg[0x61]) | 0x40); | 354 | saa7185_write(sd, 0x61, (encoder->reg[0x61]) | 0x40); |
355 | kfree(encoder); | ||
356 | return 0; | 355 | return 0; |
357 | } | 356 | } |
358 | 357 | ||
diff --git a/drivers/media/i2c/saa7191.c b/drivers/media/i2c/saa7191.c index d7d1670e0ca3..84f7899a4044 100644 --- a/drivers/media/i2c/saa7191.c +++ b/drivers/media/i2c/saa7191.c | |||
@@ -605,7 +605,7 @@ static int saa7191_probe(struct i2c_client *client, | |||
605 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 605 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
606 | client->addr << 1, client->adapter->name); | 606 | client->addr << 1, client->adapter->name); |
607 | 607 | ||
608 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); | 608 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
609 | if (!decoder) | 609 | if (!decoder) |
610 | return -ENOMEM; | 610 | return -ENOMEM; |
611 | 611 | ||
@@ -615,7 +615,6 @@ static int saa7191_probe(struct i2c_client *client, | |||
615 | err = saa7191_write_block(sd, sizeof(initseq), initseq); | 615 | err = saa7191_write_block(sd, sizeof(initseq), initseq); |
616 | if (err) { | 616 | if (err) { |
617 | printk(KERN_ERR "SAA7191 initialization failed\n"); | 617 | printk(KERN_ERR "SAA7191 initialization failed\n"); |
618 | kfree(decoder); | ||
619 | return err; | 618 | return err; |
620 | } | 619 | } |
621 | 620 | ||
@@ -636,7 +635,6 @@ static int saa7191_remove(struct i2c_client *client) | |||
636 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 635 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
637 | 636 | ||
638 | v4l2_device_unregister_subdev(sd); | 637 | v4l2_device_unregister_subdev(sd); |
639 | kfree(to_saa7191(sd)); | ||
640 | return 0; | 638 | return 0; |
641 | } | 639 | } |
642 | 640 | ||
diff --git a/drivers/media/i2c/sony-btf-mpx.c b/drivers/media/i2c/sony-btf-mpx.c index 38cbea98764c..efa306165618 100644 --- a/drivers/media/i2c/sony-btf-mpx.c +++ b/drivers/media/i2c/sony-btf-mpx.c | |||
@@ -355,7 +355,7 @@ static int sony_btf_mpx_probe(struct i2c_client *client, | |||
355 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 355 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
356 | client->addr << 1, client->adapter->name); | 356 | client->addr << 1, client->adapter->name); |
357 | 357 | ||
358 | t = kzalloc(sizeof(struct sony_btf_mpx), GFP_KERNEL); | 358 | t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL); |
359 | if (t == NULL) | 359 | if (t == NULL) |
360 | return -ENOMEM; | 360 | return -ENOMEM; |
361 | 361 | ||
@@ -374,7 +374,6 @@ static int sony_btf_mpx_remove(struct i2c_client *client) | |||
374 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 374 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
375 | 375 | ||
376 | v4l2_device_unregister_subdev(sd); | 376 | v4l2_device_unregister_subdev(sd); |
377 | kfree(to_state(sd)); | ||
378 | 377 | ||
379 | return 0; | 378 | return 0; |
380 | } | 379 | } |
diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c index e9d95bda2ab1..4c5a9ee60c3e 100644 --- a/drivers/media/i2c/sr030pc30.c +++ b/drivers/media/i2c/sr030pc30.c | |||
@@ -820,7 +820,7 @@ static int sr030pc30_probe(struct i2c_client *client, | |||
820 | if (ret) | 820 | if (ret) |
821 | return ret; | 821 | return ret; |
822 | 822 | ||
823 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 823 | info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); |
824 | if (!info) | 824 | if (!info) |
825 | return -ENOMEM; | 825 | return -ENOMEM; |
826 | 826 | ||
@@ -841,10 +841,8 @@ static int sr030pc30_probe(struct i2c_client *client, | |||
841 | static int sr030pc30_remove(struct i2c_client *client) | 841 | static int sr030pc30_remove(struct i2c_client *client) |
842 | { | 842 | { |
843 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 843 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
844 | struct sr030pc30_info *info = to_sr030pc30(sd); | ||
845 | 844 | ||
846 | v4l2_device_unregister_subdev(sd); | 845 | v4l2_device_unregister_subdev(sd); |
847 | kfree(info); | ||
848 | return 0; | 846 | return 0; |
849 | } | 847 | } |
850 | 848 | ||
diff --git a/drivers/media/i2c/tda7432.c b/drivers/media/i2c/tda7432.c index 28b5121881f5..72af644fa051 100644 --- a/drivers/media/i2c/tda7432.c +++ b/drivers/media/i2c/tda7432.c | |||
@@ -359,7 +359,7 @@ static int tda7432_probe(struct i2c_client *client, | |||
359 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 359 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
360 | client->addr << 1, client->adapter->name); | 360 | client->addr << 1, client->adapter->name); |
361 | 361 | ||
362 | t = kzalloc(sizeof(*t), GFP_KERNEL); | 362 | t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL); |
363 | if (!t) | 363 | if (!t) |
364 | return -ENOMEM; | 364 | return -ENOMEM; |
365 | sd = &t->sd; | 365 | sd = &t->sd; |
@@ -380,7 +380,6 @@ static int tda7432_probe(struct i2c_client *client, | |||
380 | int err = t->hdl.error; | 380 | int err = t->hdl.error; |
381 | 381 | ||
382 | v4l2_ctrl_handler_free(&t->hdl); | 382 | v4l2_ctrl_handler_free(&t->hdl); |
383 | kfree(t); | ||
384 | return err; | 383 | return err; |
385 | } | 384 | } |
386 | v4l2_ctrl_cluster(2, &t->bass); | 385 | v4l2_ctrl_cluster(2, &t->bass); |
@@ -406,7 +405,6 @@ static int tda7432_remove(struct i2c_client *client) | |||
406 | tda7432_set(sd); | 405 | tda7432_set(sd); |
407 | v4l2_device_unregister_subdev(sd); | 406 | v4l2_device_unregister_subdev(sd); |
408 | v4l2_ctrl_handler_free(&t->hdl); | 407 | v4l2_ctrl_handler_free(&t->hdl); |
409 | kfree(t); | ||
410 | return 0; | 408 | return 0; |
411 | } | 409 | } |
412 | 410 | ||
diff --git a/drivers/media/i2c/tda9840.c b/drivers/media/i2c/tda9840.c index 01441e35d88b..3f1266246ca3 100644 --- a/drivers/media/i2c/tda9840.c +++ b/drivers/media/i2c/tda9840.c | |||
@@ -184,7 +184,7 @@ static int tda9840_probe(struct i2c_client *client, | |||
184 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 184 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
185 | client->addr << 1, client->adapter->name); | 185 | client->addr << 1, client->adapter->name); |
186 | 186 | ||
187 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 187 | sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); |
188 | if (sd == NULL) | 188 | if (sd == NULL) |
189 | return -ENOMEM; | 189 | return -ENOMEM; |
190 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); | 190 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); |
@@ -201,7 +201,6 @@ static int tda9840_remove(struct i2c_client *client) | |||
201 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 201 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
202 | 202 | ||
203 | v4l2_device_unregister_subdev(sd); | 203 | v4l2_device_unregister_subdev(sd); |
204 | kfree(sd); | ||
205 | return 0; | 204 | return 0; |
206 | } | 205 | } |
207 | 206 | ||
diff --git a/drivers/media/i2c/tea6415c.c b/drivers/media/i2c/tea6415c.c index 3d5b06a5c308..52ebc384e453 100644 --- a/drivers/media/i2c/tea6415c.c +++ b/drivers/media/i2c/tea6415c.c | |||
@@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client, | |||
152 | 152 | ||
153 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 153 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
154 | client->addr << 1, client->adapter->name); | 154 | client->addr << 1, client->adapter->name); |
155 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 155 | sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); |
156 | if (sd == NULL) | 156 | if (sd == NULL) |
157 | return -ENOMEM; | 157 | return -ENOMEM; |
158 | v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); | 158 | v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); |
@@ -164,7 +164,6 @@ static int tea6415c_remove(struct i2c_client *client) | |||
164 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 164 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
165 | 165 | ||
166 | v4l2_device_unregister_subdev(sd); | 166 | v4l2_device_unregister_subdev(sd); |
167 | kfree(sd); | ||
168 | return 0; | 167 | return 0; |
169 | } | 168 | } |
170 | 169 | ||
diff --git a/drivers/media/i2c/tea6420.c b/drivers/media/i2c/tea6420.c index 38757217a074..1f869742e3fe 100644 --- a/drivers/media/i2c/tea6420.c +++ b/drivers/media/i2c/tea6420.c | |||
@@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client, | |||
125 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 125 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
126 | client->addr << 1, client->adapter->name); | 126 | client->addr << 1, client->adapter->name); |
127 | 127 | ||
128 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 128 | sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); |
129 | if (sd == NULL) | 129 | if (sd == NULL) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | v4l2_i2c_subdev_init(sd, client, &tea6420_ops); | 131 | v4l2_i2c_subdev_init(sd, client, &tea6420_ops); |
@@ -146,7 +146,6 @@ static int tea6420_remove(struct i2c_client *client) | |||
146 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 146 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
147 | 147 | ||
148 | v4l2_device_unregister_subdev(sd); | 148 | v4l2_device_unregister_subdev(sd); |
149 | kfree(sd); | ||
150 | return 0; | 149 | return 0; |
151 | } | 150 | } |
152 | 151 | ||
diff --git a/drivers/media/i2c/tlv320aic23b.c b/drivers/media/i2c/tlv320aic23b.c index 809a75a558ee..ef87f7b09ea2 100644 --- a/drivers/media/i2c/tlv320aic23b.c +++ b/drivers/media/i2c/tlv320aic23b.c | |||
@@ -162,7 +162,7 @@ static int tlv320aic23b_probe(struct i2c_client *client, | |||
162 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 162 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
163 | client->addr << 1, client->adapter->name); | 163 | client->addr << 1, client->adapter->name); |
164 | 164 | ||
165 | state = kzalloc(sizeof(struct tlv320aic23b_state), GFP_KERNEL); | 165 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
166 | if (state == NULL) | 166 | if (state == NULL) |
167 | return -ENOMEM; | 167 | return -ENOMEM; |
168 | sd = &state->sd; | 168 | sd = &state->sd; |
@@ -191,7 +191,6 @@ static int tlv320aic23b_probe(struct i2c_client *client, | |||
191 | int err = state->hdl.error; | 191 | int err = state->hdl.error; |
192 | 192 | ||
193 | v4l2_ctrl_handler_free(&state->hdl); | 193 | v4l2_ctrl_handler_free(&state->hdl); |
194 | kfree(state); | ||
195 | return err; | 194 | return err; |
196 | } | 195 | } |
197 | v4l2_ctrl_handler_setup(&state->hdl); | 196 | v4l2_ctrl_handler_setup(&state->hdl); |
@@ -205,7 +204,6 @@ static int tlv320aic23b_remove(struct i2c_client *client) | |||
205 | 204 | ||
206 | v4l2_device_unregister_subdev(sd); | 205 | v4l2_device_unregister_subdev(sd); |
207 | v4l2_ctrl_handler_free(&state->hdl); | 206 | v4l2_ctrl_handler_free(&state->hdl); |
208 | kfree(state); | ||
209 | return 0; | 207 | return 0; |
210 | } | 208 | } |
211 | 209 | ||
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c index b72a59d3216a..fc69e9c27343 100644 --- a/drivers/media/i2c/tvaudio.c +++ b/drivers/media/i2c/tvaudio.c | |||
@@ -1910,7 +1910,7 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * | |||
1910 | printk("\n"); | 1910 | printk("\n"); |
1911 | } | 1911 | } |
1912 | 1912 | ||
1913 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1913 | chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
1914 | if (!chip) | 1914 | if (!chip) |
1915 | return -ENOMEM; | 1915 | return -ENOMEM; |
1916 | sd = &chip->sd; | 1916 | sd = &chip->sd; |
@@ -1930,7 +1930,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * | |||
1930 | } | 1930 | } |
1931 | if (desc->name == NULL) { | 1931 | if (desc->name == NULL) { |
1932 | v4l2_dbg(1, debug, sd, "no matching chip description found\n"); | 1932 | v4l2_dbg(1, debug, sd, "no matching chip description found\n"); |
1933 | kfree(chip); | ||
1934 | return -EIO; | 1933 | return -EIO; |
1935 | } | 1934 | } |
1936 | v4l2_info(sd, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); | 1935 | v4l2_info(sd, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); |
@@ -2001,7 +2000,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * | |||
2001 | int err = chip->hdl.error; | 2000 | int err = chip->hdl.error; |
2002 | 2001 | ||
2003 | v4l2_ctrl_handler_free(&chip->hdl); | 2002 | v4l2_ctrl_handler_free(&chip->hdl); |
2004 | kfree(chip); | ||
2005 | return err; | 2003 | return err; |
2006 | } | 2004 | } |
2007 | /* set controls to the default values */ | 2005 | /* set controls to the default values */ |
@@ -2043,7 +2041,6 @@ static int tvaudio_remove(struct i2c_client *client) | |||
2043 | 2041 | ||
2044 | v4l2_device_unregister_subdev(sd); | 2042 | v4l2_device_unregister_subdev(sd); |
2045 | v4l2_ctrl_handler_free(&chip->hdl); | 2043 | v4l2_ctrl_handler_free(&chip->hdl); |
2046 | kfree(chip); | ||
2047 | return 0; | 2044 | return 0; |
2048 | } | 2045 | } |
2049 | 2046 | ||
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 485159a3c0b7..de9db3bf1ebd 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c | |||
@@ -1152,10 +1152,9 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1152 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | 1152 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) |
1153 | return -EIO; | 1153 | return -EIO; |
1154 | 1154 | ||
1155 | core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL); | 1155 | core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL); |
1156 | if (!core) { | 1156 | if (!core) |
1157 | return -ENOMEM; | 1157 | return -ENOMEM; |
1158 | } | ||
1159 | sd = &core->sd; | 1158 | sd = &core->sd; |
1160 | v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); | 1159 | v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); |
1161 | 1160 | ||
@@ -1166,7 +1165,7 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1166 | for (i = 0; i < 4; i++) { | 1165 | for (i = 0; i < 4; i++) { |
1167 | res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i); | 1166 | res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i); |
1168 | if (res < 0) | 1167 | if (res < 0) |
1169 | goto free_core; | 1168 | return res; |
1170 | tvp5150_id[i] = res; | 1169 | tvp5150_id[i] = res; |
1171 | } | 1170 | } |
1172 | 1171 | ||
@@ -1209,7 +1208,7 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1209 | if (core->hdl.error) { | 1208 | if (core->hdl.error) { |
1210 | res = core->hdl.error; | 1209 | res = core->hdl.error; |
1211 | v4l2_ctrl_handler_free(&core->hdl); | 1210 | v4l2_ctrl_handler_free(&core->hdl); |
1212 | goto free_core; | 1211 | return res; |
1213 | } | 1212 | } |
1214 | v4l2_ctrl_handler_setup(&core->hdl); | 1213 | v4l2_ctrl_handler_setup(&core->hdl); |
1215 | 1214 | ||
@@ -1225,10 +1224,6 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1225 | if (debug > 1) | 1224 | if (debug > 1) |
1226 | tvp5150_log_status(sd); | 1225 | tvp5150_log_status(sd); |
1227 | return 0; | 1226 | return 0; |
1228 | |||
1229 | free_core: | ||
1230 | kfree(core); | ||
1231 | return res; | ||
1232 | } | 1227 | } |
1233 | 1228 | ||
1234 | static int tvp5150_remove(struct i2c_client *c) | 1229 | static int tvp5150_remove(struct i2c_client *c) |
@@ -1242,7 +1237,6 @@ static int tvp5150_remove(struct i2c_client *c) | |||
1242 | 1237 | ||
1243 | v4l2_device_unregister_subdev(sd); | 1238 | v4l2_device_unregister_subdev(sd); |
1244 | v4l2_ctrl_handler_free(&decoder->hdl); | 1239 | v4l2_ctrl_handler_free(&decoder->hdl); |
1245 | kfree(to_tvp5150(sd)); | ||
1246 | return 0; | 1240 | return 0; |
1247 | } | 1241 | } |
1248 | 1242 | ||
diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c index c5dc2c3bf2d7..41a5c9b31006 100644 --- a/drivers/media/i2c/tw2804.c +++ b/drivers/media/i2c/tw2804.c | |||
@@ -368,8 +368,7 @@ static int tw2804_probe(struct i2c_client *client, | |||
368 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 368 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
369 | return -ENODEV; | 369 | return -ENODEV; |
370 | 370 | ||
371 | state = kzalloc(sizeof(struct tw2804), GFP_KERNEL); | 371 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
372 | |||
373 | if (state == NULL) | 372 | if (state == NULL) |
374 | return -ENOMEM; | 373 | return -ENOMEM; |
375 | sd = &state->sd; | 374 | sd = &state->sd; |
@@ -410,7 +409,6 @@ static int tw2804_probe(struct i2c_client *client, | |||
410 | err = state->hdl.error; | 409 | err = state->hdl.error; |
411 | if (err) { | 410 | if (err) { |
412 | v4l2_ctrl_handler_free(&state->hdl); | 411 | v4l2_ctrl_handler_free(&state->hdl); |
413 | kfree(state); | ||
414 | return err; | 412 | return err; |
415 | } | 413 | } |
416 | 414 | ||
@@ -427,7 +425,6 @@ static int tw2804_remove(struct i2c_client *client) | |||
427 | 425 | ||
428 | v4l2_device_unregister_subdev(sd); | 426 | v4l2_device_unregister_subdev(sd); |
429 | v4l2_ctrl_handler_free(&state->hdl); | 427 | v4l2_ctrl_handler_free(&state->hdl); |
430 | kfree(state); | ||
431 | return 0; | 428 | return 0; |
432 | } | 429 | } |
433 | 430 | ||
diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c index 87880b19d8c3..285b759a5f7f 100644 --- a/drivers/media/i2c/tw9903.c +++ b/drivers/media/i2c/tw9903.c | |||
@@ -215,7 +215,7 @@ static int tw9903_probe(struct i2c_client *client, | |||
215 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 215 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
216 | client->addr << 1, client->adapter->name); | 216 | client->addr << 1, client->adapter->name); |
217 | 217 | ||
218 | dec = kzalloc(sizeof(struct tw9903), GFP_KERNEL); | 218 | dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL); |
219 | if (dec == NULL) | 219 | if (dec == NULL) |
220 | return -ENOMEM; | 220 | return -ENOMEM; |
221 | sd = &dec->sd; | 221 | sd = &dec->sd; |
@@ -233,7 +233,6 @@ static int tw9903_probe(struct i2c_client *client, | |||
233 | int err = hdl->error; | 233 | int err = hdl->error; |
234 | 234 | ||
235 | v4l2_ctrl_handler_free(hdl); | 235 | v4l2_ctrl_handler_free(hdl); |
236 | kfree(dec); | ||
237 | return err; | 236 | return err; |
238 | } | 237 | } |
239 | 238 | ||
@@ -242,7 +241,6 @@ static int tw9903_probe(struct i2c_client *client, | |||
242 | 241 | ||
243 | if (write_regs(sd, initial_registers) < 0) { | 242 | if (write_regs(sd, initial_registers) < 0) { |
244 | v4l2_err(client, "error initializing TW9903\n"); | 243 | v4l2_err(client, "error initializing TW9903\n"); |
245 | kfree(dec); | ||
246 | return -EINVAL; | 244 | return -EINVAL; |
247 | } | 245 | } |
248 | 246 | ||
@@ -255,7 +253,6 @@ static int tw9903_remove(struct i2c_client *client) | |||
255 | 253 | ||
256 | v4l2_device_unregister_subdev(sd); | 254 | v4l2_device_unregister_subdev(sd); |
257 | v4l2_ctrl_handler_free(&to_state(sd)->hdl); | 255 | v4l2_ctrl_handler_free(&to_state(sd)->hdl); |
258 | kfree(to_state(sd)); | ||
259 | return 0; | 256 | return 0; |
260 | } | 257 | } |
261 | 258 | ||
diff --git a/drivers/media/i2c/tw9906.c b/drivers/media/i2c/tw9906.c index accd79e5a7fd..f6bef25bd9ce 100644 --- a/drivers/media/i2c/tw9906.c +++ b/drivers/media/i2c/tw9906.c | |||
@@ -183,7 +183,7 @@ static int tw9906_probe(struct i2c_client *client, | |||
183 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 183 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
184 | client->addr << 1, client->adapter->name); | 184 | client->addr << 1, client->adapter->name); |
185 | 185 | ||
186 | dec = kzalloc(sizeof(struct tw9906), GFP_KERNEL); | 186 | dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL); |
187 | if (dec == NULL) | 187 | if (dec == NULL) |
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | sd = &dec->sd; | 189 | sd = &dec->sd; |
@@ -201,7 +201,6 @@ static int tw9906_probe(struct i2c_client *client, | |||
201 | int err = hdl->error; | 201 | int err = hdl->error; |
202 | 202 | ||
203 | v4l2_ctrl_handler_free(hdl); | 203 | v4l2_ctrl_handler_free(hdl); |
204 | kfree(dec); | ||
205 | return err; | 204 | return err; |
206 | } | 205 | } |
207 | 206 | ||
@@ -210,7 +209,6 @@ static int tw9906_probe(struct i2c_client *client, | |||
210 | 209 | ||
211 | if (write_regs(sd, initial_registers) < 0) { | 210 | if (write_regs(sd, initial_registers) < 0) { |
212 | v4l2_err(client, "error initializing TW9906\n"); | 211 | v4l2_err(client, "error initializing TW9906\n"); |
213 | kfree(dec); | ||
214 | return -EINVAL; | 212 | return -EINVAL; |
215 | } | 213 | } |
216 | 214 | ||
@@ -223,7 +221,6 @@ static int tw9906_remove(struct i2c_client *client) | |||
223 | 221 | ||
224 | v4l2_device_unregister_subdev(sd); | 222 | v4l2_device_unregister_subdev(sd); |
225 | v4l2_ctrl_handler_free(&to_state(sd)->hdl); | 223 | v4l2_ctrl_handler_free(&to_state(sd)->hdl); |
226 | kfree(to_state(sd)); | ||
227 | return 0; | 224 | return 0; |
228 | } | 225 | } |
229 | 226 | ||
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c index 3af408556d27..081786d176d0 100644 --- a/drivers/media/i2c/uda1342.c +++ b/drivers/media/i2c/uda1342.c | |||
@@ -69,7 +69,7 @@ static int uda1342_probe(struct i2c_client *client, | |||
69 | dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n", | 69 | dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n", |
70 | client->addr, adapter->name); | 70 | client->addr, adapter->name); |
71 | 71 | ||
72 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | 72 | sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); |
73 | if (sd == NULL) | 73 | if (sd == NULL) |
74 | return -ENOMEM; | 74 | return -ENOMEM; |
75 | 75 | ||
@@ -89,7 +89,6 @@ static int uda1342_remove(struct i2c_client *client) | |||
89 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 89 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
90 | 90 | ||
91 | v4l2_device_unregister_subdev(sd); | 91 | v4l2_device_unregister_subdev(sd); |
92 | kfree(sd); | ||
93 | return 0; | 92 | return 0; |
94 | } | 93 | } |
95 | 94 | ||
diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c index f0a09214c519..4283fc5f39ef 100644 --- a/drivers/media/i2c/upd64031a.c +++ b/drivers/media/i2c/upd64031a.c | |||
@@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client, | |||
230 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 230 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
231 | client->addr << 1, client->adapter->name); | 231 | client->addr << 1, client->adapter->name); |
232 | 232 | ||
233 | state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL); | 233 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
234 | if (state == NULL) | 234 | if (state == NULL) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | sd = &state->sd; | 236 | sd = &state->sd; |
@@ -249,7 +249,6 @@ static int upd64031a_remove(struct i2c_client *client) | |||
249 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 249 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
250 | 250 | ||
251 | v4l2_device_unregister_subdev(sd); | 251 | v4l2_device_unregister_subdev(sd); |
252 | kfree(to_state(sd)); | ||
253 | return 0; | 252 | return 0; |
254 | } | 253 | } |
255 | 254 | ||
diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c index 343e0215f74c..b2ac56ca22e6 100644 --- a/drivers/media/i2c/upd64083.c +++ b/drivers/media/i2c/upd64083.c | |||
@@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client, | |||
202 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 202 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
203 | client->addr << 1, client->adapter->name); | 203 | client->addr << 1, client->adapter->name); |
204 | 204 | ||
205 | state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL); | 205 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
206 | if (state == NULL) | 206 | if (state == NULL) |
207 | return -ENOMEM; | 207 | return -ENOMEM; |
208 | sd = &state->sd; | 208 | sd = &state->sd; |
@@ -221,7 +221,6 @@ static int upd64083_remove(struct i2c_client *client) | |||
221 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 221 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
222 | 222 | ||
223 | v4l2_device_unregister_subdev(sd); | 223 | v4l2_device_unregister_subdev(sd); |
224 | kfree(to_state(sd)); | ||
225 | return 0; | 224 | return 0; |
226 | } | 225 | } |
227 | 226 | ||
diff --git a/drivers/media/i2c/vp27smpx.c b/drivers/media/i2c/vp27smpx.c index e71f139695af..208a095d7bcc 100644 --- a/drivers/media/i2c/vp27smpx.c +++ b/drivers/media/i2c/vp27smpx.c | |||
@@ -169,7 +169,7 @@ static int vp27smpx_probe(struct i2c_client *client, | |||
169 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 169 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
170 | client->addr << 1, client->adapter->name); | 170 | client->addr << 1, client->adapter->name); |
171 | 171 | ||
172 | state = kzalloc(sizeof(struct vp27smpx_state), GFP_KERNEL); | 172 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
173 | if (state == NULL) | 173 | if (state == NULL) |
174 | return -ENOMEM; | 174 | return -ENOMEM; |
175 | sd = &state->sd; | 175 | sd = &state->sd; |
@@ -186,7 +186,6 @@ static int vp27smpx_remove(struct i2c_client *client) | |||
186 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 186 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
187 | 187 | ||
188 | v4l2_device_unregister_subdev(sd); | 188 | v4l2_device_unregister_subdev(sd); |
189 | kfree(to_state(sd)); | ||
190 | return 0; | 189 | return 0; |
191 | } | 190 | } |
192 | 191 | ||
diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c index 2f67b4c5c823..f02e74b9b1ac 100644 --- a/drivers/media/i2c/vpx3220.c +++ b/drivers/media/i2c/vpx3220.c | |||
@@ -499,7 +499,7 @@ static int vpx3220_probe(struct i2c_client *client, | |||
499 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) | 499 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) |
500 | return -ENODEV; | 500 | return -ENODEV; |
501 | 501 | ||
502 | decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); | 502 | decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); |
503 | if (decoder == NULL) | 503 | if (decoder == NULL) |
504 | return -ENOMEM; | 504 | return -ENOMEM; |
505 | sd = &decoder->sd; | 505 | sd = &decoder->sd; |
@@ -521,7 +521,6 @@ static int vpx3220_probe(struct i2c_client *client, | |||
521 | int err = decoder->hdl.error; | 521 | int err = decoder->hdl.error; |
522 | 522 | ||
523 | v4l2_ctrl_handler_free(&decoder->hdl); | 523 | v4l2_ctrl_handler_free(&decoder->hdl); |
524 | kfree(decoder); | ||
525 | return err; | 524 | return err; |
526 | } | 525 | } |
527 | v4l2_ctrl_handler_setup(&decoder->hdl); | 526 | v4l2_ctrl_handler_setup(&decoder->hdl); |
@@ -566,7 +565,7 @@ static int vpx3220_remove(struct i2c_client *client) | |||
566 | 565 | ||
567 | v4l2_device_unregister_subdev(sd); | 566 | v4l2_device_unregister_subdev(sd); |
568 | v4l2_ctrl_handler_free(&decoder->hdl); | 567 | v4l2_ctrl_handler_free(&decoder->hdl); |
569 | kfree(decoder); | 568 | |
570 | return 0; | 569 | return 0; |
571 | } | 570 | } |
572 | 571 | ||
diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index 6b8c0b7aa488..94e284908f39 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c | |||
@@ -813,11 +813,9 @@ static int vs6624_probe(struct i2c_client *client, | |||
813 | /* wait 100ms before any further i2c writes are performed */ | 813 | /* wait 100ms before any further i2c writes are performed */ |
814 | mdelay(100); | 814 | mdelay(100); |
815 | 815 | ||
816 | sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); | 816 | sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); |
817 | if (sensor == NULL) { | 817 | if (sensor == NULL) |
818 | gpio_free(*ce); | ||
819 | return -ENOMEM; | 818 | return -ENOMEM; |
820 | } | ||
821 | 819 | ||
822 | sd = &sensor->sd; | 820 | sd = &sensor->sd; |
823 | v4l2_i2c_subdev_init(sd, client, &vs6624_ops); | 821 | v4l2_i2c_subdev_init(sd, client, &vs6624_ops); |
@@ -865,7 +863,6 @@ static int vs6624_probe(struct i2c_client *client, | |||
865 | int err = hdl->error; | 863 | int err = hdl->error; |
866 | 864 | ||
867 | v4l2_ctrl_handler_free(hdl); | 865 | v4l2_ctrl_handler_free(hdl); |
868 | kfree(sensor); | ||
869 | gpio_free(*ce); | 866 | gpio_free(*ce); |
870 | return err; | 867 | return err; |
871 | } | 868 | } |
@@ -874,7 +871,6 @@ static int vs6624_probe(struct i2c_client *client, | |||
874 | ret = v4l2_ctrl_handler_setup(hdl); | 871 | ret = v4l2_ctrl_handler_setup(hdl); |
875 | if (ret) { | 872 | if (ret) { |
876 | v4l2_ctrl_handler_free(hdl); | 873 | v4l2_ctrl_handler_free(hdl); |
877 | kfree(sensor); | ||
878 | gpio_free(*ce); | 874 | gpio_free(*ce); |
879 | } | 875 | } |
880 | return ret; | 876 | return ret; |
@@ -888,7 +884,6 @@ static int vs6624_remove(struct i2c_client *client) | |||
888 | v4l2_device_unregister_subdev(sd); | 884 | v4l2_device_unregister_subdev(sd); |
889 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 885 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
890 | gpio_free(sensor->ce_pin); | 886 | gpio_free(sensor->ce_pin); |
891 | kfree(sensor); | ||
892 | return 0; | 887 | return 0; |
893 | } | 888 | } |
894 | 889 | ||
diff --git a/drivers/media/i2c/wm8739.c b/drivers/media/i2c/wm8739.c index 3bb99e93febe..ac3faa7bab2d 100644 --- a/drivers/media/i2c/wm8739.c +++ b/drivers/media/i2c/wm8739.c | |||
@@ -220,7 +220,7 @@ static int wm8739_probe(struct i2c_client *client, | |||
220 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 220 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
221 | client->addr << 1, client->adapter->name); | 221 | client->addr << 1, client->adapter->name); |
222 | 222 | ||
223 | state = kzalloc(sizeof(struct wm8739_state), GFP_KERNEL); | 223 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
224 | if (state == NULL) | 224 | if (state == NULL) |
225 | return -ENOMEM; | 225 | return -ENOMEM; |
226 | sd = &state->sd; | 226 | sd = &state->sd; |
@@ -237,7 +237,6 @@ static int wm8739_probe(struct i2c_client *client, | |||
237 | int err = state->hdl.error; | 237 | int err = state->hdl.error; |
238 | 238 | ||
239 | v4l2_ctrl_handler_free(&state->hdl); | 239 | v4l2_ctrl_handler_free(&state->hdl); |
240 | kfree(state); | ||
241 | return err; | 240 | return err; |
242 | } | 241 | } |
243 | v4l2_ctrl_cluster(3, &state->volume); | 242 | v4l2_ctrl_cluster(3, &state->volume); |
@@ -271,7 +270,6 @@ static int wm8739_remove(struct i2c_client *client) | |||
271 | 270 | ||
272 | v4l2_device_unregister_subdev(sd); | 271 | v4l2_device_unregister_subdev(sd); |
273 | v4l2_ctrl_handler_free(&state->hdl); | 272 | v4l2_ctrl_handler_free(&state->hdl); |
274 | kfree(to_state(sd)); | ||
275 | return 0; | 273 | return 0; |
276 | } | 274 | } |
277 | 275 | ||
diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c index 27c27b4ae238..75ded82d513f 100644 --- a/drivers/media/i2c/wm8775.c +++ b/drivers/media/i2c/wm8775.c | |||
@@ -241,7 +241,7 @@ static int wm8775_probe(struct i2c_client *client, | |||
241 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | 241 | v4l_info(client, "chip found @ 0x%02x (%s)\n", |
242 | client->addr << 1, client->adapter->name); | 242 | client->addr << 1, client->adapter->name); |
243 | 243 | ||
244 | state = kzalloc(sizeof(struct wm8775_state), GFP_KERNEL); | 244 | state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); |
245 | if (state == NULL) | 245 | if (state == NULL) |
246 | return -ENOMEM; | 246 | return -ENOMEM; |
247 | sd = &state->sd; | 247 | sd = &state->sd; |
@@ -261,7 +261,6 @@ static int wm8775_probe(struct i2c_client *client, | |||
261 | err = state->hdl.error; | 261 | err = state->hdl.error; |
262 | if (err) { | 262 | if (err) { |
263 | v4l2_ctrl_handler_free(&state->hdl); | 263 | v4l2_ctrl_handler_free(&state->hdl); |
264 | kfree(state); | ||
265 | return err; | 264 | return err; |
266 | } | 265 | } |
267 | 266 | ||
@@ -319,7 +318,6 @@ static int wm8775_remove(struct i2c_client *client) | |||
319 | 318 | ||
320 | v4l2_device_unregister_subdev(sd); | 319 | v4l2_device_unregister_subdev(sd); |
321 | v4l2_ctrl_handler_free(&state->hdl); | 320 | v4l2_ctrl_handler_free(&state->hdl); |
322 | kfree(state); | ||
323 | return 0; | 321 | return 0; |
324 | } | 322 | } |
325 | 323 | ||