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/cx23885 | |
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/cx23885')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-417.c | 22 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885-core.c | 11 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885-video.c | 44 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885.h | 3 |
4 files changed, 21 insertions, 59 deletions
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 */ |