diff options
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-video.c')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-video.c | 44 |
1 files changed, 17 insertions, 27 deletions
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; |