diff options
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-video.c')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-video.c | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index 8b372b4f0de2..8934d61cf660 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -318,11 +318,11 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, | |||
318 | if (NULL == vfd) | 318 | if (NULL == vfd) |
319 | return NULL; | 319 | return NULL; |
320 | *vfd = *template; | 320 | *vfd = *template; |
321 | vfd->minor = -1; | ||
322 | vfd->v4l2_dev = &dev->v4l2_dev; | 321 | vfd->v4l2_dev = &dev->v4l2_dev; |
323 | vfd->release = video_device_release; | 322 | vfd->release = video_device_release; |
324 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", | 323 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", |
325 | dev->name, type, cx23885_boards[dev->board].name); | 324 | dev->name, type, cx23885_boards[dev->board].name); |
325 | video_set_drvdata(vfd, dev); | ||
326 | return vfd; | 326 | return vfd; |
327 | } | 327 | } |
328 | 328 | ||
@@ -716,46 +716,34 @@ static int get_resource(struct cx23885_fh *fh) | |||
716 | 716 | ||
717 | static int video_open(struct file *file) | 717 | static int video_open(struct file *file) |
718 | { | 718 | { |
719 | int minor = video_devdata(file)->minor; | 719 | struct video_device *vdev = video_devdata(file); |
720 | struct cx23885_dev *h, *dev = NULL; | 720 | struct cx23885_dev *dev = video_drvdata(file); |
721 | struct cx23885_fh *fh; | 721 | struct cx23885_fh *fh; |
722 | struct list_head *list; | ||
723 | enum v4l2_buf_type type = 0; | 722 | enum v4l2_buf_type type = 0; |
724 | int radio = 0; | 723 | int radio = 0; |
725 | 724 | ||
726 | lock_kernel(); | 725 | switch (vdev->vfl_type) { |
727 | list_for_each(list, &cx23885_devlist) { | 726 | case VFL_TYPE_GRABBER: |
728 | h = list_entry(list, struct cx23885_dev, devlist); | 727 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
729 | if (h->video_dev && | 728 | break; |
730 | h->video_dev->minor == minor) { | 729 | case VFL_TYPE_VBI: |
731 | dev = h; | 730 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
732 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 731 | break; |
733 | } | 732 | case VFL_TYPE_RADIO: |
734 | if (h->vbi_dev && | 733 | radio = 1; |
735 | h->vbi_dev->minor == minor) { | 734 | 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 | } | 735 | } |
749 | 736 | ||
750 | dprintk(1, "open minor=%d radio=%d type=%s\n", | 737 | dprintk(1, "open dev=%s radio=%d type=%s\n", |
751 | minor, radio, v4l2_type_names[type]); | 738 | video_device_node_name(vdev), radio, v4l2_type_names[type]); |
752 | 739 | ||
753 | /* allocate + initialize per filehandle data */ | 740 | /* allocate + initialize per filehandle data */ |
754 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 741 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
755 | if (NULL == fh) { | 742 | if (NULL == fh) |
756 | unlock_kernel(); | ||
757 | return -ENOMEM; | 743 | return -ENOMEM; |
758 | } | 744 | |
745 | lock_kernel(); | ||
746 | |||
759 | file->private_data = fh; | 747 | file->private_data = fh; |
760 | fh->dev = dev; | 748 | fh->dev = dev; |
761 | fh->radio = radio; | 749 | fh->radio = radio; |
@@ -1441,7 +1429,6 @@ static struct video_device cx23885_vbi_template; | |||
1441 | static struct video_device cx23885_video_template = { | 1429 | static struct video_device cx23885_video_template = { |
1442 | .name = "cx23885-video", | 1430 | .name = "cx23885-video", |
1443 | .fops = &video_fops, | 1431 | .fops = &video_fops, |
1444 | .minor = -1, | ||
1445 | .ioctl_ops = &video_ioctl_ops, | 1432 | .ioctl_ops = &video_ioctl_ops, |
1446 | .tvnorms = CX23885_NORMS, | 1433 | .tvnorms = CX23885_NORMS, |
1447 | .current_norm = V4L2_STD_NTSC_M, | 1434 | .current_norm = V4L2_STD_NTSC_M, |
@@ -1461,7 +1448,7 @@ void cx23885_video_unregister(struct cx23885_dev *dev) | |||
1461 | cx_clear(PCI_INT_MSK, 1); | 1448 | cx_clear(PCI_INT_MSK, 1); |
1462 | 1449 | ||
1463 | if (dev->video_dev) { | 1450 | if (dev->video_dev) { |
1464 | if (-1 != dev->video_dev->minor) | 1451 | if (video_is_registered(dev->video_dev)) |
1465 | video_unregister_device(dev->video_dev); | 1452 | video_unregister_device(dev->video_dev); |
1466 | else | 1453 | else |
1467 | video_device_release(dev->video_dev); | 1454 | video_device_release(dev->video_dev); |
@@ -1532,8 +1519,8 @@ int cx23885_video_register(struct cx23885_dev *dev) | |||
1532 | dev->name); | 1519 | dev->name); |
1533 | goto fail_unreg; | 1520 | goto fail_unreg; |
1534 | } | 1521 | } |
1535 | printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n", | 1522 | printk(KERN_INFO "%s/0: registered device %s [v4l2]\n", |
1536 | dev->name, dev->video_dev->num); | 1523 | dev->name, video_device_node_name(dev->video_dev)); |
1537 | /* initial device configuration */ | 1524 | /* initial device configuration */ |
1538 | mutex_lock(&dev->lock); | 1525 | mutex_lock(&dev->lock); |
1539 | cx23885_set_tvnorm(dev, dev->tvnorm); | 1526 | cx23885_set_tvnorm(dev, dev->tvnorm); |