[media] em28xx-v4l: simplify em28xx_v4l2_open() by using v4l2_fh_open()
Instead of calling ... struct v4l2_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL); filp->private_data = fh; v4l2_fh_init(fh, vdev); v4l2_fh_add(fh); ... simply use function v4l2_fh_open() which does all of these calls for us. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
917ba6b0b6
commit
3c0f90e14c
1 changed files with 7 additions and 8 deletions
|
@ -1868,7 +1868,7 @@ static int em28xx_v4l2_open(struct file *filp)
|
||||||
struct em28xx *dev = video_drvdata(filp);
|
struct em28xx *dev = video_drvdata(filp);
|
||||||
struct em28xx_v4l2 *v4l2 = dev->v4l2;
|
struct em28xx_v4l2 *v4l2 = dev->v4l2;
|
||||||
enum v4l2_buf_type fh_type = 0;
|
enum v4l2_buf_type fh_type = 0;
|
||||||
struct v4l2_fh *fh;
|
int ret;
|
||||||
|
|
||||||
switch (vdev->vfl_type) {
|
switch (vdev->vfl_type) {
|
||||||
case VFL_TYPE_GRABBER:
|
case VFL_TYPE_GRABBER:
|
||||||
|
@ -1889,14 +1889,14 @@ static int em28xx_v4l2_open(struct file *filp)
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&dev->lock))
|
if (mutex_lock_interruptible(&dev->lock))
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
fh = kzalloc(sizeof(struct v4l2_fh), GFP_KERNEL);
|
|
||||||
if (!fh) {
|
ret = v4l2_fh_open(filp);
|
||||||
em28xx_errdev("em28xx-video.c: Out of memory?!\n");
|
if (ret) {
|
||||||
|
em28xx_errdev("%s: v4l2_fh_open() returned error %d\n",
|
||||||
|
__func__, ret);
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
return -ENOMEM;
|
return ret;
|
||||||
}
|
}
|
||||||
v4l2_fh_init(fh, vdev);
|
|
||||||
filp->private_data = fh;
|
|
||||||
|
|
||||||
if (v4l2->users == 0) {
|
if (v4l2->users == 0) {
|
||||||
em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
|
em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
|
||||||
|
@ -1921,7 +1921,6 @@ static int em28xx_v4l2_open(struct file *filp)
|
||||||
v4l2->users++;
|
v4l2->users++;
|
||||||
|
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
v4l2_fh_add(fh);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue