diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 7b332bf70ec0fb45b76534618b77ac2ca901d258..110673a4db103f9686b0a771a549c917c1ac2757 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -934,7 +934,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) if (rc) return rc; - if (dev->streaming_users == 0) { + if (v4l2->streaming_users == 0) { /* First active streaming user, so allocate all the URBs */ /* Allocate the USB bandwidth */ @@ -972,7 +972,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) 0, tuner, s_frequency, &f); } - dev->streaming_users++; + v4l2->streaming_users++; return rc; } @@ -980,6 +980,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) static void em28xx_stop_streaming(struct vb2_queue *vq) { struct em28xx *dev = vb2_get_drv_priv(vq); + struct em28xx_v4l2 *v4l2 = dev->v4l2; struct em28xx_dmaqueue *vidq = &dev->vidq; unsigned long flags = 0; @@ -987,7 +988,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq) res_free(dev, vq->type); - if (dev->streaming_users-- == 1) { + if (v4l2->streaming_users-- == 1) { /* Last active user, so shutdown all the URBS */ em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); } @@ -1006,6 +1007,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq) void em28xx_stop_vbi_streaming(struct vb2_queue *vq) { struct em28xx *dev = vb2_get_drv_priv(vq); + struct em28xx_v4l2 *v4l2 = dev->v4l2; struct em28xx_dmaqueue *vbiq = &dev->vbiq; unsigned long flags = 0; @@ -1013,7 +1015,7 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq) res_free(dev, vq->type); - if (dev->streaming_users-- == 1) { + if (v4l2->streaming_users-- == 1) { /* Last active user, so shutdown all the URBS */ em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); } @@ -1340,8 +1342,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct em28xx *dev = video_drvdata(file); + struct em28xx_v4l2 *v4l2 = dev->v4l2; - if (dev->streaming_users > 0) + if (v4l2->streaming_users > 0) return -EBUSY; vidioc_try_fmt_vid_cap(file, priv, f); @@ -1380,7 +1383,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) if (norm == v4l2->norm) return 0; - if (dev->streaming_users > 0) + if (v4l2->streaming_users > 0) return -EBUSY; v4l2->norm = norm; @@ -1903,7 +1906,7 @@ static int em28xx_v4l2_open(struct file *filp) em28xx_videodbg("open dev=%s type=%s users=%d\n", video_device_node_name(vdev), v4l2_type_names[fh_type], - dev->users); + v4l2->users); if (mutex_lock_interruptible(&dev->lock)) return -ERESTARTSYS; @@ -1918,7 +1921,7 @@ static int em28xx_v4l2_open(struct file *filp) fh->type = fh_type; filp->private_data = fh; - if (dev->users == 0) { + if (v4l2->users == 0) { em28xx_set_mode(dev, EM28XX_ANALOG_MODE); if (vdev->vfl_type != VFL_TYPE_RADIO) @@ -1938,7 +1941,7 @@ static int em28xx_v4l2_open(struct file *filp) kref_get(&dev->ref); kref_get(&v4l2->ref); - dev->users++; + v4l2->users++; mutex_unlock(&dev->lock); v4l2_fh_add(&fh->fh); @@ -2047,12 +2050,12 @@ static int em28xx_v4l2_close(struct file *filp) struct em28xx_v4l2 *v4l2 = dev->v4l2; int errCode; - em28xx_videodbg("users=%d\n", dev->users); + em28xx_videodbg("users=%d\n", v4l2->users); vb2_fop_release(filp); mutex_lock(&dev->lock); - if (dev->users == 1) { + if (v4l2->users == 1) { /* No sense to try to write to the device */ if (dev->disconnected) goto exit; @@ -2074,8 +2077,8 @@ static int em28xx_v4l2_close(struct file *filp) } exit: + v4l2->users--; kref_put(&v4l2->ref, em28xx_free_v4l2); - dev->users--; mutex_unlock(&dev->lock); kref_put(&dev->ref, em28xx_free_device); diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 7edba65f99c95a29980b493cf67b01e4b5ed155e..998be42c0f70c96bbd040d61bd53016afa5bdfe3 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -524,6 +524,9 @@ struct em28xx_v4l2 { int sensor_yres; int sensor_xtal; + int users; /* user count for exclusive use */ + int streaming_users; /* number of actively streaming users */ + struct em28xx_fmt *format; v4l2_std_id norm; /* selected tv norm */ @@ -642,8 +645,6 @@ struct em28xx { struct rt_mutex i2c_bus_lock; /* video for linux */ - int users; /* user count for exclusive use */ - int streaming_users; /* Number of actively streaming users */ int ctl_freq; /* selected frequency */ unsigned int ctl_input; /* selected input */ unsigned int ctl_ainput;/* selected audio input */