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/media/video/s2255drv.c | |
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/media/video/s2255drv.c')
-rw-r--r-- | drivers/media/video/s2255drv.c | 35 |
1 files changed, 9 insertions, 26 deletions
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, |