From a8f35ce3d6f5b776463f03403e0319c2415401f7 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 13 Apr 2013 07:07:40 -0300 Subject: [media] cx25821: remove unnecessary global devlist This device list is not necessary. The kernel already has all that information, so just use that instead. Also remove a bogus refcount and some dead 'private_free' code in the alsa driver. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx25821/cx25821-video.c | 38 ++++++++----------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'drivers/media/pci/cx25821/cx25821-video.c') diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index c418e0d38c24..a9aa09651cab 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c @@ -654,45 +654,28 @@ static struct videobuf_queue_ops cx25821_video_qops = { static int video_open(struct file *file) { struct video_device *vdev = video_devdata(file); - struct cx25821_dev *h, *dev = video_drvdata(file); + struct cx25821_dev *dev = video_drvdata(file); struct cx25821_fh *fh; - struct list_head *list; - int minor = video_devdata(file)->minor; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; u32 pix_format; - int ch_id = 0; - int i; + int ch_id; dprintk(1, "open dev=%s type=%s\n", video_device_node_name(vdev), v4l2_type_names[type]); + for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++) + if (dev->channels[ch_id].video_dev == vdev) + break; + + /* Can't happen */ + if (ch_id >= MAX_VID_CHANNEL_NUM - 1) + return -ENODEV; + /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh), GFP_KERNEL); if (NULL == fh) return -ENOMEM; - mutex_lock(&cx25821_devlist_mutex); - - list_for_each(list, &cx25821_devlist) - { - h = list_entry(list, struct cx25821_dev, devlist); - - for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) { - if (h->channels[i].video_dev && - h->channels[i].video_dev->minor == minor) { - dev = h; - ch_id = i; - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - } - } - } - - if (NULL == dev) { - mutex_unlock(&cx25821_devlist_mutex); - kfree(fh); - return -ENODEV; - } - file->private_data = fh; fh->dev = dev; fh->type = type; @@ -719,7 +702,6 @@ static int video_open(struct file *file) fh, NULL); dprintk(1, "post videobuf_queue_init()\n"); - mutex_unlock(&cx25821_devlist_mutex); return 0; } -- cgit v1.2.3