diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-10 08:44:04 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-15 21:17:56 -0500 |
commit | 63b0d5ad20365edf8baf96cdbb8e7faf62501286 (patch) | |
tree | 9a12041cab48051834ee67d0de358443464e5d94 /drivers | |
parent | f0813b4c9f7ffbeaddcba1c08a1812f7ff30e1b7 (diff) |
V4L/DVB (13554a): v4l: Use the video_drvdata function in drivers
Fix all device drivers to use the video_drvdata function instead of
maintaining a local list of minor to private data mappings. Call
video_set_drvdata to register the driver private pointer when not
already done.
Where applicable, the local list of mappings is completely removed when
it becomes unused.
[mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
35 files changed, 178 insertions, 555 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index f279a6440415..2d9fc2435f2b 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -195,42 +195,24 @@ void saa7146_buffer_timeout(unsigned long data) | |||
195 | static int fops_open(struct file *file) | 195 | static int fops_open(struct file *file) |
196 | { | 196 | { |
197 | unsigned int minor = video_devdata(file)->minor; | 197 | unsigned int minor = video_devdata(file)->minor; |
198 | struct saa7146_dev *h = NULL, *dev = NULL; | 198 | struct video_device *vdev = video_devdata(file); |
199 | struct list_head *list; | 199 | struct saa7146_dev *dev = video_drvdata(file); |
200 | struct saa7146_fh *fh = NULL; | 200 | struct saa7146_fh *fh = NULL; |
201 | int result = 0; | 201 | int result = 0; |
202 | 202 | ||
203 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 203 | enum v4l2_buf_type type; |
204 | 204 | ||
205 | DEB_EE(("file:%p, minor:%d\n", file, minor)); | 205 | DEB_EE(("file:%p, minor:%d\n", file, minor)); |
206 | 206 | ||
207 | if (mutex_lock_interruptible(&saa7146_devices_lock)) | 207 | if (mutex_lock_interruptible(&saa7146_devices_lock)) |
208 | return -ERESTARTSYS; | 208 | return -ERESTARTSYS; |
209 | 209 | ||
210 | list_for_each(list,&saa7146_devices) { | ||
211 | h = list_entry(list, struct saa7146_dev, item); | ||
212 | if( NULL == h->vv_data ) { | ||
213 | DEB_D(("device %p has not registered video devices.\n",h)); | ||
214 | continue; | ||
215 | } | ||
216 | DEB_D(("trying: %p @ major %d,%d\n",h,h->vv_data->video_minor,h->vv_data->vbi_minor)); | ||
217 | |||
218 | if (h->vv_data->video_minor == minor) { | ||
219 | dev = h; | ||
220 | } | ||
221 | if (h->vv_data->vbi_minor == minor) { | ||
222 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
223 | dev = h; | ||
224 | } | ||
225 | } | ||
226 | if (NULL == dev) { | ||
227 | DEB_S(("no such video device.\n")); | ||
228 | result = -ENODEV; | ||
229 | goto out; | ||
230 | } | ||
231 | |||
232 | DEB_D(("using: %p\n",dev)); | 210 | DEB_D(("using: %p\n",dev)); |
233 | 211 | ||
212 | type = vdev->vfl_type == VFL_TYPE_GRABBER | ||
213 | ? V4L2_BUF_TYPE_VIDEO_CAPTURE | ||
214 | : V4L2_BUF_TYPE_VBI_CAPTURE; | ||
215 | |||
234 | /* check if an extension is registered */ | 216 | /* check if an extension is registered */ |
235 | if( NULL == dev->ext ) { | 217 | if( NULL == dev->ext ) { |
236 | DEB_S(("no extension registered for this device.\n")); | 218 | DEB_S(("no extension registered for this device.\n")); |
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c index 1485aee18d58..13a8a1db5349 100644 --- a/drivers/media/video/au0828/au0828-video.c +++ b/drivers/media/video/au0828/au0828-video.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "au0828.h" | 40 | #include "au0828.h" |
41 | #include "au0828-reg.h" | 41 | #include "au0828-reg.h" |
42 | 42 | ||
43 | static LIST_HEAD(au0828_devlist); | ||
44 | static DEFINE_MUTEX(au0828_sysfs_lock); | 43 | static DEFINE_MUTEX(au0828_sysfs_lock); |
45 | 44 | ||
46 | #define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1) | 45 | #define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1) |
@@ -693,10 +692,8 @@ void au0828_analog_unregister(struct au0828_dev *dev) | |||
693 | dprintk(1, "au0828_release_resources called\n"); | 692 | dprintk(1, "au0828_release_resources called\n"); |
694 | mutex_lock(&au0828_sysfs_lock); | 693 | mutex_lock(&au0828_sysfs_lock); |
695 | 694 | ||
696 | if (dev->vdev) { | 695 | if (dev->vdev) |
697 | list_del(&dev->au0828list); | ||
698 | video_unregister_device(dev->vdev); | 696 | video_unregister_device(dev->vdev); |
699 | } | ||
700 | if (dev->vbi_dev) | 697 | if (dev->vbi_dev) |
701 | video_unregister_device(dev->vbi_dev); | 698 | video_unregister_device(dev->vbi_dev); |
702 | 699 | ||
@@ -737,29 +734,15 @@ static void res_free(struct au0828_fh *fh) | |||
737 | 734 | ||
738 | static int au0828_v4l2_open(struct file *filp) | 735 | static int au0828_v4l2_open(struct file *filp) |
739 | { | 736 | { |
740 | int minor = video_devdata(filp)->minor; | ||
741 | int ret = 0; | 737 | int ret = 0; |
742 | struct au0828_dev *h, *dev = NULL; | 738 | struct au0828_dev *dev = video_drvdata(filp); |
743 | struct au0828_fh *fh; | 739 | struct au0828_fh *fh; |
744 | int type = 0; | 740 | int type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
745 | struct list_head *list; | 741 | |
746 | |||
747 | list_for_each(list, &au0828_devlist) { | ||
748 | h = list_entry(list, struct au0828_dev, au0828list); | ||
749 | if (h->vdev->minor == minor) { | ||
750 | dev = h; | ||
751 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
752 | } | ||
753 | #ifdef VBI_IS_WORKING | 742 | #ifdef VBI_IS_WORKING |
754 | if (h->vbi_dev->minor == minor) { | 743 | if (video_devdata(filp)->vfl_type == VFL_TYPE_GRABBER) |
755 | dev = h; | 744 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
756 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
757 | } | ||
758 | #endif | 745 | #endif |
759 | } | ||
760 | |||
761 | if (NULL == dev) | ||
762 | return -ENODEV; | ||
763 | 746 | ||
764 | fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL); | 747 | fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL); |
765 | if (NULL == fh) { | 748 | if (NULL == fh) { |
@@ -1676,25 +1659,23 @@ int au0828_analog_register(struct au0828_dev *dev, | |||
1676 | strcpy(dev->vbi_dev->name, "au0828a vbi"); | 1659 | strcpy(dev->vbi_dev->name, "au0828a vbi"); |
1677 | #endif | 1660 | #endif |
1678 | 1661 | ||
1679 | list_add_tail(&dev->au0828list, &au0828_devlist); | ||
1680 | |||
1681 | /* Register the v4l2 device */ | 1662 | /* Register the v4l2 device */ |
1663 | video_set_drvdata(dev->vdev, dev); | ||
1682 | retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1); | 1664 | retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1); |
1683 | if (retval != 0) { | 1665 | if (retval != 0) { |
1684 | dprintk(1, "unable to register video device (error = %d).\n", | 1666 | dprintk(1, "unable to register video device (error = %d).\n", |
1685 | retval); | 1667 | retval); |
1686 | list_del(&dev->au0828list); | ||
1687 | video_device_release(dev->vdev); | 1668 | video_device_release(dev->vdev); |
1688 | return -ENODEV; | 1669 | return -ENODEV; |
1689 | } | 1670 | } |
1690 | 1671 | ||
1691 | #ifdef VBI_IS_WORKING | 1672 | #ifdef VBI_IS_WORKING |
1692 | /* Register the vbi device */ | 1673 | /* Register the vbi device */ |
1674 | video_set_drvdata(dev->vbi_dev, dev); | ||
1693 | retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1); | 1675 | retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1); |
1694 | if (retval != 0) { | 1676 | if (retval != 0) { |
1695 | dprintk(1, "unable to register vbi device (error = %d).\n", | 1677 | dprintk(1, "unable to register vbi device (error = %d).\n", |
1696 | retval); | 1678 | retval); |
1697 | list_del(&dev->au0828list); | ||
1698 | video_device_release(dev->vbi_dev); | 1679 | video_device_release(dev->vbi_dev); |
1699 | video_device_release(dev->vdev); | 1680 | video_device_release(dev->vdev); |
1700 | return -ENODEV; | 1681 | return -ENODEV; |
diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h index b977915efbd0..207f32dec6a6 100644 --- a/drivers/media/video/au0828/au0828.h +++ b/drivers/media/video/au0828/au0828.h | |||
@@ -192,7 +192,6 @@ struct au0828_dev { | |||
192 | struct au0828_dvb dvb; | 192 | struct au0828_dvb dvb; |
193 | 193 | ||
194 | /* Analog */ | 194 | /* Analog */ |
195 | struct list_head au0828list; | ||
196 | struct v4l2_device v4l2_dev; | 195 | struct v4l2_device v4l2_dev; |
197 | int users; | 196 | int users; |
198 | unsigned int stream_on:1; /* Locks streams */ | 197 | unsigned int stream_on:1; /* Locks streams */ |
diff --git a/drivers/media/video/cx231xx/cx231xx-core.c b/drivers/media/video/cx231xx/cx231xx-core.c index 0d333e679f70..4a60dfbc347d 100644 --- a/drivers/media/video/cx231xx/cx231xx-core.c +++ b/drivers/media/video/cx231xx/cx231xx-core.c | |||
@@ -66,32 +66,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); | |||
66 | static LIST_HEAD(cx231xx_devlist); | 66 | static LIST_HEAD(cx231xx_devlist); |
67 | static DEFINE_MUTEX(cx231xx_devlist_mutex); | 67 | static DEFINE_MUTEX(cx231xx_devlist_mutex); |
68 | 68 | ||
69 | struct cx231xx *cx231xx_get_device(int minor, | ||
70 | enum v4l2_buf_type *fh_type, int *has_radio) | ||
71 | { | ||
72 | struct cx231xx *h, *dev = NULL; | ||
73 | |||
74 | *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
75 | *has_radio = 0; | ||
76 | |||
77 | mutex_lock(&cx231xx_devlist_mutex); | ||
78 | list_for_each_entry(h, &cx231xx_devlist, devlist) { | ||
79 | if (h->vdev->minor == minor) | ||
80 | dev = h; | ||
81 | if (h->vbi_dev->minor == minor) { | ||
82 | dev = h; | ||
83 | *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
84 | } | ||
85 | if (h->radio_dev && h->radio_dev->minor == minor) { | ||
86 | dev = h; | ||
87 | *has_radio = 1; | ||
88 | } | ||
89 | } | ||
90 | mutex_unlock(&cx231xx_devlist_mutex); | ||
91 | |||
92 | return dev; | ||
93 | } | ||
94 | |||
95 | /* | 69 | /* |
96 | * cx231xx_realease_resources() | 70 | * cx231xx_realease_resources() |
97 | * unregisters the v4l2,i2c and usb devices | 71 | * unregisters the v4l2,i2c and usb devices |
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c index 71e152dc2791..3fc7a6fe8554 100644 --- a/drivers/media/video/cx231xx/cx231xx-video.c +++ b/drivers/media/video/cx231xx/cx231xx-video.c | |||
@@ -1918,13 +1918,22 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
1918 | { | 1918 | { |
1919 | int minor = video_devdata(filp)->minor; | 1919 | int minor = video_devdata(filp)->minor; |
1920 | int errCode = 0, radio = 0; | 1920 | int errCode = 0, radio = 0; |
1921 | struct cx231xx *dev = NULL; | 1921 | struct video_device *vdev = video_devdata(filp); |
1922 | struct cx231xx *dev = video_drvdata(filp); | ||
1922 | struct cx231xx_fh *fh; | 1923 | struct cx231xx_fh *fh; |
1923 | enum v4l2_buf_type fh_type = 0; | 1924 | enum v4l2_buf_type fh_type = 0; |
1924 | 1925 | ||
1925 | dev = cx231xx_get_device(minor, &fh_type, &radio); | 1926 | switch (vdev->vfl_type) { |
1926 | if (NULL == dev) | 1927 | case VFL_TYPE_GRABBER: |
1927 | return -ENODEV; | 1928 | fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1929 | break; | ||
1930 | case VFL_TYPE_VBI: | ||
1931 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
1932 | break; | ||
1933 | case VFL_TYPE_RADIO: | ||
1934 | radio = 1; | ||
1935 | break; | ||
1936 | } | ||
1928 | 1937 | ||
1929 | mutex_lock(&dev->lock); | 1938 | mutex_lock(&dev->lock); |
1930 | 1939 | ||
@@ -2326,6 +2335,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, | |||
2326 | 2335 | ||
2327 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); | 2336 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); |
2328 | 2337 | ||
2338 | video_set_drvdata(vfd, dev); | ||
2329 | return vfd; | 2339 | return vfd; |
2330 | } | 2340 | } |
2331 | 2341 | ||
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h index 64e2ddd3c401..17d4d1a800ce 100644 --- a/drivers/media/video/cx231xx/cx231xx.h +++ b/drivers/media/video/cx231xx/cx231xx.h | |||
@@ -689,8 +689,6 @@ void cx231xx_release_analog_resources(struct cx231xx *dev); | |||
689 | int cx231xx_register_analog_devices(struct cx231xx *dev); | 689 | int cx231xx_register_analog_devices(struct cx231xx *dev); |
690 | void cx231xx_remove_from_devlist(struct cx231xx *dev); | 690 | void cx231xx_remove_from_devlist(struct cx231xx *dev); |
691 | void cx231xx_add_into_devlist(struct cx231xx *dev); | 691 | void cx231xx_add_into_devlist(struct cx231xx *dev); |
692 | struct cx231xx *cx231xx_get_device(int minor, | ||
693 | enum v4l2_buf_type *fh_type, int *has_radio); | ||
694 | void cx231xx_init_extension(struct cx231xx *dev); | 692 | void cx231xx_init_extension(struct cx231xx *dev); |
695 | void cx231xx_close_extension(struct cx231xx *dev); | 693 | void cx231xx_close_extension(struct cx231xx *dev); |
696 | 694 | ||
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c index a7bfe7c3a447..272c60a993b5 100644 --- a/drivers/media/video/cx23885/cx23885-417.c +++ b/drivers/media/video/cx23885/cx23885-417.c | |||
@@ -1568,28 +1568,11 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
1568 | 1568 | ||
1569 | static int mpeg_open(struct file *file) | 1569 | static int mpeg_open(struct file *file) |
1570 | { | 1570 | { |
1571 | int minor = video_devdata(file)->minor; | 1571 | struct cx23885_dev *dev = video_drvdata(file); |
1572 | struct cx23885_dev *h, *dev = NULL; | ||
1573 | struct list_head *list; | ||
1574 | struct cx23885_fh *fh; | 1572 | struct cx23885_fh *fh; |
1575 | 1573 | ||
1576 | dprintk(2, "%s()\n", __func__); | 1574 | dprintk(2, "%s()\n", __func__); |
1577 | 1575 | ||
1578 | lock_kernel(); | ||
1579 | list_for_each(list, &cx23885_devlist) { | ||
1580 | h = list_entry(list, struct cx23885_dev, devlist); | ||
1581 | if (h->v4l_device && | ||
1582 | h->v4l_device->minor == minor) { | ||
1583 | dev = h; | ||
1584 | break; | ||
1585 | } | ||
1586 | } | ||
1587 | |||
1588 | if (dev == NULL) { | ||
1589 | unlock_kernel(); | ||
1590 | return -ENODEV; | ||
1591 | } | ||
1592 | |||
1593 | /* allocate + initialize per filehandle data */ | 1576 | /* allocate + initialize per filehandle data */ |
1594 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 1577 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
1595 | if (NULL == fh) { | 1578 | if (NULL == fh) { |
@@ -1597,6 +1580,8 @@ static int mpeg_open(struct file *file) | |||
1597 | return -ENOMEM; | 1580 | return -ENOMEM; |
1598 | } | 1581 | } |
1599 | 1582 | ||
1583 | lock_kernel(); | ||
1584 | |||
1600 | file->private_data = fh; | 1585 | file->private_data = fh; |
1601 | fh->dev = dev; | 1586 | fh->dev = dev; |
1602 | 1587 | ||
@@ -1803,6 +1788,7 @@ int cx23885_417_register(struct cx23885_dev *dev) | |||
1803 | /* Allocate and initialize V4L video device */ | 1788 | /* Allocate and initialize V4L video device */ |
1804 | dev->v4l_device = cx23885_video_dev_alloc(tsport, | 1789 | dev->v4l_device = cx23885_video_dev_alloc(tsport, |
1805 | dev->pci, &cx23885_mpeg_template, "mpeg"); | 1790 | dev->pci, &cx23885_mpeg_template, "mpeg"); |
1791 | video_set_drvdata(dev->v4l_device, dev); | ||
1806 | err = video_register_device(dev->v4l_device, | 1792 | err = video_register_device(dev->v4l_device, |
1807 | VFL_TYPE_GRABBER, -1); | 1793 | VFL_TYPE_GRABBER, -1); |
1808 | if (err < 0) { | 1794 | if (err < 0) { |
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index 04b12d27bc13..0dde57e96d30 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
@@ -55,9 +55,6 @@ MODULE_PARM_DESC(card, "card type"); | |||
55 | 55 | ||
56 | static unsigned int cx23885_devcount; | 56 | static unsigned int cx23885_devcount; |
57 | 57 | ||
58 | static DEFINE_MUTEX(devlist); | ||
59 | LIST_HEAD(cx23885_devlist); | ||
60 | |||
61 | #define NO_SYNC_LINE (-1U) | 58 | #define NO_SYNC_LINE (-1U) |
62 | 59 | ||
63 | /* FIXME, these allocations will change when | 60 | /* FIXME, these allocations will change when |
@@ -785,10 +782,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
785 | dev->nr = cx23885_devcount++; | 782 | dev->nr = cx23885_devcount++; |
786 | sprintf(dev->name, "cx23885[%d]", dev->nr); | 783 | sprintf(dev->name, "cx23885[%d]", dev->nr); |
787 | 784 | ||
788 | mutex_lock(&devlist); | ||
789 | list_add_tail(&dev->devlist, &cx23885_devlist); | ||
790 | mutex_unlock(&devlist); | ||
791 | |||
792 | /* Configure the internal memory */ | 785 | /* Configure the internal memory */ |
793 | if (dev->pci->device == 0x8880) { | 786 | if (dev->pci->device == 0x8880) { |
794 | /* Could be 887 or 888, assume a default */ | 787 | /* Could be 887 or 888, assume a default */ |
@@ -2008,10 +2001,6 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev) | |||
2008 | /* unregister stuff */ | 2001 | /* unregister stuff */ |
2009 | free_irq(pci_dev->irq, dev); | 2002 | free_irq(pci_dev->irq, dev); |
2010 | 2003 | ||
2011 | mutex_lock(&devlist); | ||
2012 | list_del(&dev->devlist); | ||
2013 | mutex_unlock(&devlist); | ||
2014 | |||
2015 | cx23885_dev_unregister(dev); | 2004 | cx23885_dev_unregister(dev); |
2016 | v4l2_device_unregister(v4l2_dev); | 2005 | v4l2_device_unregister(v4l2_dev); |
2017 | kfree(dev); | 2006 | kfree(dev); |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index fd98121361f4..e10f28cfef5e 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -323,6 +323,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, | |||
323 | vfd->release = video_device_release; | 323 | vfd->release = video_device_release; |
324 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", | 324 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", |
325 | dev->name, type, cx23885_boards[dev->board].name); | 325 | dev->name, type, cx23885_boards[dev->board].name); |
326 | video_set_drvdata(vfd, dev); | ||
326 | return vfd; | 327 | return vfd; |
327 | } | 328 | } |
328 | 329 | ||
@@ -717,34 +718,22 @@ static int get_resource(struct cx23885_fh *fh) | |||
717 | static int video_open(struct file *file) | 718 | static int video_open(struct file *file) |
718 | { | 719 | { |
719 | int minor = video_devdata(file)->minor; | 720 | int minor = video_devdata(file)->minor; |
720 | struct cx23885_dev *h, *dev = NULL; | 721 | struct video_device *vdev = video_devdata(file); |
722 | struct cx23885_dev *dev = video_drvdata(file); | ||
721 | struct cx23885_fh *fh; | 723 | struct cx23885_fh *fh; |
722 | struct list_head *list; | ||
723 | enum v4l2_buf_type type = 0; | 724 | enum v4l2_buf_type type = 0; |
724 | int radio = 0; | 725 | int radio = 0; |
725 | 726 | ||
726 | lock_kernel(); | 727 | switch (vdev->vfl_type) { |
727 | list_for_each(list, &cx23885_devlist) { | 728 | case VFL_TYPE_GRABBER: |
728 | h = list_entry(list, struct cx23885_dev, devlist); | 729 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
729 | if (h->video_dev && | 730 | break; |
730 | h->video_dev->minor == minor) { | 731 | case VFL_TYPE_VBI: |
731 | dev = h; | 732 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
732 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 733 | break; |
733 | } | 734 | case VFL_TYPE_RADIO: |
734 | if (h->vbi_dev && | 735 | radio = 1; |
735 | h->vbi_dev->minor == minor) { | 736 | break; |
736 | dev = h; | ||
737 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
738 | } | ||
739 | if (h->radio_dev && | ||
740 | h->radio_dev->minor == minor) { | ||
741 | radio = 1; | ||
742 | dev = h; | ||
743 | } | ||
744 | } | ||
745 | if (NULL == dev) { | ||
746 | unlock_kernel(); | ||
747 | return -ENODEV; | ||
748 | } | 737 | } |
749 | 738 | ||
750 | dprintk(1, "open minor=%d radio=%d type=%s\n", | 739 | dprintk(1, "open minor=%d radio=%d type=%s\n", |
@@ -752,10 +741,11 @@ static int video_open(struct file *file) | |||
752 | 741 | ||
753 | /* allocate + initialize per filehandle data */ | 742 | /* allocate + initialize per filehandle data */ |
754 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 743 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
755 | if (NULL == fh) { | 744 | if (NULL == fh) |
756 | unlock_kernel(); | ||
757 | return -ENOMEM; | 745 | return -ENOMEM; |
758 | } | 746 | |
747 | lock_kernel(); | ||
748 | |||
759 | file->private_data = fh; | 749 | file->private_data = fh; |
760 | fh->dev = dev; | 750 | fh->dev = dev; |
761 | fh->radio = radio; | 751 | fh->radio = radio; |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index fa744764dc8b..08b3f6b136a0 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
@@ -303,7 +303,6 @@ struct cx23885_tsport { | |||
303 | }; | 303 | }; |
304 | 304 | ||
305 | struct cx23885_dev { | 305 | struct cx23885_dev { |
306 | struct list_head devlist; | ||
307 | atomic_t refcount; | 306 | atomic_t refcount; |
308 | struct v4l2_device v4l2_dev; | 307 | struct v4l2_device v4l2_dev; |
309 | 308 | ||
@@ -399,8 +398,6 @@ static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev) | |||
399 | 398 | ||
400 | extern struct v4l2_subdev *cx23885_find_hw(struct cx23885_dev *dev, u32 hw); | 399 | extern struct v4l2_subdev *cx23885_find_hw(struct cx23885_dev *dev, u32 hw); |
401 | 400 | ||
402 | extern struct list_head cx23885_devlist; | ||
403 | |||
404 | #define SRAM_CH01 0 /* Video A */ | 401 | #define SRAM_CH01 0 /* Video A */ |
405 | #define SRAM_CH02 1 /* VBI A */ | 402 | #define SRAM_CH02 1 /* VBI A */ |
406 | #define SRAM_CH03 2 /* Video B */ | 403 | #define SRAM_CH03 2 /* Video B */ |
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 5186f87b4ece..f0ef94150d1e 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -1049,20 +1049,14 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
1049 | static int mpeg_open(struct file *file) | 1049 | static int mpeg_open(struct file *file) |
1050 | { | 1050 | { |
1051 | int minor = video_devdata(file)->minor; | 1051 | int minor = video_devdata(file)->minor; |
1052 | struct cx8802_dev *dev = NULL; | 1052 | struct cx8802_dev *dev = video_drvdata(file); |
1053 | struct cx8802_fh *fh; | 1053 | struct cx8802_fh *fh; |
1054 | struct cx8802_driver *drv = NULL; | 1054 | struct cx8802_driver *drv = NULL; |
1055 | int err; | 1055 | int err; |
1056 | 1056 | ||
1057 | lock_kernel(); | ||
1058 | dev = cx8802_get_device(minor); | ||
1059 | |||
1060 | dprintk( 1, "%s\n", __func__); | 1057 | dprintk( 1, "%s\n", __func__); |
1061 | 1058 | ||
1062 | if (dev == NULL) { | 1059 | lock_kernel(); |
1063 | unlock_kernel(); | ||
1064 | return -ENODEV; | ||
1065 | } | ||
1066 | 1060 | ||
1067 | /* Make sure we can acquire the hardware */ | 1061 | /* Make sure we can acquire the hardware */ |
1068 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | 1062 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); |
@@ -1129,10 +1123,6 @@ static int mpeg_release(struct file *file) | |||
1129 | kfree(fh); | 1123 | kfree(fh); |
1130 | 1124 | ||
1131 | /* Make sure we release the hardware */ | 1125 | /* Make sure we release the hardware */ |
1132 | dev = cx8802_get_device(video_devdata(file)->minor); | ||
1133 | if (dev == NULL) | ||
1134 | return -ENODEV; | ||
1135 | |||
1136 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | 1126 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); |
1137 | if (drv) | 1127 | if (drv) |
1138 | drv->request_release(drv); | 1128 | drv->request_release(drv); |
@@ -1290,6 +1280,7 @@ static int blackbird_register_video(struct cx8802_dev *dev) | |||
1290 | 1280 | ||
1291 | dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, | 1281 | dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, |
1292 | &cx8802_mpeg_template,"mpeg"); | 1282 | &cx8802_mpeg_template,"mpeg"); |
1283 | video_set_drvdata(dev->mpeg_dev, dev); | ||
1293 | err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); | 1284 | err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); |
1294 | if (err < 0) { | 1285 | if (err < 0) { |
1295 | printk(KERN_INFO "%s/2: can't register mpeg device\n", | 1286 | printk(KERN_INFO "%s/2: can't register mpeg device\n", |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index de9ff0fc741f..bb5104893411 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -580,21 +580,6 @@ static int cx8802_resume_common(struct pci_dev *pci_dev) | |||
580 | return 0; | 580 | return 0; |
581 | } | 581 | } |
582 | 582 | ||
583 | #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ | ||
584 | defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) | ||
585 | struct cx8802_dev *cx8802_get_device(int minor) | ||
586 | { | ||
587 | struct cx8802_dev *dev; | ||
588 | |||
589 | list_for_each_entry(dev, &cx8802_devlist, devlist) | ||
590 | if (dev->mpeg_dev && dev->mpeg_dev->minor == minor) | ||
591 | return dev; | ||
592 | |||
593 | return NULL; | ||
594 | } | ||
595 | EXPORT_SYMBOL(cx8802_get_device); | ||
596 | #endif | ||
597 | |||
598 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) | 583 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) |
599 | { | 584 | { |
600 | struct cx8802_driver *d; | 585 | struct cx8802_driver *d; |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 0259ac6d8147..758399173a52 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -75,10 +75,6 @@ MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); | |||
75 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ | 75 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ |
76 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) | 76 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) |
77 | 77 | ||
78 | /* ------------------------------------------------------------------ */ | ||
79 | |||
80 | static LIST_HEAD(cx8800_devlist); | ||
81 | |||
82 | /* ------------------------------------------------------------------- */ | 78 | /* ------------------------------------------------------------------- */ |
83 | /* static data */ | 79 | /* static data */ |
84 | 80 | ||
@@ -754,33 +750,27 @@ static int get_ressource(struct cx8800_fh *fh) | |||
754 | static int video_open(struct file *file) | 750 | static int video_open(struct file *file) |
755 | { | 751 | { |
756 | int minor = video_devdata(file)->minor; | 752 | int minor = video_devdata(file)->minor; |
757 | struct cx8800_dev *h,*dev = NULL; | 753 | struct video_device *vdev = video_devdata(file); |
754 | struct cx8800_dev *dev = video_drvdata(file); | ||
758 | struct cx88_core *core; | 755 | struct cx88_core *core; |
759 | struct cx8800_fh *fh; | 756 | struct cx8800_fh *fh; |
760 | enum v4l2_buf_type type = 0; | 757 | enum v4l2_buf_type type = 0; |
761 | int radio = 0; | 758 | int radio = 0; |
762 | 759 | ||
763 | lock_kernel(); | 760 | switch (vdev->vfl_type) { |
764 | list_for_each_entry(h, &cx8800_devlist, devlist) { | 761 | case VFL_TYPE_GRABBER: |
765 | if (h->video_dev->minor == minor) { | 762 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
766 | dev = h; | 763 | break; |
767 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 764 | case VFL_TYPE_VBI: |
768 | } | 765 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
769 | if (h->vbi_dev->minor == minor) { | 766 | break; |
770 | dev = h; | 767 | case VFL_TYPE_RADIO: |
771 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | 768 | radio = 1; |
772 | } | 769 | break; |
773 | if (h->radio_dev && | ||
774 | h->radio_dev->minor == minor) { | ||
775 | radio = 1; | ||
776 | dev = h; | ||
777 | } | ||
778 | } | ||
779 | if (NULL == dev) { | ||
780 | unlock_kernel(); | ||
781 | return -ENODEV; | ||
782 | } | 770 | } |
783 | 771 | ||
772 | lock_kernel(); | ||
773 | |||
784 | core = dev->core; | 774 | core = dev->core; |
785 | 775 | ||
786 | dprintk(1,"open minor=%d radio=%d type=%s\n", | 776 | dprintk(1,"open minor=%d radio=%d type=%s\n", |
@@ -1909,6 +1899,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1909 | /* register v4l devices */ | 1899 | /* register v4l devices */ |
1910 | dev->video_dev = cx88_vdev_init(core,dev->pci, | 1900 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
1911 | &cx8800_video_template,"video"); | 1901 | &cx8800_video_template,"video"); |
1902 | video_set_drvdata(dev->video_dev, dev); | ||
1912 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, | 1903 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
1913 | video_nr[core->nr]); | 1904 | video_nr[core->nr]); |
1914 | if (err < 0) { | 1905 | if (err < 0) { |
@@ -1920,6 +1911,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1920 | core->name, video_device_node_name(dev->video_dev)); | 1911 | core->name, video_device_node_name(dev->video_dev)); |
1921 | 1912 | ||
1922 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); | 1913 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); |
1914 | video_set_drvdata(dev->vbi_dev, dev); | ||
1923 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, | 1915 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
1924 | vbi_nr[core->nr]); | 1916 | vbi_nr[core->nr]); |
1925 | if (err < 0) { | 1917 | if (err < 0) { |
@@ -1933,6 +1925,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1933 | if (core->board.radio.type == CX88_RADIO) { | 1925 | if (core->board.radio.type == CX88_RADIO) { |
1934 | dev->radio_dev = cx88_vdev_init(core,dev->pci, | 1926 | dev->radio_dev = cx88_vdev_init(core,dev->pci, |
1935 | &cx8800_radio_template,"radio"); | 1927 | &cx8800_radio_template,"radio"); |
1928 | video_set_drvdata(dev->radio_dev, dev); | ||
1936 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, | 1929 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
1937 | radio_nr[core->nr]); | 1930 | radio_nr[core->nr]); |
1938 | if (err < 0) { | 1931 | if (err < 0) { |
@@ -1945,7 +1938,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1945 | } | 1938 | } |
1946 | 1939 | ||
1947 | /* everything worked */ | 1940 | /* everything worked */ |
1948 | list_add_tail(&dev->devlist,&cx8800_devlist); | ||
1949 | pci_set_drvdata(pci_dev,dev); | 1941 | pci_set_drvdata(pci_dev,dev); |
1950 | 1942 | ||
1951 | /* initial device configuration */ | 1943 | /* initial device configuration */ |
@@ -2001,7 +1993,6 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) | |||
2001 | 1993 | ||
2002 | /* free memory */ | 1994 | /* free memory */ |
2003 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); | 1995 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); |
2004 | list_del(&dev->devlist); | ||
2005 | cx88_core_put(core,dev->pci); | 1996 | cx88_core_put(core,dev->pci); |
2006 | kfree(dev); | 1997 | kfree(dev); |
2007 | } | 1998 | } |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index e1c521710103..b1499bf604ea 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -423,7 +423,6 @@ struct cx8800_suspend_state { | |||
423 | 423 | ||
424 | struct cx8800_dev { | 424 | struct cx8800_dev { |
425 | struct cx88_core *core; | 425 | struct cx88_core *core; |
426 | struct list_head devlist; | ||
427 | spinlock_t slock; | 426 | spinlock_t slock; |
428 | 427 | ||
429 | /* various device info */ | 428 | /* various device info */ |
@@ -670,7 +669,6 @@ int cx88_audio_thread(void *data); | |||
670 | 669 | ||
671 | int cx8802_register_driver(struct cx8802_driver *drv); | 670 | int cx8802_register_driver(struct cx8802_driver *drv); |
672 | int cx8802_unregister_driver(struct cx8802_driver *drv); | 671 | int cx8802_unregister_driver(struct cx8802_driver *drv); |
673 | struct cx8802_dev *cx8802_get_device(int minor); | ||
674 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); | 672 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); |
675 | 673 | ||
676 | /* ----------------------------------------------------------- */ | 674 | /* ----------------------------------------------------------- */ |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 4ace70946d32..e7a68e2507de 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -2653,7 +2653,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2653 | INIT_LIST_HEAD(&dev->vbiq.active); | 2653 | INIT_LIST_HEAD(&dev->vbiq.active); |
2654 | INIT_LIST_HEAD(&dev->vbiq.queued); | 2654 | INIT_LIST_HEAD(&dev->vbiq.queued); |
2655 | 2655 | ||
2656 | |||
2657 | if (dev->board.has_msp34xx) { | 2656 | if (dev->board.has_msp34xx) { |
2658 | /* Send a reset to other chips via gpio */ | 2657 | /* Send a reset to other chips via gpio */ |
2659 | errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7); | 2658 | errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7); |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 4f61e05d30b4..b311d4514bdf 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -1136,34 +1136,6 @@ void em28xx_wake_i2c(struct em28xx *dev) | |||
1136 | static LIST_HEAD(em28xx_devlist); | 1136 | static LIST_HEAD(em28xx_devlist); |
1137 | static DEFINE_MUTEX(em28xx_devlist_mutex); | 1137 | static DEFINE_MUTEX(em28xx_devlist_mutex); |
1138 | 1138 | ||
1139 | struct em28xx *em28xx_get_device(int minor, | ||
1140 | enum v4l2_buf_type *fh_type, | ||
1141 | int *has_radio) | ||
1142 | { | ||
1143 | struct em28xx *h, *dev = NULL; | ||
1144 | |||
1145 | *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1146 | *has_radio = 0; | ||
1147 | |||
1148 | mutex_lock(&em28xx_devlist_mutex); | ||
1149 | list_for_each_entry(h, &em28xx_devlist, devlist) { | ||
1150 | if (h->vdev->minor == minor) | ||
1151 | dev = h; | ||
1152 | if (h->vbi_dev && h->vbi_dev->minor == minor) { | ||
1153 | dev = h; | ||
1154 | *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
1155 | } | ||
1156 | if (h->radio_dev && | ||
1157 | h->radio_dev->minor == minor) { | ||
1158 | dev = h; | ||
1159 | *has_radio = 1; | ||
1160 | } | ||
1161 | } | ||
1162 | mutex_unlock(&em28xx_devlist_mutex); | ||
1163 | |||
1164 | return dev; | ||
1165 | } | ||
1166 | |||
1167 | /* | 1139 | /* |
1168 | * em28xx_realease_resources() | 1140 | * em28xx_realease_resources() |
1169 | * unregisters the v4l2,i2c and usb devices | 1141 | * unregisters the v4l2,i2c and usb devices |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 9a8ff32cb31b..dd9bbe88c601 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -2082,16 +2082,24 @@ static int radio_queryctrl(struct file *file, void *priv, | |||
2082 | static int em28xx_v4l2_open(struct file *filp) | 2082 | static int em28xx_v4l2_open(struct file *filp) |
2083 | { | 2083 | { |
2084 | int minor = video_devdata(filp)->minor; | 2084 | int minor = video_devdata(filp)->minor; |
2085 | int errCode = 0, radio; | 2085 | int errCode = 0, radio = 0; |
2086 | struct em28xx *dev; | 2086 | struct video_device *vdev = video_devdata(filp); |
2087 | enum v4l2_buf_type fh_type; | 2087 | struct em28xx *dev = video_drvdata(filp); |
2088 | enum v4l2_buf_type fh_type = 0; | ||
2088 | struct em28xx_fh *fh; | 2089 | struct em28xx_fh *fh; |
2089 | enum v4l2_field field; | 2090 | enum v4l2_field field; |
2090 | 2091 | ||
2091 | dev = em28xx_get_device(minor, &fh_type, &radio); | 2092 | switch (vdev->vfl_type) { |
2092 | 2093 | case VFL_TYPE_GRABBER: | |
2093 | if (NULL == dev) | 2094 | fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
2094 | return -ENODEV; | 2095 | break; |
2096 | case VFL_TYPE_VBI: | ||
2097 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
2098 | break; | ||
2099 | case VFL_TYPE_RADIO: | ||
2100 | radio = 1; | ||
2101 | break; | ||
2102 | } | ||
2095 | 2103 | ||
2096 | mutex_lock(&dev->lock); | 2104 | mutex_lock(&dev->lock); |
2097 | 2105 | ||
@@ -2459,6 +2467,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
2459 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", | 2467 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", |
2460 | dev->name, type_name); | 2468 | dev->name, type_name); |
2461 | 2469 | ||
2470 | video_set_drvdata(vfd, dev); | ||
2462 | return vfd; | 2471 | return vfd; |
2463 | } | 2472 | } |
2464 | 2473 | ||
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 48977832316e..80d9b4fa1b97 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -668,9 +668,6 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); | |||
668 | void em28xx_wake_i2c(struct em28xx *dev); | 668 | void em28xx_wake_i2c(struct em28xx *dev); |
669 | void em28xx_remove_from_devlist(struct em28xx *dev); | 669 | void em28xx_remove_from_devlist(struct em28xx *dev); |
670 | void em28xx_add_into_devlist(struct em28xx *dev); | 670 | void em28xx_add_into_devlist(struct em28xx *dev); |
671 | struct em28xx *em28xx_get_device(int minor, | ||
672 | enum v4l2_buf_type *fh_type, | ||
673 | int *has_radio); | ||
674 | int em28xx_register_extension(struct em28xx_ops *dev); | 671 | int em28xx_register_extension(struct em28xx_ops *dev); |
675 | void em28xx_unregister_extension(struct em28xx_ops *dev); | 672 | void em28xx_unregister_extension(struct em28xx_ops *dev); |
676 | void em28xx_init_extension(struct em28xx *dev); | 673 | void em28xx_init_extension(struct em28xx *dev); |
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 4201abcf8f63..0a77108ee06f 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -233,7 +233,6 @@ struct s2255_dev { | |||
233 | 233 | ||
234 | struct s2255_dmaqueue vidq[MAX_CHANNELS]; | 234 | struct s2255_dmaqueue vidq[MAX_CHANNELS]; |
235 | struct video_device *vdev[MAX_CHANNELS]; | 235 | struct video_device *vdev[MAX_CHANNELS]; |
236 | struct list_head s2255_devlist; | ||
237 | struct timer_list timer; | 236 | struct timer_list timer; |
238 | struct s2255_fw *fw_data; | 237 | struct s2255_fw *fw_data; |
239 | struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS]; | 238 | struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS]; |
@@ -313,8 +312,6 @@ struct s2255_fh { | |||
313 | /* Channels on box are in reverse order */ | 312 | /* Channels on box are in reverse order */ |
314 | static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0}; | 313 | static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0}; |
315 | 314 | ||
316 | static LIST_HEAD(s2255_devlist); | ||
317 | |||
318 | static int debug; | 315 | static int debug; |
319 | static int *s2255_debug = &debug; | 316 | static int *s2255_debug = &debug; |
320 | 317 | ||
@@ -1534,31 +1531,22 @@ static int vidioc_s_parm(struct file *file, void *priv, | |||
1534 | static int s2255_open(struct file *file) | 1531 | static int s2255_open(struct file *file) |
1535 | { | 1532 | { |
1536 | int minor = video_devdata(file)->minor; | 1533 | int minor = video_devdata(file)->minor; |
1537 | struct s2255_dev *h, *dev = NULL; | 1534 | struct video_device *vdev = video_devdata(file); |
1535 | struct s2255_dev *dev = video_drvdata(file); | ||
1538 | struct s2255_fh *fh; | 1536 | struct s2255_fh *fh; |
1539 | struct list_head *list; | 1537 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1540 | enum v4l2_buf_type type = 0; | ||
1541 | int i = 0; | 1538 | int i = 0; |
1542 | int cur_channel = -1; | 1539 | int cur_channel = -1; |
1543 | int state; | 1540 | int state; |
1544 | dprintk(1, "s2255: open called (minor=%d)\n", minor); | 1541 | dprintk(1, "s2255: open called (minor=%d)\n", minor); |
1545 | 1542 | ||
1546 | lock_kernel(); | 1543 | lock_kernel(); |
1547 | list_for_each(list, &s2255_devlist) { | ||
1548 | h = list_entry(list, struct s2255_dev, s2255_devlist); | ||
1549 | for (i = 0; i < MAX_CHANNELS; i++) { | ||
1550 | if (h->vdev[i]->minor == minor) { | ||
1551 | cur_channel = i; | ||
1552 | dev = h; | ||
1553 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1554 | } | ||
1555 | } | ||
1556 | } | ||
1557 | 1544 | ||
1558 | if ((NULL == dev) || (cur_channel == -1)) { | 1545 | for (i = 0; i < MAX_CHANNELS; i++) { |
1559 | unlock_kernel(); | 1546 | if (dev->vdev[i] == vdev) { |
1560 | printk(KERN_INFO "s2255: openv4l no dev\n"); | 1547 | cur_channel = i; |
1561 | return -ENODEV; | 1548 | break; |
1549 | } | ||
1562 | } | 1550 | } |
1563 | 1551 | ||
1564 | if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING) { | 1552 | if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING) { |
@@ -1699,7 +1687,6 @@ static unsigned int s2255_poll(struct file *file, | |||
1699 | static void s2255_destroy(struct kref *kref) | 1687 | static void s2255_destroy(struct kref *kref) |
1700 | { | 1688 | { |
1701 | struct s2255_dev *dev = to_s2255_dev(kref); | 1689 | struct s2255_dev *dev = to_s2255_dev(kref); |
1702 | struct list_head *list; | ||
1703 | int i; | 1690 | int i; |
1704 | if (!dev) { | 1691 | if (!dev) { |
1705 | printk(KERN_ERR "s2255drv: kref problem\n"); | 1692 | printk(KERN_ERR "s2255drv: kref problem\n"); |
@@ -1733,10 +1720,6 @@ static void s2255_destroy(struct kref *kref) | |||
1733 | usb_put_dev(dev->udev); | 1720 | usb_put_dev(dev->udev); |
1734 | dprintk(1, "%s", __func__); | 1721 | dprintk(1, "%s", __func__); |
1735 | 1722 | ||
1736 | while (!list_empty(&s2255_devlist)) { | ||
1737 | list = s2255_devlist.next; | ||
1738 | list_del(list); | ||
1739 | } | ||
1740 | mutex_unlock(&dev->open_lock); | 1723 | mutex_unlock(&dev->open_lock); |
1741 | kfree(dev); | 1724 | kfree(dev); |
1742 | } | 1725 | } |
@@ -1843,7 +1826,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev) | |||
1843 | int cur_nr = video_nr; | 1826 | int cur_nr = video_nr; |
1844 | 1827 | ||
1845 | /* initialize all video 4 linux */ | 1828 | /* initialize all video 4 linux */ |
1846 | list_add_tail(&dev->s2255_devlist, &s2255_devlist); | ||
1847 | /* register 4 video devices */ | 1829 | /* register 4 video devices */ |
1848 | for (i = 0; i < MAX_CHANNELS; i++) { | 1830 | for (i = 0; i < MAX_CHANNELS; i++) { |
1849 | INIT_LIST_HEAD(&dev->vidq[i].active); | 1831 | INIT_LIST_HEAD(&dev->vidq[i].active); |
@@ -1853,6 +1835,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) | |||
1853 | dev->vdev[i] = video_device_alloc(); | 1835 | dev->vdev[i] = video_device_alloc(); |
1854 | memcpy(dev->vdev[i], &template, sizeof(struct video_device)); | 1836 | memcpy(dev->vdev[i], &template, sizeof(struct video_device)); |
1855 | dev->vdev[i]->parent = &dev->interface->dev; | 1837 | dev->vdev[i]->parent = &dev->interface->dev; |
1838 | video_set_drvdata(dev->vdev[i], dev); | ||
1856 | if (video_nr == -1) | 1839 | if (video_nr == -1) |
1857 | ret = video_register_device(dev->vdev[i], | 1840 | ret = video_register_device(dev->vdev[i], |
1858 | VFL_TYPE_GRABBER, | 1841 | VFL_TYPE_GRABBER, |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index b910df94ed72..9f85e917f9f3 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -797,6 +797,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev, | |||
797 | vfd->debug = video_debug; | 797 | vfd->debug = video_debug; |
798 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", | 798 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", |
799 | dev->name, type, saa7134_boards[dev->board].name); | 799 | dev->name, type, saa7134_boards[dev->board].name); |
800 | video_set_drvdata(vfd, dev); | ||
800 | return vfd; | 801 | return vfd; |
801 | } | 802 | } |
802 | 803 | ||
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index abc1d0bf5837..1de27af54590 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -87,17 +87,9 @@ static int ts_init_encoder(struct saa7134_dev* dev) | |||
87 | static int ts_open(struct file *file) | 87 | static int ts_open(struct file *file) |
88 | { | 88 | { |
89 | int minor = video_devdata(file)->minor; | 89 | int minor = video_devdata(file)->minor; |
90 | struct saa7134_dev *dev; | 90 | struct saa7134_dev *dev = video_drvdata(file); |
91 | int err; | 91 | int err; |
92 | 92 | ||
93 | lock_kernel(); | ||
94 | list_for_each_entry(dev, &saa7134_devlist, devlist) | ||
95 | if (dev->empress_dev && dev->empress_dev->minor == minor) | ||
96 | goto found; | ||
97 | unlock_kernel(); | ||
98 | return -ENODEV; | ||
99 | found: | ||
100 | |||
101 | dprintk("open minor=%d\n",minor); | 93 | dprintk("open minor=%d\n",minor); |
102 | err = -EBUSY; | 94 | err = -EBUSY; |
103 | if (!mutex_trylock(&dev->empress_tsq.vb_lock)) | 95 | if (!mutex_trylock(&dev->empress_tsq.vb_lock)) |
@@ -531,6 +523,7 @@ static int empress_init(struct saa7134_dev *dev) | |||
531 | 523 | ||
532 | INIT_WORK(&dev->empress_workqueue, empress_signal_update); | 524 | INIT_WORK(&dev->empress_workqueue, empress_signal_update); |
533 | 525 | ||
526 | video_set_drvdata(dev->empress_dev, dev); | ||
534 | err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, | 527 | err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, |
535 | empress_nr[dev->nr]); | 528 | empress_nr[dev->nr]); |
536 | if (err < 0) { | 529 | if (err < 0) { |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 35f8daa3a359..bcca5a479817 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -1327,29 +1327,23 @@ static int saa7134_resource(struct saa7134_fh *fh) | |||
1327 | static int video_open(struct file *file) | 1327 | static int video_open(struct file *file) |
1328 | { | 1328 | { |
1329 | int minor = video_devdata(file)->minor; | 1329 | int minor = video_devdata(file)->minor; |
1330 | struct saa7134_dev *dev; | 1330 | struct video_device *vdev = video_devdata(file); |
1331 | struct saa7134_dev *dev = video_drvdata(file); | ||
1331 | struct saa7134_fh *fh; | 1332 | struct saa7134_fh *fh; |
1332 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1333 | enum v4l2_buf_type type = 0; |
1333 | int radio = 0; | 1334 | int radio = 0; |
1334 | 1335 | ||
1335 | mutex_lock(&saa7134_devlist_lock); | 1336 | switch (vdev->vfl_type) { |
1336 | list_for_each_entry(dev, &saa7134_devlist, devlist) { | 1337 | case VFL_TYPE_GRABBER: |
1337 | if (dev->video_dev && (dev->video_dev->minor == minor)) | 1338 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1338 | goto found; | 1339 | break; |
1339 | if (dev->radio_dev && (dev->radio_dev->minor == minor)) { | 1340 | case VFL_TYPE_VBI: |
1340 | radio = 1; | 1341 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
1341 | goto found; | 1342 | break; |
1342 | } | 1343 | case VFL_TYPE_RADIO: |
1343 | if (dev->vbi_dev && (dev->vbi_dev->minor == minor)) { | 1344 | radio = 1; |
1344 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | 1345 | break; |
1345 | goto found; | ||
1346 | } | ||
1347 | } | 1346 | } |
1348 | mutex_unlock(&saa7134_devlist_lock); | ||
1349 | return -ENODEV; | ||
1350 | |||
1351 | found: | ||
1352 | mutex_unlock(&saa7134_devlist_lock); | ||
1353 | 1347 | ||
1354 | dprintk("open minor=%d radio=%d type=%s\n",minor,radio, | 1348 | dprintk("open minor=%d radio=%d type=%s\n",minor,radio, |
1355 | v4l2_type_names[type]); | 1349 | v4l2_type_names[type]); |
diff --git a/drivers/staging/cx25821/cx25821-audups11.c b/drivers/staging/cx25821/cx25821-audups11.c index f78b8912d905..e1364d1c976e 100644 --- a/drivers/staging/cx25821/cx25821-audups11.c +++ b/drivers/staging/cx25821/cx25821-audups11.c | |||
@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | |||
103 | lock_kernel(); | ||
104 | list_for_each(list, &cx25821_devlist) { | ||
105 | h = list_entry(list, struct cx25821_dev, devlist); | ||
106 | |||
107 | if (h->video_dev[SRAM_CH11] | ||
108 | && h->video_dev[SRAM_CH11]->minor == minor) { | ||
109 | dev = h; | ||
110 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (NULL == dev) { | ||
115 | unlock_kernel(); | ||
116 | return -ENODEV; | ||
117 | } | ||
118 | 101 | ||
119 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 102 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
120 | 103 | ||
121 | /* allocate + initialize per filehandle data */ | 104 | /* allocate + initialize per filehandle data */ |
122 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 105 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
123 | if (NULL == fh) { | 106 | if (NULL == fh) |
124 | unlock_kernel(); | ||
125 | return -ENOMEM; | 107 | return -ENOMEM; |
126 | } | 108 | |
109 | lock_kernel(); | ||
127 | 110 | ||
128 | file->private_data = fh; | 111 | file->private_data = fh; |
129 | fh->dev = dev; | 112 | fh->dev = dev; |
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 156e332ce002..c0c99c0fd437 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c | |||
@@ -189,6 +189,7 @@ struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, | |||
189 | vfd->release = video_device_release; | 189 | vfd->release = video_device_release; |
190 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, | 190 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, |
191 | cx25821_boards[dev->board].name); | 191 | cx25821_boards[dev->board].name); |
192 | video_set_drvdata(vfd, dev); | ||
192 | return vfd; | 193 | return vfd; |
193 | } | 194 | } |
194 | 195 | ||
diff --git a/drivers/staging/cx25821/cx25821-video0.c b/drivers/staging/cx25821/cx25821-video0.c index 950fac1d7003..eb0fe8175517 100644 --- a/drivers/staging/cx25821/cx25821-video0.c +++ b/drivers/staging/cx25821/cx25821-video0.c | |||
@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH00] | ||
109 | && h->video_dev[SRAM_CH00]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
128 | 111 | ||
129 | file->private_data = fh; | 112 | file->private_data = fh; |
130 | fh->dev = dev; | 113 | fh->dev = dev; |
diff --git a/drivers/staging/cx25821/cx25821-video1.c b/drivers/staging/cx25821/cx25821-video1.c index a4dddc684adf..96ec2385bcdf 100644 --- a/drivers/staging/cx25821/cx25821-video1.c +++ b/drivers/staging/cx25821/cx25821-video1.c | |||
@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH01] | ||
109 | && h->video_dev[SRAM_CH01]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
128 | 111 | ||
129 | file->private_data = fh; | 112 | file->private_data = fh; |
130 | fh->dev = dev; | 113 | fh->dev = dev; |
diff --git a/drivers/staging/cx25821/cx25821-video2.c b/drivers/staging/cx25821/cx25821-video2.c index 8e04e253f5d9..e659603c3fbe 100644 --- a/drivers/staging/cx25821/cx25821-video2.c +++ b/drivers/staging/cx25821/cx25821-video2.c | |||
@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH02] | ||
109 | && h->video_dev[SRAM_CH02]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
111 | |||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
130 | fh->type = type; | 114 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-video3.c b/drivers/staging/cx25821/cx25821-video3.c index 8801a8ead904..873f0f83a893 100644 --- a/drivers/staging/cx25821/cx25821-video3.c +++ b/drivers/staging/cx25821/cx25821-video3.c | |||
@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH03] | ||
109 | && h->video_dev[SRAM_CH03]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
111 | |||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
130 | fh->type = type; | 114 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-video4.c b/drivers/staging/cx25821/cx25821-video4.c index ab0d747138ad..c00e3f84e8eb 100644 --- a/drivers/staging/cx25821/cx25821-video4.c +++ b/drivers/staging/cx25821/cx25821-video4.c | |||
@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH04] | ||
109 | && h->video_dev[SRAM_CH04]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
111 | |||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
130 | fh->type = type; | 114 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-video5.c b/drivers/staging/cx25821/cx25821-video5.c index 7ef0b971f5cf..06396b86e98b 100644 --- a/drivers/staging/cx25821/cx25821-video5.c +++ b/drivers/staging/cx25821/cx25821-video5.c | |||
@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH05] | ||
109 | && h->video_dev[SRAM_CH05]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
111 | |||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
130 | fh->type = type; | 114 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-video6.c b/drivers/staging/cx25821/cx25821-video6.c index 3c41b49e2ea9..c5410c1558e4 100644 --- a/drivers/staging/cx25821/cx25821-video6.c +++ b/drivers/staging/cx25821/cx25821-video6.c | |||
@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->video_dev[SRAM_CH06] | ||
109 | && h->video_dev[SRAM_CH06]->minor == minor) { | ||
110 | dev = h; | ||
111 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | if (NULL == dev) { | ||
116 | unlock_kernel(); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | |||
120 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
121 | 104 | ||
122 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
123 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
124 | if (NULL == fh) { | 107 | if (NULL == fh) |
125 | unlock_kernel(); | ||
126 | return -ENOMEM; | 108 | return -ENOMEM; |
127 | } | 109 | |
110 | lock_kernel(); | ||
111 | |||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
130 | fh->type = type; | 114 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-video7.c b/drivers/staging/cx25821/cx25821-video7.c index 625c9b78a9cf..274977eefcaf 100644 --- a/drivers/staging/cx25821/cx25821-video7.c +++ b/drivers/staging/cx25821/cx25821-video7.c | |||
@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
94 | static int video_open(struct file *file) | 94 | static int video_open(struct file *file) |
95 | { | 95 | { |
96 | int minor = video_devdata(file)->minor; | 96 | int minor = video_devdata(file)->minor; |
97 | struct cx25821_dev *h, *dev = NULL; | 97 | struct cx25821_dev *dev = video_drvdata(file); |
98 | struct cx25821_fh *fh; | 98 | struct cx25821_fh *fh; |
99 | struct list_head *list; | 99 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
100 | enum v4l2_buf_type type = 0; | ||
101 | u32 pix_format; | 100 | u32 pix_format; |
102 | 101 | ||
103 | lock_kernel(); | ||
104 | list_for_each(list, &cx25821_devlist) { | ||
105 | h = list_entry(list, struct cx25821_dev, devlist); | ||
106 | |||
107 | if (h->video_dev[SRAM_CH07] | ||
108 | && h->video_dev[SRAM_CH07]->minor == minor) { | ||
109 | dev = h; | ||
110 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (NULL == dev) { | ||
115 | unlock_kernel(); | ||
116 | return -ENODEV; | ||
117 | } | ||
118 | |||
119 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 102 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
120 | 103 | ||
121 | /* allocate + initialize per filehandle data */ | 104 | /* allocate + initialize per filehandle data */ |
122 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 105 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
123 | if (NULL == fh) { | 106 | if (NULL == fh) |
124 | unlock_kernel(); | ||
125 | return -ENOMEM; | 107 | return -ENOMEM; |
126 | } | 108 | |
109 | lock_kernel(); | ||
110 | |||
127 | file->private_data = fh; | 111 | file->private_data = fh; |
128 | fh->dev = dev; | 112 | fh->dev = dev; |
129 | fh->type = type; | 113 | fh->type = type; |
diff --git a/drivers/staging/cx25821/cx25821-videoioctl.c b/drivers/staging/cx25821/cx25821-videoioctl.c index 2a312ce78c63..42ea8bfa9ed8 100644 --- a/drivers/staging/cx25821/cx25821-videoioctl.c +++ b/drivers/staging/cx25821/cx25821-videoioctl.c | |||
@@ -95,35 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | u32 pix_format; | 101 | u32 pix_format; |
103 | 102 | ||
104 | lock_kernel(); | ||
105 | list_for_each(list, &cx25821_devlist) { | ||
106 | h = list_entry(list, struct cx25821_dev, devlist); | ||
107 | |||
108 | if (h->ioctl_dev && h->ioctl_dev->minor == minor) { | ||
109 | dev = h; | ||
110 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (NULL == dev) { | ||
115 | unlock_kernel(); | ||
116 | return -ENODEV; | ||
117 | } | ||
118 | |||
119 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 103 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
120 | 104 | ||
121 | /* allocate + initialize per filehandle data */ | 105 | /* allocate + initialize per filehandle data */ |
122 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 106 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
123 | if (NULL == fh) { | 107 | if (NULL == fh) |
124 | unlock_kernel(); | ||
125 | return -ENOMEM; | 108 | return -ENOMEM; |
126 | } | 109 | |
110 | lock_kernel(); | ||
127 | 111 | ||
128 | file->private_data = fh; | 112 | file->private_data = fh; |
129 | fh->dev = dev; | 113 | fh->dev = dev; |
diff --git a/drivers/staging/cx25821/cx25821-vidups10.c b/drivers/staging/cx25821/cx25821-vidups10.c index 77b63b060405..4e0033fa205b 100644 --- a/drivers/staging/cx25821/cx25821-vidups10.c +++ b/drivers/staging/cx25821/cx25821-vidups10.c | |||
@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | |||
103 | lock_kernel(); | ||
104 | list_for_each(list, &cx25821_devlist) { | ||
105 | h = list_entry(list, struct cx25821_dev, devlist); | ||
106 | |||
107 | if (h->video_dev[SRAM_CH10] | ||
108 | && h->video_dev[SRAM_CH10]->minor == minor) { | ||
109 | dev = h; | ||
110 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (NULL == dev) { | ||
115 | unlock_kernel(); | ||
116 | return -ENODEV; | ||
117 | } | ||
118 | 101 | ||
119 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 102 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
120 | 103 | ||
121 | /* allocate + initialize per filehandle data */ | 104 | /* allocate + initialize per filehandle data */ |
122 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 105 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
123 | if (NULL == fh) { | 106 | if (NULL == fh) |
124 | unlock_kernel(); | ||
125 | return -ENOMEM; | 107 | return -ENOMEM; |
126 | } | 108 | |
109 | lock_kernel(); | ||
127 | 110 | ||
128 | file->private_data = fh; | 111 | file->private_data = fh; |
129 | fh->dev = dev; | 112 | fh->dev = dev; |
diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c index 75c8c1eed2da..67fc082e3086 100644 --- a/drivers/staging/cx25821/cx25821-vidups9.c +++ b/drivers/staging/cx25821/cx25821-vidups9.c | |||
@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
95 | static int video_open(struct file *file) | 95 | static int video_open(struct file *file) |
96 | { | 96 | { |
97 | int minor = video_devdata(file)->minor; | 97 | int minor = video_devdata(file)->minor; |
98 | struct cx25821_dev *h, *dev = NULL; | 98 | struct cx25821_dev *dev = video_drvdata(file); |
99 | struct cx25821_fh *fh; | 99 | struct cx25821_fh *fh; |
100 | struct list_head *list; | 100 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
101 | enum v4l2_buf_type type = 0; | ||
102 | |||
103 | lock_kernel(); | ||
104 | list_for_each(list, &cx25821_devlist) { | ||
105 | h = list_entry(list, struct cx25821_dev, devlist); | ||
106 | |||
107 | if (h->video_dev[SRAM_CH09] | ||
108 | && h->video_dev[SRAM_CH09]->minor == minor) { | ||
109 | dev = h; | ||
110 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (NULL == dev) { | ||
115 | unlock_kernel(); | ||
116 | return -ENODEV; | ||
117 | } | ||
118 | 101 | ||
119 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 102 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
120 | 103 | ||
121 | /* allocate + initialize per filehandle data */ | 104 | /* allocate + initialize per filehandle data */ |
122 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 105 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
123 | if (NULL == fh) { | 106 | if (NULL == fh) |
124 | unlock_kernel(); | ||
125 | return -ENOMEM; | 107 | return -ENOMEM; |
126 | } | 108 | |
109 | lock_kernel(); | ||
127 | 110 | ||
128 | file->private_data = fh; | 111 | file->private_data = fh; |
129 | fh->dev = dev; | 112 | fh->dev = dev; |