diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-08-09 10:29:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-09-03 06:47:21 -0400 |
commit | 24a8f7b5648ff8dfd8d26f8444ab4b04286dba98 (patch) | |
tree | 75e0081767f1d3a6e1c0b342ea8b3e0d152aa76d /drivers/media/pci | |
parent | 86dd9831aea494e3e5c565c697df60484f55780c (diff) |
[media] cx23885: use core locking, switch to unlocked_ioctl
Enable core locking which allows us to safely switch to unlocked_ioctl.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-417.c | 5 | ||||
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-video.c | 43 |
2 files changed, 12 insertions, 36 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index b65de33a6e23..395f7a987d61 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c | |||
@@ -1235,9 +1235,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) | |||
1235 | dev->encodernorm = cx23885_tvnorms[i]; | 1235 | dev->encodernorm = cx23885_tvnorms[i]; |
1236 | 1236 | ||
1237 | /* Have the drier core notify the subdevices */ | 1237 | /* Have the drier core notify the subdevices */ |
1238 | mutex_lock(&dev->lock); | ||
1239 | cx23885_set_tvnorm(dev, id); | 1238 | cx23885_set_tvnorm(dev, id); |
1240 | mutex_unlock(&dev->lock); | ||
1241 | 1239 | ||
1242 | return 0; | 1240 | return 0; |
1243 | } | 1241 | } |
@@ -1661,7 +1659,7 @@ static struct v4l2_file_operations mpeg_fops = { | |||
1661 | .read = mpeg_read, | 1659 | .read = mpeg_read, |
1662 | .poll = mpeg_poll, | 1660 | .poll = mpeg_poll, |
1663 | .mmap = mpeg_mmap, | 1661 | .mmap = mpeg_mmap, |
1664 | .ioctl = video_ioctl2, | 1662 | .unlocked_ioctl = video_ioctl2, |
1665 | }; | 1663 | }; |
1666 | 1664 | ||
1667 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | 1665 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { |
@@ -1770,6 +1768,7 @@ int cx23885_417_register(struct cx23885_dev *dev) | |||
1770 | dev->v4l_device = cx23885_video_dev_alloc(tsport, | 1768 | dev->v4l_device = cx23885_video_dev_alloc(tsport, |
1771 | dev->pci, &cx23885_mpeg_template, "mpeg"); | 1769 | dev->pci, &cx23885_mpeg_template, "mpeg"); |
1772 | video_set_drvdata(dev->v4l_device, dev); | 1770 | video_set_drvdata(dev->v4l_device, dev); |
1771 | dev->v4l_device->lock = &dev->lock; | ||
1773 | err = video_register_device(dev->v4l_device, | 1772 | err = video_register_device(dev->v4l_device, |
1774 | VFL_TYPE_GRABBER, -1); | 1773 | VFL_TYPE_GRABBER, -1); |
1775 | if (err < 0) { | 1774 | if (err < 0) { |
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index d575bfc8ac41..ba93e29bf158 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c | |||
@@ -345,6 +345,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, | |||
345 | *vfd = *template; | 345 | *vfd = *template; |
346 | vfd->v4l2_dev = &dev->v4l2_dev; | 346 | vfd->v4l2_dev = &dev->v4l2_dev; |
347 | vfd->release = video_device_release; | 347 | vfd->release = video_device_release; |
348 | vfd->lock = &dev->lock; | ||
348 | snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", | 349 | snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", |
349 | cx23885_boards[dev->board].name, type); | 350 | cx23885_boards[dev->board].name, type); |
350 | video_set_drvdata(vfd, dev); | 351 | video_set_drvdata(vfd, dev); |
@@ -381,17 +382,14 @@ static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, | |||
381 | return 1; | 382 | return 1; |
382 | 383 | ||
383 | /* is it free? */ | 384 | /* is it free? */ |
384 | mutex_lock(&dev->lock); | ||
385 | if (dev->resources & bit) { | 385 | if (dev->resources & bit) { |
386 | /* no, someone else uses it */ | 386 | /* no, someone else uses it */ |
387 | mutex_unlock(&dev->lock); | ||
388 | return 0; | 387 | return 0; |
389 | } | 388 | } |
390 | /* it's free, grab it */ | 389 | /* it's free, grab it */ |
391 | fh->resources |= bit; | 390 | fh->resources |= bit; |
392 | dev->resources |= bit; | 391 | dev->resources |= bit; |
393 | dprintk(1, "res: get %d\n", bit); | 392 | dprintk(1, "res: get %d\n", bit); |
394 | mutex_unlock(&dev->lock); | ||
395 | return 1; | 393 | return 1; |
396 | } | 394 | } |
397 | 395 | ||
@@ -411,11 +409,9 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, | |||
411 | BUG_ON((fh->resources & bits) != bits); | 409 | BUG_ON((fh->resources & bits) != bits); |
412 | dprintk(1, "%s()\n", __func__); | 410 | dprintk(1, "%s()\n", __func__); |
413 | 411 | ||
414 | mutex_lock(&dev->lock); | ||
415 | fh->resources &= ~bits; | 412 | fh->resources &= ~bits; |
416 | dev->resources &= ~bits; | 413 | dev->resources &= ~bits; |
417 | dprintk(1, "res: put %d\n", bits); | 414 | dprintk(1, "res: put %d\n", bits); |
418 | mutex_unlock(&dev->lock); | ||
419 | } | 415 | } |
420 | 416 | ||
421 | int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data) | 417 | int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data) |
@@ -1272,9 +1268,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) | |||
1272 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 1268 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
1273 | dprintk(1, "%s()\n", __func__); | 1269 | dprintk(1, "%s()\n", __func__); |
1274 | 1270 | ||
1275 | mutex_lock(&dev->lock); | ||
1276 | cx23885_set_tvnorm(dev, tvnorms); | 1271 | cx23885_set_tvnorm(dev, tvnorms); |
1277 | mutex_unlock(&dev->lock); | ||
1278 | 1272 | ||
1279 | return 0; | 1273 | return 0; |
1280 | } | 1274 | } |
@@ -1364,13 +1358,11 @@ int cx23885_set_input(struct file *file, void *priv, unsigned int i) | |||
1364 | if (INPUT(i)->type == 0) | 1358 | if (INPUT(i)->type == 0) |
1365 | return -EINVAL; | 1359 | return -EINVAL; |
1366 | 1360 | ||
1367 | mutex_lock(&dev->lock); | ||
1368 | cx23885_video_mux(dev, i); | 1361 | cx23885_video_mux(dev, i); |
1369 | 1362 | ||
1370 | /* By default establish the default audio input for the card also */ | 1363 | /* By default establish the default audio input for the card also */ |
1371 | /* Caller is free to use VIDIOC_S_AUDIO to override afterwards */ | 1364 | /* Caller is free to use VIDIOC_S_AUDIO to override afterwards */ |
1372 | cx23885_audio_mux(dev, i); | 1365 | cx23885_audio_mux(dev, i); |
1373 | mutex_unlock(&dev->lock); | ||
1374 | return 0; | 1366 | return 0; |
1375 | } | 1367 | } |
1376 | 1368 | ||
@@ -1544,7 +1536,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency | |||
1544 | if (unlikely(f->tuner != 0)) | 1536 | if (unlikely(f->tuner != 0)) |
1545 | return -EINVAL; | 1537 | return -EINVAL; |
1546 | 1538 | ||
1547 | mutex_lock(&dev->lock); | ||
1548 | dev->freq = f->frequency; | 1539 | dev->freq = f->frequency; |
1549 | 1540 | ||
1550 | /* I need to mute audio here */ | 1541 | /* I need to mute audio here */ |
@@ -1561,8 +1552,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency | |||
1561 | ctrl.value = 0; | 1552 | ctrl.value = 0; |
1562 | cx23885_set_control(dev, &ctrl); | 1553 | cx23885_set_control(dev, &ctrl); |
1563 | 1554 | ||
1564 | mutex_unlock(&dev->lock); | ||
1565 | |||
1566 | return 0; | 1555 | return 0; |
1567 | } | 1556 | } |
1568 | 1557 | ||
@@ -1580,7 +1569,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, | |||
1580 | .frequency = f->frequency | 1569 | .frequency = f->frequency |
1581 | }; | 1570 | }; |
1582 | 1571 | ||
1583 | mutex_lock(&dev->lock); | ||
1584 | dev->freq = f->frequency; | 1572 | dev->freq = f->frequency; |
1585 | 1573 | ||
1586 | /* I need to mute audio here */ | 1574 | /* I need to mute audio here */ |
@@ -1594,7 +1582,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, | |||
1594 | 1582 | ||
1595 | vfe = videobuf_dvb_get_frontend(&dev->ts2.frontends, 1); | 1583 | vfe = videobuf_dvb_get_frontend(&dev->ts2.frontends, 1); |
1596 | if (!vfe) { | 1584 | if (!vfe) { |
1597 | mutex_unlock(&dev->lock); | ||
1598 | return -EINVAL; | 1585 | return -EINVAL; |
1599 | } | 1586 | } |
1600 | 1587 | ||
@@ -1619,8 +1606,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, | |||
1619 | ctrl.value = 0; | 1606 | ctrl.value = 0; |
1620 | cx23885_set_control(dev, &ctrl); | 1607 | cx23885_set_control(dev, &ctrl); |
1621 | 1608 | ||
1622 | mutex_unlock(&dev->lock); | ||
1623 | |||
1624 | return 0; | 1609 | return 0; |
1625 | } | 1610 | } |
1626 | 1611 | ||
@@ -1742,7 +1727,7 @@ static const struct v4l2_file_operations video_fops = { | |||
1742 | .read = video_read, | 1727 | .read = video_read, |
1743 | .poll = video_poll, | 1728 | .poll = video_poll, |
1744 | .mmap = video_mmap, | 1729 | .mmap = video_mmap, |
1745 | .ioctl = video_ioctl2, | 1730 | .unlocked_ioctl = video_ioctl2, |
1746 | }; | 1731 | }; |
1747 | 1732 | ||
1748 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 1733 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -1791,14 +1776,6 @@ static struct video_device cx23885_video_template = { | |||
1791 | .tvnorms = CX23885_NORMS, | 1776 | .tvnorms = CX23885_NORMS, |
1792 | }; | 1777 | }; |
1793 | 1778 | ||
1794 | static const struct v4l2_file_operations radio_fops = { | ||
1795 | .owner = THIS_MODULE, | ||
1796 | .open = video_open, | ||
1797 | .release = video_release, | ||
1798 | .ioctl = video_ioctl2, | ||
1799 | }; | ||
1800 | |||
1801 | |||
1802 | void cx23885_video_unregister(struct cx23885_dev *dev) | 1779 | void cx23885_video_unregister(struct cx23885_dev *dev) |
1803 | { | 1780 | { |
1804 | dprintk(1, "%s()\n", __func__); | 1781 | dprintk(1, "%s()\n", __func__); |
@@ -1909,6 +1886,14 @@ int cx23885_video_register(struct cx23885_dev *dev) | |||
1909 | } | 1886 | } |
1910 | } | 1887 | } |
1911 | 1888 | ||
1889 | /* initial device configuration */ | ||
1890 | mutex_lock(&dev->lock); | ||
1891 | cx23885_set_tvnorm(dev, dev->tvnorm); | ||
1892 | init_controls(dev); | ||
1893 | cx23885_video_mux(dev, 0); | ||
1894 | cx23885_audio_mux(dev, 0); | ||
1895 | mutex_unlock(&dev->lock); | ||
1896 | |||
1912 | /* register Video device */ | 1897 | /* register Video device */ |
1913 | dev->video_dev = cx23885_vdev_init(dev, dev->pci, | 1898 | dev->video_dev = cx23885_vdev_init(dev, dev->pci, |
1914 | &cx23885_video_template, "video"); | 1899 | &cx23885_video_template, "video"); |
@@ -1938,14 +1923,6 @@ int cx23885_video_register(struct cx23885_dev *dev) | |||
1938 | /* Register ALSA audio device */ | 1923 | /* Register ALSA audio device */ |
1939 | dev->audio_dev = cx23885_audio_register(dev); | 1924 | dev->audio_dev = cx23885_audio_register(dev); |
1940 | 1925 | ||
1941 | /* initial device configuration */ | ||
1942 | mutex_lock(&dev->lock); | ||
1943 | cx23885_set_tvnorm(dev, dev->tvnorm); | ||
1944 | init_controls(dev); | ||
1945 | cx23885_video_mux(dev, 0); | ||
1946 | cx23885_audio_mux(dev, 0); | ||
1947 | mutex_unlock(&dev->lock); | ||
1948 | |||
1949 | return 0; | 1926 | return 0; |
1950 | 1927 | ||
1951 | fail_unreg: | 1928 | fail_unreg: |