aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2009-12-10 08:44:04 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-15 21:17:56 -0500
commit63b0d5ad20365edf8baf96cdbb8e7faf62501286 (patch)
tree9a12041cab48051834ee67d0de358443464e5d94 /drivers/media/video/cx88
parentf0813b4c9f7ffbeaddcba1c08a1812f7ff30e1b7 (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/cx88')
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c15
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c15
-rw-r--r--drivers/media/video/cx88/cx88-video.c43
-rw-r--r--drivers/media/video/cx88/cx88.h2
4 files changed, 20 insertions, 55 deletions
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)
1049static int mpeg_open(struct file *file) 1049static 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)
585struct 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}
595EXPORT_SYMBOL(cx8802_get_device);
596#endif
597
598struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) 583struct 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
80static 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)
754static int video_open(struct file *file) 750static 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
424struct cx8800_dev { 424struct 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
671int cx8802_register_driver(struct cx8802_driver *drv); 670int cx8802_register_driver(struct cx8802_driver *drv);
672int cx8802_unregister_driver(struct cx8802_driver *drv); 671int cx8802_unregister_driver(struct cx8802_driver *drv);
673struct cx8802_dev *cx8802_get_device(int minor);
674struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); 672struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
675 673
676/* ----------------------------------------------------------- */ 674/* ----------------------------------------------------------- */