提交 65b88c0b 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] tm6000: embed video_device

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@osg.samsung.com>
上级 4b30409b
...@@ -1576,7 +1576,7 @@ static struct video_device tm6000_template = { ...@@ -1576,7 +1576,7 @@ static struct video_device tm6000_template = {
.name = "tm6000", .name = "tm6000",
.fops = &tm6000_fops, .fops = &tm6000_fops,
.ioctl_ops = &video_ioctl_ops, .ioctl_ops = &video_ioctl_ops,
.release = video_device_release, .release = video_device_release_empty,
.tvnorms = TM6000_STD, .tvnorms = TM6000_STD,
}; };
...@@ -1609,25 +1609,19 @@ static struct video_device tm6000_radio_template = { ...@@ -1609,25 +1609,19 @@ static struct video_device tm6000_radio_template = {
* ------------------------------------------------------------------ * ------------------------------------------------------------------
*/ */
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 const struct video_device
*template, const char *type_name) *template, const char *type_name)
{ {
struct video_device *vfd;
vfd = video_device_alloc();
if (NULL == vfd)
return NULL;
*vfd = *template; *vfd = *template;
vfd->v4l2_dev = &dev->v4l2_dev; vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release; vfd->release = video_device_release_empty;
vfd->lock = &dev->lock; vfd->lock = &dev->lock;
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); video_set_drvdata(vfd, dev);
return vfd;
} }
int tm6000_v4l2_register(struct tm6000_core *dev) int tm6000_v4l2_register(struct tm6000_core *dev)
...@@ -1658,62 +1652,46 @@ int tm6000_v4l2_register(struct tm6000_core *dev) ...@@ -1658,62 +1652,46 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
if (ret) if (ret)
goto free_ctrl; goto free_ctrl;
dev->vfd = vdev_init(dev, &tm6000_template, "video"); vdev_init(dev, &dev->vfd, &tm6000_template, "video");
if (!dev->vfd) { dev->vfd.ctrl_handler = &dev->ctrl_handler;
printk(KERN_INFO "%s: can't register video device\n",
dev->name);
ret = -ENOMEM;
goto free_ctrl;
}
dev->vfd->ctrl_handler = &dev->ctrl_handler;
/* init video dma queues */ /* init video dma queues */
INIT_LIST_HEAD(&dev->vidq.active); INIT_LIST_HEAD(&dev->vidq.active);
INIT_LIST_HEAD(&dev->vidq.queued); 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) { if (ret < 0) {
printk(KERN_INFO "%s: can't register video device\n", printk(KERN_INFO "%s: can't register video device\n",
dev->name); dev->name);
video_device_release(dev->vfd);
dev->vfd = NULL;
goto free_ctrl; goto free_ctrl;
} }
printk(KERN_INFO "%s: registered device %s\n", 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) { if (dev->caps.has_radio) {
dev->radio_dev = vdev_init(dev, &tm6000_radio_template, vdev_init(dev, &dev->radio_dev, &tm6000_radio_template,
"radio"); "radio");
if (!dev->radio_dev) { dev->radio_dev.ctrl_handler = &dev->radio_ctrl_handler;
printk(KERN_INFO "%s: can't register radio device\n", ret = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO,
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,
radio_nr); radio_nr);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "%s: can't register radio device\n", printk(KERN_INFO "%s: can't register radio device\n",
dev->name); dev->name);
video_device_release(dev->radio_dev);
goto unreg_video; goto unreg_video;
} }
printk(KERN_INFO "%s: registered device %s\n", 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); printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
return ret; return ret;
unreg_video: unreg_video:
video_unregister_device(dev->vfd); video_unregister_device(&dev->vfd);
free_ctrl: free_ctrl:
v4l2_ctrl_handler_free(&dev->ctrl_handler); v4l2_ctrl_handler_free(&dev->ctrl_handler);
v4l2_ctrl_handler_free(&dev->radio_ctrl_handler); v4l2_ctrl_handler_free(&dev->radio_ctrl_handler);
...@@ -1722,19 +1700,12 @@ int tm6000_v4l2_register(struct tm6000_core *dev) ...@@ -1722,19 +1700,12 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
int tm6000_v4l2_unregister(struct tm6000_core *dev) 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 */ /* if URB buffers are still allocated free them now */
tm6000_free_urb_buffers(dev); tm6000_free_urb_buffers(dev);
if (dev->radio_dev) { video_unregister_device(&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;
}
return 0; return 0;
} }
......
...@@ -220,8 +220,8 @@ struct tm6000_core { ...@@ -220,8 +220,8 @@ struct tm6000_core {
struct tm6000_fh *resources; /* Points to fh that is streaming */ struct tm6000_fh *resources; /* Points to fh that is streaming */
bool is_res_read; bool is_res_read;
struct video_device *vfd; struct video_device vfd;
struct video_device *radio_dev; struct video_device radio_dev;
struct tm6000_dmaqueue vidq; struct tm6000_dmaqueue vidq;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl_handler ctrl_handler;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册