--- zzzz-none-000/linux-3.10.107/drivers/media/usb/tm6000/tm6000-video.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/usb/tm6000/tm6000-video.c 2021-02-04 17:41:59.000000000 +0000 @@ -621,7 +621,7 @@ dev->isoc_in.maxsize, size); - if (!dev->urb_buffer && tm6000_alloc_urb_buffers(dev) < 0) { + if (tm6000_alloc_urb_buffers(dev) < 0) { tm6000_err("cannot allocate memory for urb buffers\n"); /* call free, as some buffers might have been allocated */ @@ -714,8 +714,7 @@ struct tm6000_core *dev = fh->dev; unsigned long flags; - if (in_interrupt()) - BUG(); + BUG_ON(in_interrupt()); /* We used to wait for the buffer to finish here, but this didn't work because, as we were keeping the state as VIDEOBUF_QUEUED, @@ -918,7 +917,6 @@ (f->fmt.pix.width * fh->fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; - f->fmt.pix.priv = 0; return 0; } @@ -942,7 +940,7 @@ fmt = format_by_fourcc(f->fmt.pix.pixelformat); if (NULL == fmt) { - dprintk(dev, V4L2_DEBUG_IOCTL_ARG, "Fourcc format (0x%08x)" + dprintk(dev, 2, "Fourcc format (0x%08x)" " invalid.\n", f->fmt.pix.pixelformat); return -EINVAL; } @@ -959,7 +957,6 @@ f->fmt.pix.width &= ~0x01; f->fmt.pix.field = field; - f->fmt.pix.priv = 0; f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; @@ -1071,11 +1068,20 @@ if (rc < 0) return rc; - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm); + v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_std, dev->norm); return 0; } +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm) +{ + struct tm6000_fh *fh = priv; + struct tm6000_core *dev = fh->dev; + + *norm = dev->norm; + return 0; +} + static const char *iname[] = { [TM6000_INPUT_TV] = "Television", [TM6000_INPUT_COMPOSITE1] = "Composite 1", @@ -1134,7 +1140,7 @@ dev->input = i; - rc = vidioc_s_std(file, priv, dev->vfd->current_norm); + rc = vidioc_s_std(file, priv, dev->norm); return rc; } @@ -1547,6 +1553,7 @@ .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, .vidioc_s_std = vidioc_s_std, + .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1568,9 +1575,8 @@ .name = "tm6000", .fops = &tm6000_fops, .ioctl_ops = &video_ioctl_ops, - .release = video_device_release, + .release = video_device_release_empty, .tvnorms = TM6000_STD, - .current_norm = V4L2_STD_NTSC_M, }; static const struct v4l2_file_operations radio_fops = { @@ -1602,27 +1608,19 @@ * ------------------------------------------------------------------ */ -static struct video_device *vdev_init(struct tm6000_core *dev, +static void vdev_init(struct tm6000_core *dev, + struct video_device *vfd, const struct video_device *template, const char *type_name) { - struct video_device *vfd; - - vfd = video_device_alloc(); - if (NULL == vfd) - return NULL; - *vfd = *template; vfd->v4l2_dev = &dev->v4l2_dev; - vfd->release = video_device_release; - vfd->debug = tm6000_debug; + vfd->release = video_device_release_empty; vfd->lock = &dev->lock; - set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); video_set_drvdata(vfd, dev); - return vfd; } int tm6000_v4l2_register(struct tm6000_core *dev) @@ -1653,62 +1651,46 @@ if (ret) goto free_ctrl; - dev->vfd = vdev_init(dev, &tm6000_template, "video"); + vdev_init(dev, &dev->vfd, &tm6000_template, "video"); - if (!dev->vfd) { - printk(KERN_INFO "%s: can't register video device\n", - dev->name); - ret = -ENOMEM; - goto free_ctrl; - } - dev->vfd->ctrl_handler = &dev->ctrl_handler; + dev->vfd.ctrl_handler = &dev->ctrl_handler; /* init video dma queues */ INIT_LIST_HEAD(&dev->vidq.active); INIT_LIST_HEAD(&dev->vidq.queued); - ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr); + ret = video_register_device(&dev->vfd, VFL_TYPE_GRABBER, video_nr); if (ret < 0) { printk(KERN_INFO "%s: can't register video device\n", dev->name); - video_device_release(dev->vfd); - dev->vfd = NULL; goto free_ctrl; } printk(KERN_INFO "%s: registered device %s\n", - dev->name, video_device_node_name(dev->vfd)); + dev->name, video_device_node_name(&dev->vfd)); if (dev->caps.has_radio) { - dev->radio_dev = vdev_init(dev, &tm6000_radio_template, + vdev_init(dev, &dev->radio_dev, &tm6000_radio_template, "radio"); - if (!dev->radio_dev) { - printk(KERN_INFO "%s: can't register radio device\n", - dev->name); - ret = -ENXIO; - goto unreg_video; - } - - dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; - ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, + dev->radio_dev.ctrl_handler = &dev->radio_ctrl_handler; + ret = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO, radio_nr); if (ret < 0) { printk(KERN_INFO "%s: can't register radio device\n", dev->name); - video_device_release(dev->radio_dev); goto unreg_video; } printk(KERN_INFO "%s: registered device %s\n", - dev->name, video_device_node_name(dev->radio_dev)); + dev->name, video_device_node_name(&dev->radio_dev)); } printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); return ret; unreg_video: - video_unregister_device(dev->vfd); + video_unregister_device(&dev->vfd); free_ctrl: v4l2_ctrl_handler_free(&dev->ctrl_handler); v4l2_ctrl_handler_free(&dev->radio_ctrl_handler); @@ -1717,19 +1699,12 @@ int tm6000_v4l2_unregister(struct tm6000_core *dev) { - video_unregister_device(dev->vfd); + video_unregister_device(&dev->vfd); /* if URB buffers are still allocated free them now */ tm6000_free_urb_buffers(dev); - if (dev->radio_dev) { - if (video_is_registered(dev->radio_dev)) - video_unregister_device(dev->radio_dev); - else - video_device_release(dev->radio_dev); - dev->radio_dev = NULL; - } - + video_unregister_device(&dev->radio_dev); return 0; }