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 /drivers/media/i2c/ir-kbd-i2c.c | |
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>
Diffstat (limited to 'drivers/media/i2c/ir-kbd-i2c.c')
-rw-r--r-- | drivers/media/i2c/ir-kbd-i2c.c | 10 |
1 files changed, 3 insertions, 7 deletions
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 | ||