aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-05-11 16:59:04 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-23 12:37:49 -0400
commit8139a4d583abad45eb987b5a99b3281b6d435b7e (patch)
treeda71de3861b282e96ffd6cc5960451a69d09b391 /drivers/media/usb
parentf0e38230b3b1e564841a52e2de17e063f5df19ea (diff)
[media] em28xx: move v4l2 user counting fields from struct em28xx to struct v4l2
Despite being at the common em28xx struct, those two fields are actually taking into account only the usage inside em28xx v4l2 submodule. So, move them out of the common struct. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c27
-rw-r--r--drivers/media/usb/em28xx/em28xx.h5
2 files changed, 18 insertions, 14 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 7b332bf70ec0..110673a4db10 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)
934 if (rc) 934 if (rc)
935 return rc; 935 return rc;
936 936
937 if (dev->streaming_users == 0) { 937 if (v4l2->streaming_users == 0) {
938 /* First active streaming user, so allocate all the URBs */ 938 /* First active streaming user, so allocate all the URBs */
939 939
940 /* Allocate the USB bandwidth */ 940 /* Allocate the USB bandwidth */
@@ -972,7 +972,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
972 0, tuner, s_frequency, &f); 972 0, tuner, s_frequency, &f);
973 } 973 }
974 974
975 dev->streaming_users++; 975 v4l2->streaming_users++;
976 976
977 return rc; 977 return rc;
978} 978}
@@ -980,6 +980,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
980static void em28xx_stop_streaming(struct vb2_queue *vq) 980static void em28xx_stop_streaming(struct vb2_queue *vq)
981{ 981{
982 struct em28xx *dev = vb2_get_drv_priv(vq); 982 struct em28xx *dev = vb2_get_drv_priv(vq);
983 struct em28xx_v4l2 *v4l2 = dev->v4l2;
983 struct em28xx_dmaqueue *vidq = &dev->vidq; 984 struct em28xx_dmaqueue *vidq = &dev->vidq;
984 unsigned long flags = 0; 985 unsigned long flags = 0;
985 986
@@ -987,7 +988,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq)
987 988
988 res_free(dev, vq->type); 989 res_free(dev, vq->type);
989 990
990 if (dev->streaming_users-- == 1) { 991 if (v4l2->streaming_users-- == 1) {
991 /* Last active user, so shutdown all the URBS */ 992 /* Last active user, so shutdown all the URBS */
992 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); 993 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
993 } 994 }
@@ -1006,6 +1007,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq)
1006void em28xx_stop_vbi_streaming(struct vb2_queue *vq) 1007void em28xx_stop_vbi_streaming(struct vb2_queue *vq)
1007{ 1008{
1008 struct em28xx *dev = vb2_get_drv_priv(vq); 1009 struct em28xx *dev = vb2_get_drv_priv(vq);
1010 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1009 struct em28xx_dmaqueue *vbiq = &dev->vbiq; 1011 struct em28xx_dmaqueue *vbiq = &dev->vbiq;
1010 unsigned long flags = 0; 1012 unsigned long flags = 0;
1011 1013
@@ -1013,7 +1015,7 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq)
1013 1015
1014 res_free(dev, vq->type); 1016 res_free(dev, vq->type);
1015 1017
1016 if (dev->streaming_users-- == 1) { 1018 if (v4l2->streaming_users-- == 1) {
1017 /* Last active user, so shutdown all the URBS */ 1019 /* Last active user, so shutdown all the URBS */
1018 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); 1020 em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
1019 } 1021 }
@@ -1340,8 +1342,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1340 struct v4l2_format *f) 1342 struct v4l2_format *f)
1341{ 1343{
1342 struct em28xx *dev = video_drvdata(file); 1344 struct em28xx *dev = video_drvdata(file);
1345 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1343 1346
1344 if (dev->streaming_users > 0) 1347 if (v4l2->streaming_users > 0)
1345 return -EBUSY; 1348 return -EBUSY;
1346 1349
1347 vidioc_try_fmt_vid_cap(file, priv, f); 1350 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)
1380 if (norm == v4l2->norm) 1383 if (norm == v4l2->norm)
1381 return 0; 1384 return 0;
1382 1385
1383 if (dev->streaming_users > 0) 1386 if (v4l2->streaming_users > 0)
1384 return -EBUSY; 1387 return -EBUSY;
1385 1388
1386 v4l2->norm = norm; 1389 v4l2->norm = norm;
@@ -1903,7 +1906,7 @@ static int em28xx_v4l2_open(struct file *filp)
1903 1906
1904 em28xx_videodbg("open dev=%s type=%s users=%d\n", 1907 em28xx_videodbg("open dev=%s type=%s users=%d\n",
1905 video_device_node_name(vdev), v4l2_type_names[fh_type], 1908 video_device_node_name(vdev), v4l2_type_names[fh_type],
1906 dev->users); 1909 v4l2->users);
1907 1910
1908 if (mutex_lock_interruptible(&dev->lock)) 1911 if (mutex_lock_interruptible(&dev->lock))
1909 return -ERESTARTSYS; 1912 return -ERESTARTSYS;
@@ -1918,7 +1921,7 @@ static int em28xx_v4l2_open(struct file *filp)
1918 fh->type = fh_type; 1921 fh->type = fh_type;
1919 filp->private_data = fh; 1922 filp->private_data = fh;
1920 1923
1921 if (dev->users == 0) { 1924 if (v4l2->users == 0) {
1922 em28xx_set_mode(dev, EM28XX_ANALOG_MODE); 1925 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
1923 1926
1924 if (vdev->vfl_type != VFL_TYPE_RADIO) 1927 if (vdev->vfl_type != VFL_TYPE_RADIO)
@@ -1938,7 +1941,7 @@ static int em28xx_v4l2_open(struct file *filp)
1938 1941
1939 kref_get(&dev->ref); 1942 kref_get(&dev->ref);
1940 kref_get(&v4l2->ref); 1943 kref_get(&v4l2->ref);
1941 dev->users++; 1944 v4l2->users++;
1942 1945
1943 mutex_unlock(&dev->lock); 1946 mutex_unlock(&dev->lock);
1944 v4l2_fh_add(&fh->fh); 1947 v4l2_fh_add(&fh->fh);
@@ -2047,12 +2050,12 @@ static int em28xx_v4l2_close(struct file *filp)
2047 struct em28xx_v4l2 *v4l2 = dev->v4l2; 2050 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2048 int errCode; 2051 int errCode;
2049 2052
2050 em28xx_videodbg("users=%d\n", dev->users); 2053 em28xx_videodbg("users=%d\n", v4l2->users);
2051 2054
2052 vb2_fop_release(filp); 2055 vb2_fop_release(filp);
2053 mutex_lock(&dev->lock); 2056 mutex_lock(&dev->lock);
2054 2057
2055 if (dev->users == 1) { 2058 if (v4l2->users == 1) {
2056 /* No sense to try to write to the device */ 2059 /* No sense to try to write to the device */
2057 if (dev->disconnected) 2060 if (dev->disconnected)
2058 goto exit; 2061 goto exit;
@@ -2074,8 +2077,8 @@ static int em28xx_v4l2_close(struct file *filp)
2074 } 2077 }
2075 2078
2076exit: 2079exit:
2080 v4l2->users--;
2077 kref_put(&v4l2->ref, em28xx_free_v4l2); 2081 kref_put(&v4l2->ref, em28xx_free_v4l2);
2078 dev->users--;
2079 mutex_unlock(&dev->lock); 2082 mutex_unlock(&dev->lock);
2080 kref_put(&dev->ref, em28xx_free_device); 2083 kref_put(&dev->ref, em28xx_free_device);
2081 2084
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 7edba65f99c9..998be42c0f70 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -524,6 +524,9 @@ struct em28xx_v4l2 {
524 int sensor_yres; 524 int sensor_yres;
525 int sensor_xtal; 525 int sensor_xtal;
526 526
527 int users; /* user count for exclusive use */
528 int streaming_users; /* number of actively streaming users */
529
527 struct em28xx_fmt *format; 530 struct em28xx_fmt *format;
528 v4l2_std_id norm; /* selected tv norm */ 531 v4l2_std_id norm; /* selected tv norm */
529 532
@@ -642,8 +645,6 @@ struct em28xx {
642 struct rt_mutex i2c_bus_lock; 645 struct rt_mutex i2c_bus_lock;
643 646
644 /* video for linux */ 647 /* video for linux */
645 int users; /* user count for exclusive use */
646 int streaming_users; /* Number of actively streaming users */
647 int ctl_freq; /* selected frequency */ 648 int ctl_freq; /* selected frequency */
648 unsigned int ctl_input; /* selected input */ 649 unsigned int ctl_input; /* selected input */
649 unsigned int ctl_ainput;/* selected audio input */ 650 unsigned int ctl_ainput;/* selected audio input */