diff options
author | Frank Schaefer <fschaefer.oss@googlemail.com> | 2014-09-18 16:55:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-09-21 20:27:57 -0400 |
commit | 8e2c8717c1812628b5538c05250057b37c66fdbe (patch) | |
tree | 366dea5547845a47d346cde54ca933c1343936b7 /drivers/media/usb/em28xx | |
parent | c7854c2c5d692a329b4d9a9a73bcf36ae137ee7c (diff) |
[media] em28xx-v4l: get rid of field "users" in struct em28xx_v4l2"
This reverts commit 747dba7de2a51a3db58b665ed3bc8c07921546ec.
It breaks concurrent vbi and video capturing:
While v4l2->users is the number of users of the whole device (all device nodes),
v4l2_fh_is_singular() only checks the number of users of a specific device node.
As a result. if one device node is open and a second device node is opened
(closed), the device is reinitialized (streaming is stopped).
Reported-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb/em28xx')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 23 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx.h | 1 |
2 files changed, 11 insertions, 13 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 41339259f30c..29abc379551e 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -1883,8 +1883,9 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1883 | return -EINVAL; | 1883 | return -EINVAL; |
1884 | } | 1884 | } |
1885 | 1885 | ||
1886 | em28xx_videodbg("open dev=%s type=%s\n", | 1886 | em28xx_videodbg("open dev=%s type=%s users=%d\n", |
1887 | video_device_node_name(vdev), v4l2_type_names[fh_type]); | 1887 | video_device_node_name(vdev), v4l2_type_names[fh_type], |
1888 | v4l2->users); | ||
1888 | 1889 | ||
1889 | if (mutex_lock_interruptible(&dev->lock)) | 1890 | if (mutex_lock_interruptible(&dev->lock)) |
1890 | return -ERESTARTSYS; | 1891 | return -ERESTARTSYS; |
@@ -1897,9 +1898,7 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1897 | return ret; | 1898 | return ret; |
1898 | } | 1899 | } |
1899 | 1900 | ||
1900 | if (v4l2_fh_is_singular_file(filp)) { | 1901 | if (v4l2->users == 0) { |
1901 | em28xx_videodbg("first opened filehandle, initializing device\n"); | ||
1902 | |||
1903 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); | 1902 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); |
1904 | 1903 | ||
1905 | if (vdev->vfl_type != VFL_TYPE_RADIO) | 1904 | if (vdev->vfl_type != VFL_TYPE_RADIO) |
@@ -1910,8 +1909,6 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1910 | * of some i2c devices | 1909 | * of some i2c devices |
1911 | */ | 1910 | */ |
1912 | em28xx_wake_i2c(dev); | 1911 | em28xx_wake_i2c(dev); |
1913 | } else { | ||
1914 | em28xx_videodbg("further filehandles are already opened\n"); | ||
1915 | } | 1912 | } |
1916 | 1913 | ||
1917 | if (vdev->vfl_type == VFL_TYPE_RADIO) { | 1914 | if (vdev->vfl_type == VFL_TYPE_RADIO) { |
@@ -1921,6 +1918,7 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1921 | 1918 | ||
1922 | kref_get(&dev->ref); | 1919 | kref_get(&dev->ref); |
1923 | kref_get(&v4l2->ref); | 1920 | kref_get(&v4l2->ref); |
1921 | v4l2->users++; | ||
1924 | 1922 | ||
1925 | mutex_unlock(&dev->lock); | 1923 | mutex_unlock(&dev->lock); |
1926 | 1924 | ||
@@ -2027,11 +2025,12 @@ static int em28xx_v4l2_close(struct file *filp) | |||
2027 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 2025 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
2028 | int errCode; | 2026 | int errCode; |
2029 | 2027 | ||
2030 | mutex_lock(&dev->lock); | 2028 | em28xx_videodbg("users=%d\n", v4l2->users); |
2031 | 2029 | ||
2032 | if (v4l2_fh_is_singular_file(filp)) { | 2030 | vb2_fop_release(filp); |
2033 | em28xx_videodbg("last opened filehandle, shutting down device\n"); | 2031 | mutex_lock(&dev->lock); |
2034 | 2032 | ||
2033 | if (v4l2->users == 1) { | ||
2035 | /* No sense to try to write to the device */ | 2034 | /* No sense to try to write to the device */ |
2036 | if (dev->disconnected) | 2035 | if (dev->disconnected) |
2037 | goto exit; | 2036 | goto exit; |
@@ -2050,12 +2049,10 @@ static int em28xx_v4l2_close(struct file *filp) | |||
2050 | em28xx_errdev("cannot change alternate number to " | 2049 | em28xx_errdev("cannot change alternate number to " |
2051 | "0 (error=%i)\n", errCode); | 2050 | "0 (error=%i)\n", errCode); |
2052 | } | 2051 | } |
2053 | } else { | ||
2054 | em28xx_videodbg("further opened filehandles left\n"); | ||
2055 | } | 2052 | } |
2056 | 2053 | ||
2057 | exit: | 2054 | exit: |
2058 | vb2_fop_release(filp); | 2055 | v4l2->users--; |
2059 | kref_put(&v4l2->ref, em28xx_free_v4l2); | 2056 | kref_put(&v4l2->ref, em28xx_free_v4l2); |
2060 | mutex_unlock(&dev->lock); | 2057 | mutex_unlock(&dev->lock); |
2061 | kref_put(&dev->ref, em28xx_free_device); | 2058 | kref_put(&dev->ref, em28xx_free_device); |
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 84ef8efdb148..4360338e7b31 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -524,6 +524,7 @@ 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 */ | ||
527 | int streaming_users; /* number of actively streaming users */ | 528 | int streaming_users; /* number of actively streaming users */ |
528 | 529 | ||
529 | u32 frequency; /* selected tuner frequency */ | 530 | u32 frequency; /* selected tuner frequency */ |