diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-09 12:13:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:17:49 -0400 |
commit | 643800d5c806cf46b0cd184b595a14cce83224e4 (patch) | |
tree | cd108c051fe983f0a6d3a67111abf7cd71679ec0 /drivers/media/video/cx231xx | |
parent | 0f86158375308804f86d36c7d45aaff1d7dc0d96 (diff) |
[media] cx231xx: use core-assisted lock
Instead of doing its own lock, use core-assisted one. As a bonus, it
will do the proper unlock during queue wait events. This fixes a
long-standing bug where softwares like tvtime would hang if you try to
use cx231xx-alsa.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-video.c | 86 |
1 files changed, 8 insertions, 78 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c index 38367ee07cc5..b13b69fb2af6 100644 --- a/drivers/media/video/cx231xx/cx231xx-video.c +++ b/drivers/media/video/cx231xx/cx231xx-video.c | |||
@@ -1019,8 +1019,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
1019 | struct cx231xx_fh *fh = priv; | 1019 | struct cx231xx_fh *fh = priv; |
1020 | struct cx231xx *dev = fh->dev; | 1020 | struct cx231xx *dev = fh->dev; |
1021 | 1021 | ||
1022 | mutex_lock(&dev->lock); | ||
1023 | |||
1024 | f->fmt.pix.width = dev->width; | 1022 | f->fmt.pix.width = dev->width; |
1025 | f->fmt.pix.height = dev->height; | 1023 | f->fmt.pix.height = dev->height; |
1026 | f->fmt.pix.pixelformat = dev->format->fourcc; | 1024 | f->fmt.pix.pixelformat = dev->format->fourcc; |
@@ -1030,8 +1028,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
1030 | 1028 | ||
1031 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | 1029 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; |
1032 | 1030 | ||
1033 | mutex_unlock(&dev->lock); | ||
1034 | |||
1035 | return 0; | 1031 | return 0; |
1036 | } | 1032 | } |
1037 | 1033 | ||
@@ -1092,26 +1088,20 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1092 | if (rc < 0) | 1088 | if (rc < 0) |
1093 | return rc; | 1089 | return rc; |
1094 | 1090 | ||
1095 | mutex_lock(&dev->lock); | ||
1096 | |||
1097 | vidioc_try_fmt_vid_cap(file, priv, f); | 1091 | vidioc_try_fmt_vid_cap(file, priv, f); |
1098 | 1092 | ||
1099 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 1093 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
1100 | if (!fmt) { | 1094 | if (!fmt) |
1101 | rc = -EINVAL; | 1095 | return -EINVAL; |
1102 | goto out; | ||
1103 | } | ||
1104 | 1096 | ||
1105 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | 1097 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { |
1106 | cx231xx_errdev("%s queue busy\n", __func__); | 1098 | cx231xx_errdev("%s queue busy\n", __func__); |
1107 | rc = -EBUSY; | 1099 | return -EBUSY; |
1108 | goto out; | ||
1109 | } | 1100 | } |
1110 | 1101 | ||
1111 | if (dev->stream_on && !fh->stream_on) { | 1102 | if (dev->stream_on && !fh->stream_on) { |
1112 | cx231xx_errdev("%s device in use by another fh\n", __func__); | 1103 | cx231xx_errdev("%s device in use by another fh\n", __func__); |
1113 | rc = -EBUSY; | 1104 | return -EBUSY; |
1114 | goto out; | ||
1115 | } | 1105 | } |
1116 | 1106 | ||
1117 | /* set new image size */ | 1107 | /* set new image size */ |
@@ -1123,8 +1113,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1123 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | 1113 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); |
1124 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | 1114 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); |
1125 | 1115 | ||
1126 | out: | ||
1127 | mutex_unlock(&dev->lock); | ||
1128 | return rc; | 1116 | return rc; |
1129 | } | 1117 | } |
1130 | 1118 | ||
@@ -1151,7 +1139,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
1151 | 1139 | ||
1152 | cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm); | 1140 | cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm); |
1153 | 1141 | ||
1154 | mutex_lock(&dev->lock); | ||
1155 | dev->norm = *norm; | 1142 | dev->norm = *norm; |
1156 | 1143 | ||
1157 | /* Adjusts width/height, if needed */ | 1144 | /* Adjusts width/height, if needed */ |
@@ -1172,8 +1159,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
1172 | dev->width = f.fmt.pix.width; | 1159 | dev->width = f.fmt.pix.width; |
1173 | dev->height = f.fmt.pix.height; | 1160 | dev->height = f.fmt.pix.height; |
1174 | 1161 | ||
1175 | mutex_unlock(&dev->lock); | ||
1176 | |||
1177 | /* do mode control overrides */ | 1162 | /* do mode control overrides */ |
1178 | cx231xx_do_mode_ctrl_overrides(dev); | 1163 | cx231xx_do_mode_ctrl_overrides(dev); |
1179 | 1164 | ||
@@ -1242,8 +1227,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
1242 | if (0 == INPUT(i)->type) | 1227 | if (0 == INPUT(i)->type) |
1243 | return -EINVAL; | 1228 | return -EINVAL; |
1244 | 1229 | ||
1245 | mutex_lock(&dev->lock); | ||
1246 | |||
1247 | video_mux(dev, i); | 1230 | video_mux(dev, i); |
1248 | 1231 | ||
1249 | if (INPUT(i)->type == CX231XX_VMUX_TELEVISION || | 1232 | if (INPUT(i)->type == CX231XX_VMUX_TELEVISION || |
@@ -1254,7 +1237,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
1254 | call_all(dev, core, s_std, dev->norm); | 1237 | call_all(dev, core, s_std, dev->norm); |
1255 | } | 1238 | } |
1256 | 1239 | ||
1257 | mutex_unlock(&dev->lock); | ||
1258 | return 0; | 1240 | return 0; |
1259 | } | 1241 | } |
1260 | 1242 | ||
@@ -1330,9 +1312,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
1330 | } | 1312 | } |
1331 | *qc = cx231xx_ctls[i].v; | 1313 | *qc = cx231xx_ctls[i].v; |
1332 | 1314 | ||
1333 | mutex_lock(&dev->lock); | ||
1334 | call_all(dev, core, queryctrl, qc); | 1315 | call_all(dev, core, queryctrl, qc); |
1335 | mutex_unlock(&dev->lock); | ||
1336 | 1316 | ||
1337 | if (qc->type) | 1317 | if (qc->type) |
1338 | return 0; | 1318 | return 0; |
@@ -1351,9 +1331,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
1351 | if (rc < 0) | 1331 | if (rc < 0) |
1352 | return rc; | 1332 | return rc; |
1353 | 1333 | ||
1354 | mutex_lock(&dev->lock); | ||
1355 | call_all(dev, core, g_ctrl, ctrl); | 1334 | call_all(dev, core, g_ctrl, ctrl); |
1356 | mutex_unlock(&dev->lock); | ||
1357 | return rc; | 1335 | return rc; |
1358 | } | 1336 | } |
1359 | 1337 | ||
@@ -1368,9 +1346,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1368 | if (rc < 0) | 1346 | if (rc < 0) |
1369 | return rc; | 1347 | return rc; |
1370 | 1348 | ||
1371 | mutex_lock(&dev->lock); | ||
1372 | call_all(dev, core, s_ctrl, ctrl); | 1349 | call_all(dev, core, s_ctrl, ctrl); |
1373 | mutex_unlock(&dev->lock); | ||
1374 | return rc; | 1350 | return rc; |
1375 | } | 1351 | } |
1376 | 1352 | ||
@@ -1410,9 +1386,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
1410 | if (0 != t->index) | 1386 | if (0 != t->index) |
1411 | return -EINVAL; | 1387 | return -EINVAL; |
1412 | #if 0 | 1388 | #if 0 |
1413 | mutex_lock(&dev->lock); | ||
1414 | call_all(dev, tuner, s_tuner, t); | 1389 | call_all(dev, tuner, s_tuner, t); |
1415 | mutex_unlock(&dev->lock); | ||
1416 | #endif | 1390 | #endif |
1417 | return 0; | 1391 | return 0; |
1418 | } | 1392 | } |
@@ -1423,14 +1397,11 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
1423 | struct cx231xx_fh *fh = priv; | 1397 | struct cx231xx_fh *fh = priv; |
1424 | struct cx231xx *dev = fh->dev; | 1398 | struct cx231xx *dev = fh->dev; |
1425 | 1399 | ||
1426 | mutex_lock(&dev->lock); | ||
1427 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1400 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1428 | f->frequency = dev->ctl_freq; | 1401 | f->frequency = dev->ctl_freq; |
1429 | 1402 | ||
1430 | call_all(dev, tuner, g_frequency, f); | 1403 | call_all(dev, tuner, g_frequency, f); |
1431 | 1404 | ||
1432 | mutex_unlock(&dev->lock); | ||
1433 | |||
1434 | return 0; | 1405 | return 0; |
1435 | } | 1406 | } |
1436 | 1407 | ||
@@ -1461,13 +1432,9 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1461 | /* set pre channel change settings in DIF first */ | 1432 | /* set pre channel change settings in DIF first */ |
1462 | rc = cx231xx_tuner_pre_channel_change(dev); | 1433 | rc = cx231xx_tuner_pre_channel_change(dev); |
1463 | 1434 | ||
1464 | mutex_lock(&dev->lock); | ||
1465 | |||
1466 | dev->ctl_freq = f->frequency; | 1435 | dev->ctl_freq = f->frequency; |
1467 | call_all(dev, tuner, s_frequency, f); | 1436 | call_all(dev, tuner, s_frequency, f); |
1468 | 1437 | ||
1469 | mutex_unlock(&dev->lock); | ||
1470 | |||
1471 | /* set post channel change settings in DIF first */ | 1438 | /* set post channel change settings in DIF first */ |
1472 | rc = cx231xx_tuner_post_channel_change(dev); | 1439 | rc = cx231xx_tuner_post_channel_change(dev); |
1473 | 1440 | ||
@@ -1655,9 +1622,7 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1655 | return -EINVAL; | 1622 | return -EINVAL; |
1656 | } | 1623 | } |
1657 | 1624 | ||
1658 | mutex_lock(&dev->lock); | ||
1659 | call_all(dev, core, g_register, reg); | 1625 | call_all(dev, core, g_register, reg); |
1660 | mutex_unlock(&dev->lock); | ||
1661 | 1626 | ||
1662 | return ret; | 1627 | return ret; |
1663 | } | 1628 | } |
@@ -1822,9 +1787,7 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1822 | break; | 1787 | break; |
1823 | } | 1788 | } |
1824 | 1789 | ||
1825 | mutex_lock(&dev->lock); | ||
1826 | call_all(dev, core, s_register, reg); | 1790 | call_all(dev, core, s_register, reg); |
1827 | mutex_unlock(&dev->lock); | ||
1828 | 1791 | ||
1829 | return ret; | 1792 | return ret; |
1830 | } | 1793 | } |
@@ -1861,7 +1824,6 @@ static int vidioc_streamon(struct file *file, void *priv, | |||
1861 | if (rc < 0) | 1824 | if (rc < 0) |
1862 | return rc; | 1825 | return rc; |
1863 | 1826 | ||
1864 | mutex_lock(&dev->lock); | ||
1865 | rc = res_get(fh); | 1827 | rc = res_get(fh); |
1866 | 1828 | ||
1867 | if (likely(rc >= 0)) | 1829 | if (likely(rc >= 0)) |
@@ -1869,8 +1831,6 @@ static int vidioc_streamon(struct file *file, void *priv, | |||
1869 | 1831 | ||
1870 | call_all(dev, video, s_stream, 1); | 1832 | call_all(dev, video, s_stream, 1); |
1871 | 1833 | ||
1872 | mutex_unlock(&dev->lock); | ||
1873 | |||
1874 | return rc; | 1834 | return rc; |
1875 | } | 1835 | } |
1876 | 1836 | ||
@@ -1891,15 +1851,11 @@ static int vidioc_streamoff(struct file *file, void *priv, | |||
1891 | if (type != fh->type) | 1851 | if (type != fh->type) |
1892 | return -EINVAL; | 1852 | return -EINVAL; |
1893 | 1853 | ||
1894 | mutex_lock(&dev->lock); | ||
1895 | |||
1896 | cx25840_call(dev, video, s_stream, 0); | 1854 | cx25840_call(dev, video, s_stream, 0); |
1897 | 1855 | ||
1898 | videobuf_streamoff(&fh->vb_vidq); | 1856 | videobuf_streamoff(&fh->vb_vidq); |
1899 | res_free(fh); | 1857 | res_free(fh); |
1900 | 1858 | ||
1901 | mutex_unlock(&dev->lock); | ||
1902 | |||
1903 | return 0; | 1859 | return 0; |
1904 | } | 1860 | } |
1905 | 1861 | ||
@@ -1954,8 +1910,6 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | |||
1954 | if (rc < 0) | 1910 | if (rc < 0) |
1955 | return rc; | 1911 | return rc; |
1956 | 1912 | ||
1957 | mutex_lock(&dev->lock); | ||
1958 | |||
1959 | f->fmt.sliced.service_set = 0; | 1913 | f->fmt.sliced.service_set = 0; |
1960 | 1914 | ||
1961 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); | 1915 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); |
@@ -1963,7 +1917,6 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | |||
1963 | if (f->fmt.sliced.service_set == 0) | 1917 | if (f->fmt.sliced.service_set == 0) |
1964 | rc = -EINVAL; | 1918 | rc = -EINVAL; |
1965 | 1919 | ||
1966 | mutex_unlock(&dev->lock); | ||
1967 | return rc; | 1920 | return rc; |
1968 | } | 1921 | } |
1969 | 1922 | ||
@@ -1978,9 +1931,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, | |||
1978 | if (rc < 0) | 1931 | if (rc < 0) |
1979 | return rc; | 1932 | return rc; |
1980 | 1933 | ||
1981 | mutex_lock(&dev->lock); | ||
1982 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); | 1934 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); |
1983 | mutex_unlock(&dev->lock); | ||
1984 | 1935 | ||
1985 | if (f->fmt.sliced.service_set == 0) | 1936 | if (f->fmt.sliced.service_set == 0) |
1986 | return -EINVAL; | 1937 | return -EINVAL; |
@@ -2130,9 +2081,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
2130 | strcpy(t->name, "Radio"); | 2081 | strcpy(t->name, "Radio"); |
2131 | t->type = V4L2_TUNER_RADIO; | 2082 | t->type = V4L2_TUNER_RADIO; |
2132 | 2083 | ||
2133 | mutex_lock(&dev->lock); | ||
2134 | call_all(dev, tuner, s_tuner, t); | 2084 | call_all(dev, tuner, s_tuner, t); |
2135 | mutex_unlock(&dev->lock); | ||
2136 | 2085 | ||
2137 | return 0; | 2086 | return 0; |
2138 | } | 2087 | } |
@@ -2163,9 +2112,7 @@ static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
2163 | if (0 != t->index) | 2112 | if (0 != t->index) |
2164 | return -EINVAL; | 2113 | return -EINVAL; |
2165 | 2114 | ||
2166 | mutex_lock(&dev->lock); | ||
2167 | call_all(dev, tuner, s_tuner, t); | 2115 | call_all(dev, tuner, s_tuner, t); |
2168 | mutex_unlock(&dev->lock); | ||
2169 | 2116 | ||
2170 | return 0; | 2117 | return 0; |
2171 | } | 2118 | } |
@@ -2224,8 +2171,6 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
2224 | break; | 2171 | break; |
2225 | } | 2172 | } |
2226 | 2173 | ||
2227 | mutex_lock(&dev->lock); | ||
2228 | |||
2229 | cx231xx_videodbg("open dev=%s type=%s users=%d\n", | 2174 | cx231xx_videodbg("open dev=%s type=%s users=%d\n", |
2230 | video_device_node_name(vdev), v4l2_type_names[fh_type], | 2175 | video_device_node_name(vdev), v4l2_type_names[fh_type], |
2231 | dev->users); | 2176 | dev->users); |
@@ -2235,7 +2180,6 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
2235 | if (errCode < 0) { | 2180 | if (errCode < 0) { |
2236 | cx231xx_errdev | 2181 | cx231xx_errdev |
2237 | ("Device locked on digital mode. Can't open analog\n"); | 2182 | ("Device locked on digital mode. Can't open analog\n"); |
2238 | mutex_unlock(&dev->lock); | ||
2239 | return -EBUSY; | 2183 | return -EBUSY; |
2240 | } | 2184 | } |
2241 | #endif | 2185 | #endif |
@@ -2243,7 +2187,6 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
2243 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); | 2187 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); |
2244 | if (!fh) { | 2188 | if (!fh) { |
2245 | cx231xx_errdev("cx231xx-video.c: Out of memory?!\n"); | 2189 | cx231xx_errdev("cx231xx-video.c: Out of memory?!\n"); |
2246 | mutex_unlock(&dev->lock); | ||
2247 | return -ENOMEM; | 2190 | return -ENOMEM; |
2248 | } | 2191 | } |
2249 | fh->dev = dev; | 2192 | fh->dev = dev; |
@@ -2293,7 +2236,7 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
2293 | NULL, &dev->video_mode.slock, | 2236 | NULL, &dev->video_mode.slock, |
2294 | fh->type, V4L2_FIELD_INTERLACED, | 2237 | fh->type, V4L2_FIELD_INTERLACED, |
2295 | sizeof(struct cx231xx_buffer), | 2238 | sizeof(struct cx231xx_buffer), |
2296 | fh, NULL); | 2239 | fh, &dev->lock); |
2297 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | 2240 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { |
2298 | /* Set the required alternate setting VBI interface works in | 2241 | /* Set the required alternate setting VBI interface works in |
2299 | Bulk mode only */ | 2242 | Bulk mode only */ |
@@ -2305,11 +2248,9 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
2305 | NULL, &dev->vbi_mode.slock, | 2248 | NULL, &dev->vbi_mode.slock, |
2306 | fh->type, V4L2_FIELD_SEQ_TB, | 2249 | fh->type, V4L2_FIELD_SEQ_TB, |
2307 | sizeof(struct cx231xx_buffer), | 2250 | sizeof(struct cx231xx_buffer), |
2308 | fh, NULL); | 2251 | fh, &dev->lock); |
2309 | } | 2252 | } |
2310 | 2253 | ||
2311 | mutex_unlock(&dev->lock); | ||
2312 | |||
2313 | return errCode; | 2254 | return errCode; |
2314 | } | 2255 | } |
2315 | 2256 | ||
@@ -2366,7 +2307,6 @@ static int cx231xx_v4l2_close(struct file *filp) | |||
2366 | 2307 | ||
2367 | cx231xx_videodbg("users=%d\n", dev->users); | 2308 | cx231xx_videodbg("users=%d\n", dev->users); |
2368 | 2309 | ||
2369 | mutex_lock(&dev->lock); | ||
2370 | cx231xx_videodbg("users=%d\n", dev->users); | 2310 | cx231xx_videodbg("users=%d\n", dev->users); |
2371 | if (res_check(fh)) | 2311 | if (res_check(fh)) |
2372 | res_free(fh); | 2312 | res_free(fh); |
@@ -2384,12 +2324,10 @@ static int cx231xx_v4l2_close(struct file *filp) | |||
2384 | if (dev->state & DEV_DISCONNECTED) { | 2324 | if (dev->state & DEV_DISCONNECTED) { |
2385 | if (atomic_read(&dev->devlist_count) > 0) { | 2325 | if (atomic_read(&dev->devlist_count) > 0) { |
2386 | cx231xx_release_resources(dev); | 2326 | cx231xx_release_resources(dev); |
2387 | mutex_unlock(&dev->lock); | ||
2388 | kfree(dev); | 2327 | kfree(dev); |
2389 | dev = NULL; | 2328 | dev = NULL; |
2390 | return 0; | 2329 | return 0; |
2391 | } | 2330 | } |
2392 | mutex_unlock(&dev->lock); | ||
2393 | return 0; | 2331 | return 0; |
2394 | } | 2332 | } |
2395 | 2333 | ||
@@ -2405,7 +2343,6 @@ static int cx231xx_v4l2_close(struct file *filp) | |||
2405 | kfree(fh); | 2343 | kfree(fh); |
2406 | dev->users--; | 2344 | dev->users--; |
2407 | wake_up_interruptible_nr(&dev->open, 1); | 2345 | wake_up_interruptible_nr(&dev->open, 1); |
2408 | mutex_unlock(&dev->lock); | ||
2409 | return 0; | 2346 | return 0; |
2410 | } | 2347 | } |
2411 | 2348 | ||
@@ -2417,7 +2354,6 @@ static int cx231xx_v4l2_close(struct file *filp) | |||
2417 | free the remaining resources */ | 2354 | free the remaining resources */ |
2418 | if (dev->state & DEV_DISCONNECTED) { | 2355 | if (dev->state & DEV_DISCONNECTED) { |
2419 | cx231xx_release_resources(dev); | 2356 | cx231xx_release_resources(dev); |
2420 | mutex_unlock(&dev->lock); | ||
2421 | kfree(dev); | 2357 | kfree(dev); |
2422 | dev = NULL; | 2358 | dev = NULL; |
2423 | return 0; | 2359 | return 0; |
@@ -2439,7 +2375,6 @@ static int cx231xx_v4l2_close(struct file *filp) | |||
2439 | kfree(fh); | 2375 | kfree(fh); |
2440 | dev->users--; | 2376 | dev->users--; |
2441 | wake_up_interruptible_nr(&dev->open, 1); | 2377 | wake_up_interruptible_nr(&dev->open, 1); |
2442 | mutex_unlock(&dev->lock); | ||
2443 | return 0; | 2378 | return 0; |
2444 | } | 2379 | } |
2445 | 2380 | ||
@@ -2461,9 +2396,7 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, | |||
2461 | 2396 | ||
2462 | if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) || | 2397 | if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) || |
2463 | (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) { | 2398 | (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) { |
2464 | mutex_lock(&dev->lock); | ||
2465 | rc = res_get(fh); | 2399 | rc = res_get(fh); |
2466 | mutex_unlock(&dev->lock); | ||
2467 | 2400 | ||
2468 | if (unlikely(rc < 0)) | 2401 | if (unlikely(rc < 0)) |
2469 | return rc; | 2402 | return rc; |
@@ -2488,9 +2421,7 @@ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table *wait) | |||
2488 | if (rc < 0) | 2421 | if (rc < 0) |
2489 | return rc; | 2422 | return rc; |
2490 | 2423 | ||
2491 | mutex_lock(&dev->lock); | ||
2492 | rc = res_get(fh); | 2424 | rc = res_get(fh); |
2493 | mutex_unlock(&dev->lock); | ||
2494 | 2425 | ||
2495 | if (unlikely(rc < 0)) | 2426 | if (unlikely(rc < 0)) |
2496 | return POLLERR; | 2427 | return POLLERR; |
@@ -2515,9 +2446,7 @@ static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
2515 | if (rc < 0) | 2446 | if (rc < 0) |
2516 | return rc; | 2447 | return rc; |
2517 | 2448 | ||
2518 | mutex_lock(&dev->lock); | ||
2519 | rc = res_get(fh); | 2449 | rc = res_get(fh); |
2520 | mutex_unlock(&dev->lock); | ||
2521 | 2450 | ||
2522 | if (unlikely(rc < 0)) | 2451 | if (unlikely(rc < 0)) |
2523 | return rc; | 2452 | return rc; |
@@ -2539,7 +2468,7 @@ static const struct v4l2_file_operations cx231xx_v4l_fops = { | |||
2539 | .read = cx231xx_v4l2_read, | 2468 | .read = cx231xx_v4l2_read, |
2540 | .poll = cx231xx_v4l2_poll, | 2469 | .poll = cx231xx_v4l2_poll, |
2541 | .mmap = cx231xx_v4l2_mmap, | 2470 | .mmap = cx231xx_v4l2_mmap, |
2542 | .ioctl = video_ioctl2, | 2471 | .unlocked_ioctl = video_ioctl2, |
2543 | }; | 2472 | }; |
2544 | 2473 | ||
2545 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 2474 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -2641,6 +2570,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, | |||
2641 | vfd->v4l2_dev = &dev->v4l2_dev; | 2570 | vfd->v4l2_dev = &dev->v4l2_dev; |
2642 | vfd->release = video_device_release; | 2571 | vfd->release = video_device_release; |
2643 | vfd->debug = video_debug; | 2572 | vfd->debug = video_debug; |
2573 | vfd->lock = &dev->lock; | ||
2644 | 2574 | ||
2645 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); | 2575 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); |
2646 | 2576 | ||