diff options
| author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-03-09 12:34:11 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-08 05:47:13 -0400 |
| commit | d8da7513bcf9834abbb1963f909f96a9f513dd65 (patch) | |
| tree | 3352de1b0032666b831c0ad44615378b6559e879 /drivers/media/usb | |
| parent | d4352f3639d780f1727c26708cb511a3e3702226 (diff) | |
[media] uvc: embed video_device
Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb')
| -rw-r--r-- | drivers/media/usb/uvc/uvc_driver.c | 22 | ||||
| -rw-r--r-- | drivers/media/usb/uvc/uvc_v4l2.c | 2 | ||||
| -rw-r--r-- | drivers/media/usb/uvc/uvcvideo.h | 2 |
3 files changed, 6 insertions, 20 deletions
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index fd79a1afa9b4..5970dd6a1c1c 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c | |||
| @@ -1669,10 +1669,6 @@ static void uvc_delete(struct uvc_device *dev) | |||
| 1669 | #ifdef CONFIG_MEDIA_CONTROLLER | 1669 | #ifdef CONFIG_MEDIA_CONTROLLER |
| 1670 | uvc_mc_cleanup_entity(entity); | 1670 | uvc_mc_cleanup_entity(entity); |
| 1671 | #endif | 1671 | #endif |
| 1672 | if (entity->vdev) { | ||
| 1673 | video_device_release(entity->vdev); | ||
| 1674 | entity->vdev = NULL; | ||
| 1675 | } | ||
| 1676 | kfree(entity); | 1672 | kfree(entity); |
| 1677 | } | 1673 | } |
| 1678 | 1674 | ||
| @@ -1717,11 +1713,10 @@ static void uvc_unregister_video(struct uvc_device *dev) | |||
| 1717 | atomic_inc(&dev->nstreams); | 1713 | atomic_inc(&dev->nstreams); |
| 1718 | 1714 | ||
| 1719 | list_for_each_entry(stream, &dev->streams, list) { | 1715 | list_for_each_entry(stream, &dev->streams, list) { |
| 1720 | if (stream->vdev == NULL) | 1716 | if (!video_is_registered(&stream->vdev)) |
| 1721 | continue; | 1717 | continue; |
| 1722 | 1718 | ||
| 1723 | video_unregister_device(stream->vdev); | 1719 | video_unregister_device(&stream->vdev); |
| 1724 | stream->vdev = NULL; | ||
| 1725 | 1720 | ||
| 1726 | uvc_debugfs_cleanup_stream(stream); | 1721 | uvc_debugfs_cleanup_stream(stream); |
| 1727 | } | 1722 | } |
| @@ -1736,7 +1731,7 @@ static void uvc_unregister_video(struct uvc_device *dev) | |||
| 1736 | static int uvc_register_video(struct uvc_device *dev, | 1731 | static int uvc_register_video(struct uvc_device *dev, |
| 1737 | struct uvc_streaming *stream) | 1732 | struct uvc_streaming *stream) |
| 1738 | { | 1733 | { |
| 1739 | struct video_device *vdev; | 1734 | struct video_device *vdev = &stream->vdev; |
| 1740 | int ret; | 1735 | int ret; |
| 1741 | 1736 | ||
| 1742 | /* Initialize the video buffers queue. */ | 1737 | /* Initialize the video buffers queue. */ |
| @@ -1757,12 +1752,6 @@ static int uvc_register_video(struct uvc_device *dev, | |||
| 1757 | uvc_debugfs_init_stream(stream); | 1752 | uvc_debugfs_init_stream(stream); |
| 1758 | 1753 | ||
| 1759 | /* Register the device with V4L. */ | 1754 | /* Register the device with V4L. */ |
| 1760 | vdev = video_device_alloc(); | ||
| 1761 | if (vdev == NULL) { | ||
| 1762 | uvc_printk(KERN_ERR, "Failed to allocate video device (%d).\n", | ||
| 1763 | ret); | ||
| 1764 | return -ENOMEM; | ||
| 1765 | } | ||
| 1766 | 1755 | ||
| 1767 | /* We already hold a reference to dev->udev. The video device will be | 1756 | /* We already hold a reference to dev->udev. The video device will be |
| 1768 | * unregistered before the reference is released, so we don't need to | 1757 | * unregistered before the reference is released, so we don't need to |
| @@ -1780,15 +1769,12 @@ static int uvc_register_video(struct uvc_device *dev, | |||
| 1780 | /* Set the driver data before calling video_register_device, otherwise | 1769 | /* Set the driver data before calling video_register_device, otherwise |
| 1781 | * uvc_v4l2_open might race us. | 1770 | * uvc_v4l2_open might race us. |
| 1782 | */ | 1771 | */ |
| 1783 | stream->vdev = vdev; | ||
| 1784 | video_set_drvdata(vdev, stream); | 1772 | video_set_drvdata(vdev, stream); |
| 1785 | 1773 | ||
| 1786 | ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); | 1774 | ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); |
| 1787 | if (ret < 0) { | 1775 | if (ret < 0) { |
| 1788 | uvc_printk(KERN_ERR, "Failed to register video device (%d).\n", | 1776 | uvc_printk(KERN_ERR, "Failed to register video device (%d).\n", |
| 1789 | ret); | 1777 | ret); |
| 1790 | stream->vdev = NULL; | ||
| 1791 | video_device_release(vdev); | ||
| 1792 | return ret; | 1778 | return ret; |
| 1793 | } | 1779 | } |
| 1794 | 1780 | ||
| @@ -1827,7 +1813,7 @@ static int uvc_register_terms(struct uvc_device *dev, | |||
| 1827 | if (ret < 0) | 1813 | if (ret < 0) |
| 1828 | return ret; | 1814 | return ret; |
| 1829 | 1815 | ||
| 1830 | term->vdev = stream->vdev; | 1816 | term->vdev = &stream->vdev; |
| 1831 | } | 1817 | } |
| 1832 | 1818 | ||
| 1833 | return 0; | 1819 | return 0; |
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 8d967fe2ef7d..b6a09835e7aa 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c | |||
| @@ -511,7 +511,7 @@ static int uvc_v4l2_open(struct file *file) | |||
| 511 | stream->dev->users++; | 511 | stream->dev->users++; |
| 512 | mutex_unlock(&stream->dev->lock); | 512 | mutex_unlock(&stream->dev->lock); |
| 513 | 513 | ||
| 514 | v4l2_fh_init(&handle->vfh, stream->vdev); | 514 | v4l2_fh_init(&handle->vfh, &stream->vdev); |
| 515 | v4l2_fh_add(&handle->vfh); | 515 | v4l2_fh_add(&handle->vfh); |
| 516 | handle->chain = stream->chain; | 516 | handle->chain = stream->chain; |
| 517 | handle->stream = stream; | 517 | handle->stream = stream; |
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index c63e5b55e143..1b594c203992 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h | |||
| @@ -443,7 +443,7 @@ struct uvc_stats_stream { | |||
| 443 | struct uvc_streaming { | 443 | struct uvc_streaming { |
| 444 | struct list_head list; | 444 | struct list_head list; |
| 445 | struct uvc_device *dev; | 445 | struct uvc_device *dev; |
| 446 | struct video_device *vdev; | 446 | struct video_device vdev; |
| 447 | struct uvc_video_chain *chain; | 447 | struct uvc_video_chain *chain; |
| 448 | atomic_t active; | 448 | atomic_t active; |
| 449 | 449 | ||
