diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-12-21 10:28:43 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-01-05 01:45:31 -0200 |
commit | 70e176a5a9839ea22f0fbcfa21d1c8ae952a0dd2 (patch) | |
tree | 4ab23748088e87ae0eb086a41dfdad4a222c0206 /drivers/media/i2c/soc_camera/mt9m111.c | |
parent | 25a348110078cefa99b0b079938dd930cfc3a0be (diff) | |
download | lwn-70e176a5a9839ea22f0fbcfa21d1c8ae952a0dd2.tar.gz lwn-70e176a5a9839ea22f0fbcfa21d1c8ae952a0dd2.zip |
[media] soc-camera: use devm_kzalloc in subdevice drivers
I2C drivers can use devm_kzalloc() too in their .probe() methods. Doing so
simplifies their clean up paths.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9m111.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9m111.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index 78511669bab0..bbc4ff99603c 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c @@ -971,7 +971,7 @@ static int mt9m111_probe(struct i2c_client *client, return -EIO; } - mt9m111 = kzalloc(sizeof(struct mt9m111), GFP_KERNEL); + mt9m111 = devm_kzalloc(&client->dev, sizeof(struct mt9m111), GFP_KERNEL); if (!mt9m111) return -ENOMEM; @@ -989,12 +989,8 @@ static int mt9m111_probe(struct i2c_client *client, &mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, V4L2_EXPOSURE_AUTO); mt9m111->subdev.ctrl_handler = &mt9m111->hdl; - if (mt9m111->hdl.error) { - int err = mt9m111->hdl.error; - - kfree(mt9m111); - return err; - } + if (mt9m111->hdl.error) + return mt9m111->hdl.error; /* Second stage probe - when a capture adapter is there */ mt9m111->rect.left = MT9M111_MIN_DARK_COLS; @@ -1006,10 +1002,8 @@ static int mt9m111_probe(struct i2c_client *client, mutex_init(&mt9m111->power_lock); ret = mt9m111_video_probe(client); - if (ret) { + if (ret) v4l2_ctrl_handler_free(&mt9m111->hdl); - kfree(mt9m111); - } return ret; } @@ -1020,7 +1014,6 @@ static int mt9m111_remove(struct i2c_client *client) v4l2_device_unregister_subdev(&mt9m111->subdev); v4l2_ctrl_handler_free(&mt9m111->hdl); - kfree(mt9m111); return 0; } |