diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-12-21 17:28:43 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-01-05 07:45:31 +0400 |
commit | 70e176a5a9839ea22f0fbcfa21d1c8ae952a0dd2 (patch) | |
tree | 4ab23748088e87ae0eb086a41dfdad4a222c0206 /drivers/media/i2c/soc_camera/mt9t031.c | |
parent | 25a348110078cefa99b0b079938dd930cfc3a0be (diff) | |
download | linux-70e176a5a9839ea22f0fbcfa21d1c8ae952a0dd2.tar.xz |
[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/mt9t031.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9t031.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index 9ca6d65cefaf..d80d044ebf15 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -773,7 +773,7 @@ static int mt9t031_probe(struct i2c_client *client, return -EIO; } - mt9t031 = kzalloc(sizeof(struct mt9t031), GFP_KERNEL); + mt9t031 = devm_kzalloc(&client->dev, sizeof(struct mt9t031), GFP_KERNEL); if (!mt9t031) return -ENOMEM; @@ -797,12 +797,9 @@ static int mt9t031_probe(struct i2c_client *client, V4L2_CID_EXPOSURE, 1, 255, 1, 255); mt9t031->subdev.ctrl_handler = &mt9t031->hdl; - if (mt9t031->hdl.error) { - int err = mt9t031->hdl.error; + if (mt9t031->hdl.error) + return mt9t031->hdl.error; - kfree(mt9t031); - return err; - } v4l2_ctrl_auto_cluster(2, &mt9t031->autoexposure, V4L2_EXPOSURE_MANUAL, true); @@ -816,10 +813,8 @@ static int mt9t031_probe(struct i2c_client *client, mt9t031->yskip = 1; ret = mt9t031_video_probe(client); - if (ret) { + if (ret) v4l2_ctrl_handler_free(&mt9t031->hdl); - kfree(mt9t031); - } return ret; } @@ -830,7 +825,6 @@ static int mt9t031_remove(struct i2c_client *client) v4l2_device_unregister_subdev(&mt9t031->subdev); v4l2_ctrl_handler_free(&mt9t031->hdl); - kfree(mt9t031); return 0; } |