Commit 63b0d5ad authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f0813b4c
...@@ -195,42 +195,24 @@ void saa7146_buffer_timeout(unsigned long data) ...@@ -195,42 +195,24 @@ void saa7146_buffer_timeout(unsigned long data)
static int fops_open(struct file *file) static int fops_open(struct file *file)
{ {
unsigned int minor = video_devdata(file)->minor; unsigned int minor = video_devdata(file)->minor;
struct saa7146_dev *h = NULL, *dev = NULL; struct video_device *vdev = video_devdata(file);
struct list_head *list; struct saa7146_dev *dev = video_drvdata(file);
struct saa7146_fh *fh = NULL; struct saa7146_fh *fh = NULL;
int result = 0; int result = 0;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type;
DEB_EE(("file:%p, minor:%d\n", file, minor)); DEB_EE(("file:%p, minor:%d\n", file, minor));
if (mutex_lock_interruptible(&saa7146_devices_lock)) if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
list_for_each(list,&saa7146_devices) {
h = list_entry(list, struct saa7146_dev, item);
if( NULL == h->vv_data ) {
DEB_D(("device %p has not registered video devices.\n",h));
continue;
}
DEB_D(("trying: %p @ major %d,%d\n",h,h->vv_data->video_minor,h->vv_data->vbi_minor));
if (h->vv_data->video_minor == minor) {
dev = h;
}
if (h->vv_data->vbi_minor == minor) {
type = V4L2_BUF_TYPE_VBI_CAPTURE;
dev = h;
}
}
if (NULL == dev) {
DEB_S(("no such video device.\n"));
result = -ENODEV;
goto out;
}
DEB_D(("using: %p\n",dev)); DEB_D(("using: %p\n",dev));
type = vdev->vfl_type == VFL_TYPE_GRABBER
? V4L2_BUF_TYPE_VIDEO_CAPTURE
: V4L2_BUF_TYPE_VBI_CAPTURE;
/* check if an extension is registered */ /* check if an extension is registered */
if( NULL == dev->ext ) { if( NULL == dev->ext ) {
DEB_S(("no extension registered for this device.\n")); DEB_S(("no extension registered for this device.\n"));
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "au0828.h" #include "au0828.h"
#include "au0828-reg.h" #include "au0828-reg.h"
static LIST_HEAD(au0828_devlist);
static DEFINE_MUTEX(au0828_sysfs_lock); static DEFINE_MUTEX(au0828_sysfs_lock);
#define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1) #define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1)
...@@ -693,10 +692,8 @@ void au0828_analog_unregister(struct au0828_dev *dev) ...@@ -693,10 +692,8 @@ void au0828_analog_unregister(struct au0828_dev *dev)
dprintk(1, "au0828_release_resources called\n"); dprintk(1, "au0828_release_resources called\n");
mutex_lock(&au0828_sysfs_lock); mutex_lock(&au0828_sysfs_lock);
if (dev->vdev) { if (dev->vdev)
list_del(&dev->au0828list);
video_unregister_device(dev->vdev); video_unregister_device(dev->vdev);
}
if (dev->vbi_dev) if (dev->vbi_dev)
video_unregister_device(dev->vbi_dev); video_unregister_device(dev->vbi_dev);
...@@ -737,29 +734,15 @@ static void res_free(struct au0828_fh *fh) ...@@ -737,29 +734,15 @@ static void res_free(struct au0828_fh *fh)
static int au0828_v4l2_open(struct file *filp) static int au0828_v4l2_open(struct file *filp)
{ {
int minor = video_devdata(filp)->minor;
int ret = 0; int ret = 0;
struct au0828_dev *h, *dev = NULL; struct au0828_dev *dev = video_drvdata(filp);
struct au0828_fh *fh; struct au0828_fh *fh;
int type = 0; int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct list_head *list;
list_for_each(list, &au0828_devlist) {
h = list_entry(list, struct au0828_dev, au0828list);
if (h->vdev->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
#ifdef VBI_IS_WORKING #ifdef VBI_IS_WORKING
if (h->vbi_dev->minor == minor) { if (video_devdata(filp)->vfl_type == VFL_TYPE_GRABBER)
dev = h; type = V4L2_BUF_TYPE_VBI_CAPTURE;
type = V4L2_BUF_TYPE_VBI_CAPTURE;
}
#endif #endif
}
if (NULL == dev)
return -ENODEV;
fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL); fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
...@@ -1676,25 +1659,23 @@ int au0828_analog_register(struct au0828_dev *dev, ...@@ -1676,25 +1659,23 @@ int au0828_analog_register(struct au0828_dev *dev,
strcpy(dev->vbi_dev->name, "au0828a vbi"); strcpy(dev->vbi_dev->name, "au0828a vbi");
#endif #endif
list_add_tail(&dev->au0828list, &au0828_devlist);
/* Register the v4l2 device */ /* Register the v4l2 device */
video_set_drvdata(dev->vdev, dev);
retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1); retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1);
if (retval != 0) { if (retval != 0) {
dprintk(1, "unable to register video device (error = %d).\n", dprintk(1, "unable to register video device (error = %d).\n",
retval); retval);
list_del(&dev->au0828list);
video_device_release(dev->vdev); video_device_release(dev->vdev);
return -ENODEV; return -ENODEV;
} }
#ifdef VBI_IS_WORKING #ifdef VBI_IS_WORKING
/* Register the vbi device */ /* Register the vbi device */
video_set_drvdata(dev->vbi_dev, dev);
retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1); retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1);
if (retval != 0) { if (retval != 0) {
dprintk(1, "unable to register vbi device (error = %d).\n", dprintk(1, "unable to register vbi device (error = %d).\n",
retval); retval);
list_del(&dev->au0828list);
video_device_release(dev->vbi_dev); video_device_release(dev->vbi_dev);
video_device_release(dev->vdev); video_device_release(dev->vdev);
return -ENODEV; return -ENODEV;
......
...@@ -192,7 +192,6 @@ struct au0828_dev { ...@@ -192,7 +192,6 @@ struct au0828_dev {
struct au0828_dvb dvb; struct au0828_dvb dvb;
/* Analog */ /* Analog */
struct list_head au0828list;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
int users; int users;
unsigned int stream_on:1; /* Locks streams */ unsigned int stream_on:1; /* Locks streams */
......
...@@ -66,32 +66,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); ...@@ -66,32 +66,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
static LIST_HEAD(cx231xx_devlist); static LIST_HEAD(cx231xx_devlist);
static DEFINE_MUTEX(cx231xx_devlist_mutex); static DEFINE_MUTEX(cx231xx_devlist_mutex);
struct cx231xx *cx231xx_get_device(int minor,
enum v4l2_buf_type *fh_type, int *has_radio)
{
struct cx231xx *h, *dev = NULL;
*fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
*has_radio = 0;
mutex_lock(&cx231xx_devlist_mutex);
list_for_each_entry(h, &cx231xx_devlist, devlist) {
if (h->vdev->minor == minor)
dev = h;
if (h->vbi_dev->minor == minor) {
dev = h;
*fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
}
if (h->radio_dev && h->radio_dev->minor == minor) {
dev = h;
*has_radio = 1;
}
}
mutex_unlock(&cx231xx_devlist_mutex);
return dev;
}
/* /*
* cx231xx_realease_resources() * cx231xx_realease_resources()
* unregisters the v4l2,i2c and usb devices * unregisters the v4l2,i2c and usb devices
......
...@@ -1918,13 +1918,22 @@ static int cx231xx_v4l2_open(struct file *filp) ...@@ -1918,13 +1918,22 @@ static int cx231xx_v4l2_open(struct file *filp)
{ {
int minor = video_devdata(filp)->minor; int minor = video_devdata(filp)->minor;
int errCode = 0, radio = 0; int errCode = 0, radio = 0;
struct cx231xx *dev = NULL; struct video_device *vdev = video_devdata(filp);
struct cx231xx *dev = video_drvdata(filp);
struct cx231xx_fh *fh; struct cx231xx_fh *fh;
enum v4l2_buf_type fh_type = 0; enum v4l2_buf_type fh_type = 0;
dev = cx231xx_get_device(minor, &fh_type, &radio); switch (vdev->vfl_type) {
if (NULL == dev) case VFL_TYPE_GRABBER:
return -ENODEV; fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
break;
case VFL_TYPE_VBI:
fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
break;
case VFL_TYPE_RADIO:
radio = 1;
break;
}
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
...@@ -2326,6 +2335,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, ...@@ -2326,6 +2335,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
video_set_drvdata(vfd, dev);
return vfd; return vfd;
} }
......
...@@ -689,8 +689,6 @@ void cx231xx_release_analog_resources(struct cx231xx *dev); ...@@ -689,8 +689,6 @@ void cx231xx_release_analog_resources(struct cx231xx *dev);
int cx231xx_register_analog_devices(struct cx231xx *dev); int cx231xx_register_analog_devices(struct cx231xx *dev);
void cx231xx_remove_from_devlist(struct cx231xx *dev); void cx231xx_remove_from_devlist(struct cx231xx *dev);
void cx231xx_add_into_devlist(struct cx231xx *dev); void cx231xx_add_into_devlist(struct cx231xx *dev);
struct cx231xx *cx231xx_get_device(int minor,
enum v4l2_buf_type *fh_type, int *has_radio);
void cx231xx_init_extension(struct cx231xx *dev); void cx231xx_init_extension(struct cx231xx *dev);
void cx231xx_close_extension(struct cx231xx *dev); void cx231xx_close_extension(struct cx231xx *dev);
......
...@@ -1568,28 +1568,11 @@ static int vidioc_queryctrl(struct file *file, void *priv, ...@@ -1568,28 +1568,11 @@ static int vidioc_queryctrl(struct file *file, void *priv,
static int mpeg_open(struct file *file) static int mpeg_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; struct cx23885_dev *dev = video_drvdata(file);
struct cx23885_dev *h, *dev = NULL;
struct list_head *list;
struct cx23885_fh *fh; struct cx23885_fh *fh;
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
lock_kernel();
list_for_each(list, &cx23885_devlist) {
h = list_entry(list, struct cx23885_dev, devlist);
if (h->v4l_device &&
h->v4l_device->minor == minor) {
dev = h;
break;
}
}
if (dev == NULL) {
unlock_kernel();
return -ENODEV;
}
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
...@@ -1597,6 +1580,8 @@ static int mpeg_open(struct file *file) ...@@ -1597,6 +1580,8 @@ static int mpeg_open(struct file *file)
return -ENOMEM; return -ENOMEM;
} }
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
...@@ -1803,6 +1788,7 @@ int cx23885_417_register(struct cx23885_dev *dev) ...@@ -1803,6 +1788,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
/* Allocate and initialize V4L video device */ /* Allocate and initialize V4L video device */
dev->v4l_device = cx23885_video_dev_alloc(tsport, dev->v4l_device = cx23885_video_dev_alloc(tsport,
dev->pci, &cx23885_mpeg_template, "mpeg"); dev->pci, &cx23885_mpeg_template, "mpeg");
video_set_drvdata(dev->v4l_device, dev);
err = video_register_device(dev->v4l_device, err = video_register_device(dev->v4l_device,
VFL_TYPE_GRABBER, -1); VFL_TYPE_GRABBER, -1);
if (err < 0) { if (err < 0) {
......
...@@ -55,9 +55,6 @@ MODULE_PARM_DESC(card, "card type"); ...@@ -55,9 +55,6 @@ MODULE_PARM_DESC(card, "card type");
static unsigned int cx23885_devcount; static unsigned int cx23885_devcount;
static DEFINE_MUTEX(devlist);
LIST_HEAD(cx23885_devlist);
#define NO_SYNC_LINE (-1U) #define NO_SYNC_LINE (-1U)
/* FIXME, these allocations will change when /* FIXME, these allocations will change when
...@@ -785,10 +782,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) ...@@ -785,10 +782,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
dev->nr = cx23885_devcount++; dev->nr = cx23885_devcount++;
sprintf(dev->name, "cx23885[%d]", dev->nr); sprintf(dev->name, "cx23885[%d]", dev->nr);
mutex_lock(&devlist);
list_add_tail(&dev->devlist, &cx23885_devlist);
mutex_unlock(&devlist);
/* Configure the internal memory */ /* Configure the internal memory */
if (dev->pci->device == 0x8880) { if (dev->pci->device == 0x8880) {
/* Could be 887 or 888, assume a default */ /* Could be 887 or 888, assume a default */
...@@ -2008,10 +2001,6 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev) ...@@ -2008,10 +2001,6 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev)
/* unregister stuff */ /* unregister stuff */
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
mutex_lock(&devlist);
list_del(&dev->devlist);
mutex_unlock(&devlist);
cx23885_dev_unregister(dev); cx23885_dev_unregister(dev);
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
kfree(dev); kfree(dev);
......
...@@ -323,6 +323,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, ...@@ -323,6 +323,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
vfd->release = video_device_release; vfd->release = video_device_release;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
dev->name, type, cx23885_boards[dev->board].name); dev->name, type, cx23885_boards[dev->board].name);
video_set_drvdata(vfd, dev);
return vfd; return vfd;
} }
...@@ -717,34 +718,22 @@ static int get_resource(struct cx23885_fh *fh) ...@@ -717,34 +718,22 @@ static int get_resource(struct cx23885_fh *fh)
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx23885_dev *h, *dev = NULL; struct video_device *vdev = video_devdata(file);
struct cx23885_dev *dev = video_drvdata(file);
struct cx23885_fh *fh; struct cx23885_fh *fh;
struct list_head *list;
enum v4l2_buf_type type = 0; enum v4l2_buf_type type = 0;
int radio = 0; int radio = 0;
lock_kernel(); switch (vdev->vfl_type) {
list_for_each(list, &cx23885_devlist) { case VFL_TYPE_GRABBER:
h = list_entry(list, struct cx23885_dev, devlist); type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (h->video_dev && break;
h->video_dev->minor == minor) { case VFL_TYPE_VBI:
dev = h; type = V4L2_BUF_TYPE_VBI_CAPTURE;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; break;
} case VFL_TYPE_RADIO:
if (h->vbi_dev && radio = 1;
h->vbi_dev->minor == minor) { break;
dev = h;
type = V4L2_BUF_TYPE_VBI_CAPTURE;
}
if (h->radio_dev &&
h->radio_dev->minor == minor) {
radio = 1;
dev = h;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
} }
dprintk(1, "open minor=%d radio=%d type=%s\n", dprintk(1, "open minor=%d radio=%d type=%s\n",
...@@ -752,10 +741,11 @@ static int video_open(struct file *file) ...@@ -752,10 +741,11 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->radio = radio; fh->radio = radio;
......
...@@ -303,7 +303,6 @@ struct cx23885_tsport { ...@@ -303,7 +303,6 @@ struct cx23885_tsport {
}; };
struct cx23885_dev { struct cx23885_dev {
struct list_head devlist;
atomic_t refcount; atomic_t refcount;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
...@@ -399,8 +398,6 @@ static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev) ...@@ -399,8 +398,6 @@ static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev)
extern struct v4l2_subdev *cx23885_find_hw(struct cx23885_dev *dev, u32 hw); extern struct v4l2_subdev *cx23885_find_hw(struct cx23885_dev *dev, u32 hw);
extern struct list_head cx23885_devlist;
#define SRAM_CH01 0 /* Video A */ #define SRAM_CH01 0 /* Video A */
#define SRAM_CH02 1 /* VBI A */ #define SRAM_CH02 1 /* VBI A */
#define SRAM_CH03 2 /* Video B */ #define SRAM_CH03 2 /* Video B */
......
...@@ -1049,20 +1049,14 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) ...@@ -1049,20 +1049,14 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
static int mpeg_open(struct file *file) static int mpeg_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx8802_dev *dev = NULL; struct cx8802_dev *dev = video_drvdata(file);
struct cx8802_fh *fh; struct cx8802_fh *fh;
struct cx8802_driver *drv = NULL; struct cx8802_driver *drv = NULL;
int err; int err;
lock_kernel();
dev = cx8802_get_device(minor);
dprintk( 1, "%s\n", __func__); dprintk( 1, "%s\n", __func__);
if (dev == NULL) { lock_kernel();
unlock_kernel();
return -ENODEV;
}
/* Make sure we can acquire the hardware */ /* Make sure we can acquire the hardware */
drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
...@@ -1129,10 +1123,6 @@ static int mpeg_release(struct file *file) ...@@ -1129,10 +1123,6 @@ static int mpeg_release(struct file *file)
kfree(fh); kfree(fh);
/* Make sure we release the hardware */ /* Make sure we release the hardware */
dev = cx8802_get_device(video_devdata(file)->minor);
if (dev == NULL)
return -ENODEV;
drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
if (drv) if (drv)
drv->request_release(drv); drv->request_release(drv);
...@@ -1290,6 +1280,7 @@ static int blackbird_register_video(struct cx8802_dev *dev) ...@@ -1290,6 +1280,7 @@ static int blackbird_register_video(struct cx8802_dev *dev)
dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
&cx8802_mpeg_template,"mpeg"); &cx8802_mpeg_template,"mpeg");
video_set_drvdata(dev->mpeg_dev, dev);
err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
if (err < 0) { if (err < 0) {
printk(KERN_INFO "%s/2: can't register mpeg device\n", printk(KERN_INFO "%s/2: can't register mpeg device\n",
......
...@@ -580,21 +580,6 @@ static int cx8802_resume_common(struct pci_dev *pci_dev) ...@@ -580,21 +580,6 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
return 0; return 0;
} }
#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
struct cx8802_dev *cx8802_get_device(int minor)
{
struct cx8802_dev *dev;
list_for_each_entry(dev, &cx8802_devlist, devlist)
if (dev->mpeg_dev && dev->mpeg_dev->minor == minor)
return dev;
return NULL;
}
EXPORT_SYMBOL(cx8802_get_device);
#endif
struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype)
{ {
struct cx8802_driver *d; struct cx8802_driver *d;
......
...@@ -75,10 +75,6 @@ MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); ...@@ -75,10 +75,6 @@ MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
#define dprintk(level,fmt, arg...) if (video_debug >= level) \ #define dprintk(level,fmt, arg...) if (video_debug >= level) \
printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
/* ------------------------------------------------------------------ */
static LIST_HEAD(cx8800_devlist);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
/* static data */ /* static data */
...@@ -754,33 +750,27 @@ static int get_ressource(struct cx8800_fh *fh) ...@@ -754,33 +750,27 @@ static int get_ressource(struct cx8800_fh *fh)
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx8800_dev *h,*dev = NULL; struct video_device *vdev = video_devdata(file);
struct cx8800_dev *dev = video_drvdata(file);
struct cx88_core *core; struct cx88_core *core;
struct cx8800_fh *fh; struct cx8800_fh *fh;
enum v4l2_buf_type type = 0; enum v4l2_buf_type type = 0;
int radio = 0; int radio = 0;
lock_kernel(); switch (vdev->vfl_type) {
list_for_each_entry(h, &cx8800_devlist, devlist) { case VFL_TYPE_GRABBER:
if (h->video_dev->minor == minor) { type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dev = h; break;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; case VFL_TYPE_VBI:
} type = V4L2_BUF_TYPE_VBI_CAPTURE;
if (h->vbi_dev->minor == minor) { break;
dev = h; case VFL_TYPE_RADIO:
type = V4L2_BUF_TYPE_VBI_CAPTURE; radio = 1;
} break;
if (h->radio_dev &&
h->radio_dev->minor == minor) {
radio = 1;
dev = h;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
} }
lock_kernel();
core = dev->core; core = dev->core;
dprintk(1,"open minor=%d radio=%d type=%s\n", 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,6 +1899,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
/* register v4l devices */ /* register v4l devices */
dev->video_dev = cx88_vdev_init(core,dev->pci, dev->video_dev = cx88_vdev_init(core,dev->pci,
&cx8800_video_template,"video"); &cx8800_video_template,"video");
video_set_drvdata(dev->video_dev, dev);
err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
video_nr[core->nr]); video_nr[core->nr]);
if (err < 0) { if (err < 0) {
...@@ -1920,6 +1911,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1920,6 +1911,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
core->name, video_device_node_name(dev->video_dev)); core->name, video_device_node_name(dev->video_dev));
dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
video_set_drvdata(dev->vbi_dev, dev);
err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
vbi_nr[core->nr]); vbi_nr[core->nr]);
if (err < 0) { if (err < 0) {
...@@ -1933,6 +1925,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1933,6 +1925,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
if (core->board.radio.type == CX88_RADIO) { if (core->board.radio.type == CX88_RADIO) {
dev->radio_dev = cx88_vdev_init(core,dev->pci, dev->radio_dev = cx88_vdev_init(core,dev->pci,
&cx8800_radio_template,"radio"); &cx8800_radio_template,"radio");
video_set_drvdata(dev->radio_dev, dev);
err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
radio_nr[core->nr]); radio_nr[core->nr]);
if (err < 0) { if (err < 0) {
...@@ -1945,7 +1938,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1945,7 +1938,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
} }
/* everything worked */ /* everything worked */
list_add_tail(&dev->devlist,&cx8800_devlist);
pci_set_drvdata(pci_dev,dev); pci_set_drvdata(pci_dev,dev);
/* initial device configuration */ /* initial device configuration */
...@@ -2001,7 +1993,6 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) ...@@ -2001,7 +1993,6 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
/* free memory */ /* free memory */
btcx_riscmem_free(dev->pci,&dev->vidq.stopper); btcx_riscmem_free(dev->pci,&dev->vidq.stopper);
list_del(&dev->devlist);
cx88_core_put(core,dev->pci); cx88_core_put(core,dev->pci);
kfree(dev); kfree(dev);
} }
......
...@@ -423,7 +423,6 @@ struct cx8800_suspend_state { ...@@ -423,7 +423,6 @@ struct cx8800_suspend_state {
struct cx8800_dev { struct cx8800_dev {
struct cx88_core *core; struct cx88_core *core;
struct list_head devlist;
spinlock_t slock; spinlock_t slock;
/* various device info */ /* various device info */
...@@ -670,7 +669,6 @@ int cx88_audio_thread(void *data); ...@@ -670,7 +669,6 @@ int cx88_audio_thread(void *data);
int cx8802_register_driver(struct cx8802_driver *drv); int cx8802_register_driver(struct cx8802_driver *drv);
int cx8802_unregister_driver(struct cx8802_driver *drv); int cx8802_unregister_driver(struct cx8802_driver *drv);
struct cx8802_dev *cx8802_get_device(int minor);
struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
......
...@@ -2653,7 +2653,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, ...@@ -2653,7 +2653,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
INIT_LIST_HEAD(&dev->vbiq.active); INIT_LIST_HEAD(&dev->vbiq.active);
INIT_LIST_HEAD(&dev->vbiq.queued); INIT_LIST_HEAD(&dev->vbiq.queued);
if (dev->board.has_msp34xx) { if (dev->board.has_msp34xx) {
/* Send a reset to other chips via gpio */ /* Send a reset to other chips via gpio */
errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7); errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
......
...@@ -1136,34 +1136,6 @@ void em28xx_wake_i2c(struct em28xx *dev) ...@@ -1136,34 +1136,6 @@ void em28xx_wake_i2c(struct em28xx *dev)
static LIST_HEAD(em28xx_devlist); static LIST_HEAD(em28xx_devlist);
static DEFINE_MUTEX(em28xx_devlist_mutex); static DEFINE_MUTEX(em28xx_devlist_mutex);
struct em28xx *em28xx_get_device(int minor,
enum v4l2_buf_type *fh_type,
int *has_radio)
{
struct em28xx *h, *dev = NULL;
*fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
*has_radio = 0;
mutex_lock(&em28xx_devlist_mutex);
list_for_each_entry(h, &em28xx_devlist, devlist) {
if (h->vdev->minor == minor)
dev = h;
if (h->vbi_dev && h->vbi_dev->minor == minor) {
dev = h;
*fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
}
if (h->radio_dev &&
h->radio_dev->minor == minor) {
dev = h;
*has_radio = 1;
}
}
mutex_unlock(&em28xx_devlist_mutex);
return dev;
}
/* /*
* em28xx_realease_resources() * em28xx_realease_resources()
* unregisters the v4l2,i2c and usb devices * unregisters the v4l2,i2c and usb devices
......
...@@ -2082,16 +2082,24 @@ static int radio_queryctrl(struct file *file, void *priv, ...@@ -2082,16 +2082,24 @@ static int radio_queryctrl(struct file *file, void *priv,
static int em28xx_v4l2_open(struct file *filp) static int em28xx_v4l2_open(struct file *filp)
{ {
int minor = video_devdata(filp)->minor; int minor = video_devdata(filp)->minor;
int errCode = 0, radio; int errCode = 0, radio = 0;
struct em28xx *dev; struct video_device *vdev = video_devdata(filp);
enum v4l2_buf_type fh_type; struct em28xx *dev = video_drvdata(filp);
enum v4l2_buf_type fh_type = 0;
struct em28xx_fh *fh; struct em28xx_fh *fh;
enum v4l2_field field; enum v4l2_field field;
dev = em28xx_get_device(minor, &fh_type, &radio); switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
if (NULL == dev) fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
return -ENODEV; break;
case VFL_TYPE_VBI:
fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
break;
case VFL_TYPE_RADIO:
radio = 1;
break;
}
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
...@@ -2459,6 +2467,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, ...@@ -2459,6 +2467,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
snprintf(vfd->name, sizeof(vfd->name), "%s %s", snprintf(vfd->name, sizeof(vfd->name), "%s %s",
dev->name, type_name); dev->name, type_name);
video_set_drvdata(vfd, dev);
return vfd; return vfd;
} }
......
...@@ -668,9 +668,6 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); ...@@ -668,9 +668,6 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);
void em28xx_wake_i2c(struct em28xx *dev); void em28xx_wake_i2c(struct em28xx *dev);
void em28xx_remove_from_devlist(struct em28xx *dev); void em28xx_remove_from_devlist(struct em28xx *dev);
void em28xx_add_into_devlist(struct em28xx *dev); void em28xx_add_into_devlist(struct em28xx *dev);
struct em28xx *em28xx_get_device(int minor,
enum v4l2_buf_type *fh_type,
int *has_radio);
int em28xx_register_extension(struct em28xx_ops *dev); int em28xx_register_extension(struct em28xx_ops *dev);
void em28xx_unregister_extension(struct em28xx_ops *dev); void em28xx_unregister_extension(struct em28xx_ops *dev);
void em28xx_init_extension(struct em28xx *dev); void em28xx_init_extension(struct em28xx *dev);
......
...@@ -233,7 +233,6 @@ struct s2255_dev { ...@@ -233,7 +233,6 @@ struct s2255_dev {
struct s2255_dmaqueue vidq[MAX_CHANNELS]; struct s2255_dmaqueue vidq[MAX_CHANNELS];
struct video_device *vdev[MAX_CHANNELS]; struct video_device *vdev[MAX_CHANNELS];
struct list_head s2255_devlist;
struct timer_list timer; struct timer_list timer;
struct s2255_fw *fw_data; struct s2255_fw *fw_data;
struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS]; struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS];
...@@ -313,8 +312,6 @@ struct s2255_fh { ...@@ -313,8 +312,6 @@ struct s2255_fh {
/* Channels on box are in reverse order */ /* Channels on box are in reverse order */
static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0}; static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
static LIST_HEAD(s2255_devlist);
static int debug; static int debug;
static int *s2255_debug = &debug; static int *s2255_debug = &debug;
...@@ -1534,31 +1531,22 @@ static int vidioc_s_parm(struct file *file, void *priv, ...@@ -1534,31 +1531,22 @@ static int vidioc_s_parm(struct file *file, void *priv,
static int s2255_open(struct file *file) static int s2255_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct s2255_dev *h, *dev = NULL; struct video_device *vdev = video_devdata(file);
struct s2255_dev *dev = video_drvdata(file);
struct s2255_fh *fh; struct s2255_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
int i = 0; int i = 0;
int cur_channel = -1; int cur_channel = -1;
int state; int state;
dprintk(1, "s2255: open called (minor=%d)\n", minor); dprintk(1, "s2255: open called (minor=%d)\n", minor);
lock_kernel(); lock_kernel();
list_for_each(list, &s2255_devlist) {
h = list_entry(list, struct s2255_dev, s2255_devlist);
for (i = 0; i < MAX_CHANNELS; i++) {
if (h->vdev[i]->minor == minor) {
cur_channel = i;
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
}
if ((NULL == dev) || (cur_channel == -1)) { for (i = 0; i < MAX_CHANNELS; i++) {
unlock_kernel(); if (dev->vdev[i] == vdev) {
printk(KERN_INFO "s2255: openv4l no dev\n"); cur_channel = i;
return -ENODEV; break;
}
} }
if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING) { if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING) {
...@@ -1699,7 +1687,6 @@ static unsigned int s2255_poll(struct file *file, ...@@ -1699,7 +1687,6 @@ static unsigned int s2255_poll(struct file *file,
static void s2255_destroy(struct kref *kref) static void s2255_destroy(struct kref *kref)
{ {
struct s2255_dev *dev = to_s2255_dev(kref); struct s2255_dev *dev = to_s2255_dev(kref);
struct list_head *list;
int i; int i;
if (!dev) { if (!dev) {
printk(KERN_ERR "s2255drv: kref problem\n"); printk(KERN_ERR "s2255drv: kref problem\n");
...@@ -1733,10 +1720,6 @@ static void s2255_destroy(struct kref *kref) ...@@ -1733,10 +1720,6 @@ static void s2255_destroy(struct kref *kref)
usb_put_dev(dev->udev); usb_put_dev(dev->udev);
dprintk(1, "%s", __func__); dprintk(1, "%s", __func__);
while (!list_empty(&s2255_devlist)) {
list = s2255_devlist.next;
list_del(list);
}
mutex_unlock(&dev->open_lock); mutex_unlock(&dev->open_lock);
kfree(dev); kfree(dev);
} }
...@@ -1843,7 +1826,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev) ...@@ -1843,7 +1826,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
int cur_nr = video_nr; int cur_nr = video_nr;
/* initialize all video 4 linux */ /* initialize all video 4 linux */
list_add_tail(&dev->s2255_devlist, &s2255_devlist);
/* register 4 video devices */ /* register 4 video devices */
for (i = 0; i < MAX_CHANNELS; i++) { for (i = 0; i < MAX_CHANNELS; i++) {
INIT_LIST_HEAD(&dev->vidq[i].active); INIT_LIST_HEAD(&dev->vidq[i].active);
...@@ -1853,6 +1835,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) ...@@ -1853,6 +1835,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
dev->vdev[i] = video_device_alloc(); dev->vdev[i] = video_device_alloc();
memcpy(dev->vdev[i], &template, sizeof(struct video_device)); memcpy(dev->vdev[i], &template, sizeof(struct video_device));
dev->vdev[i]->parent = &dev->interface->dev; dev->vdev[i]->parent = &dev->interface->dev;
video_set_drvdata(dev->vdev[i], dev);
if (video_nr == -1) if (video_nr == -1)
ret = video_register_device(dev->vdev[i], ret = video_register_device(dev->vdev[i],
VFL_TYPE_GRABBER, VFL_TYPE_GRABBER,
......
...@@ -797,6 +797,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev, ...@@ -797,6 +797,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
vfd->debug = video_debug; vfd->debug = video_debug;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
dev->name, type, saa7134_boards[dev->board].name); dev->name, type, saa7134_boards[dev->board].name);
video_set_drvdata(vfd, dev);
return vfd; return vfd;
} }
......
...@@ -87,17 +87,9 @@ static int ts_init_encoder(struct saa7134_dev* dev) ...@@ -87,17 +87,9 @@ static int ts_init_encoder(struct saa7134_dev* dev)
static int ts_open(struct file *file) static int ts_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct saa7134_dev *dev; struct saa7134_dev *dev = video_drvdata(file);
int err; int err;
lock_kernel();
list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->empress_dev && dev->empress_dev->minor == minor)
goto found;
unlock_kernel();
return -ENODEV;
found:
dprintk("open minor=%d\n",minor); dprintk("open minor=%d\n",minor);
err = -EBUSY; err = -EBUSY;
if (!mutex_trylock(&dev->empress_tsq.vb_lock)) if (!mutex_trylock(&dev->empress_tsq.vb_lock))
...@@ -531,6 +523,7 @@ static int empress_init(struct saa7134_dev *dev) ...@@ -531,6 +523,7 @@ static int empress_init(struct saa7134_dev *dev)
INIT_WORK(&dev->empress_workqueue, empress_signal_update); INIT_WORK(&dev->empress_workqueue, empress_signal_update);
video_set_drvdata(dev->empress_dev, dev);
err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
empress_nr[dev->nr]); empress_nr[dev->nr]);
if (err < 0) { if (err < 0) {
......
...@@ -1327,29 +1327,23 @@ static int saa7134_resource(struct saa7134_fh *fh) ...@@ -1327,29 +1327,23 @@ static int saa7134_resource(struct saa7134_fh *fh)
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct saa7134_dev *dev; struct video_device *vdev = video_devdata(file);
struct saa7134_dev *dev = video_drvdata(file);
struct saa7134_fh *fh; struct saa7134_fh *fh;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type = 0;
int radio = 0; int radio = 0;
mutex_lock(&saa7134_devlist_lock); switch (vdev->vfl_type) {
list_for_each_entry(dev, &saa7134_devlist, devlist) { case VFL_TYPE_GRABBER:
if (dev->video_dev && (dev->video_dev->minor == minor)) type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
goto found; break;
if (dev->radio_dev && (dev->radio_dev->minor == minor)) { case VFL_TYPE_VBI:
radio = 1; type = V4L2_BUF_TYPE_VBI_CAPTURE;
goto found; break;
} case VFL_TYPE_RADIO:
if (dev->vbi_dev && (dev->vbi_dev->minor == minor)) { radio = 1;
type = V4L2_BUF_TYPE_VBI_CAPTURE; break;
goto found;
}
} }
mutex_unlock(&saa7134_devlist_lock);
return -ENODEV;
found:
mutex_unlock(&saa7134_devlist_lock);
dprintk("open minor=%d radio=%d type=%s\n",minor,radio, dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
v4l2_type_names[type]); v4l2_type_names[type]);
......
...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH11]
&& h->video_dev[SRAM_CH11]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
...@@ -189,6 +189,7 @@ struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, ...@@ -189,6 +189,7 @@ struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
vfd->release = video_device_release; vfd->release = video_device_release;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type,
cx25821_boards[dev->board].name); cx25821_boards[dev->board].name);
video_set_drvdata(vfd, dev);
return vfd; return vfd;
} }
......
...@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH00]
&& h->video_dev[SRAM_CH00]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
...@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH01]
&& h->video_dev[SRAM_CH01]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH02]
&& h->video_dev[SRAM_CH02]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH03]
&& h->video_dev[SRAM_CH03]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH04]
&& h->video_dev[SRAM_CH04]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH05]
&& h->video_dev[SRAM_CH05]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,36 +95,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH06]
&& h->video_dev[SRAM_CH06]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH07]
&& h->video_dev[SRAM_CH07]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->type = type; fh->type = type;
......
...@@ -95,35 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,35 +95,19 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
u32 pix_format; u32 pix_format;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->ioctl_dev && h->ioctl_dev->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH10]
&& h->video_dev[SRAM_CH10]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { ...@@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = {
static int video_open(struct file *file) static int video_open(struct file *file)
{ {
int minor = video_devdata(file)->minor; int minor = video_devdata(file)->minor;
struct cx25821_dev *h, *dev = NULL; struct cx25821_dev *dev = video_drvdata(file);
struct cx25821_fh *fh; struct cx25821_fh *fh;
struct list_head *list; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
enum v4l2_buf_type type = 0;
lock_kernel();
list_for_each(list, &cx25821_devlist) {
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH09]
&& h->video_dev[SRAM_CH09]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
lock_kernel();
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment