summaryrefslogtreecommitdiff
path: root/linux/drivers/media/common/saa7146_fops.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/common/saa7146_fops.c')
-rw-r--r--linux/drivers/media/common/saa7146_fops.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c
index 329e6c436..5c6714dcc 100644
--- a/linux/drivers/media/common/saa7146_fops.c
+++ b/linux/drivers/media/common/saa7146_fops.c
@@ -506,45 +506,58 @@ int saa7146_vv_release(struct saa7146_dev* dev)
return 0;
}
-int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, char *name, int type)
+int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
+ char *name, int type)
{
struct saa7146_vv *vv = dev->vv_data;
+ struct video_device *vfd;
DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type));
-
- *vid = device_template;
- strlcpy(vid->name, name, sizeof(vid->name));
- vid->priv = dev;
+
+ // released by vfd->release
+ vfd = video_device_alloc();
+ if (vfd == NULL)
+ return -ENOMEM;
+
+ memcpy(vfd, &device_template, sizeof(struct video_device));
+ strlcpy(vfd->name, name, sizeof(vfd->name));
+ vfd->release = video_device_release;
+ vfd->priv = dev;
// fixme: -1 should be an insmod parameter *for the extension* (like "video_nr");
- if (video_register_device(vid,type,-1) < 0) {
+ if (video_register_device(vfd, type, -1) < 0) {
ERR(("cannot register v4l2 device. skipping.\n"));
return -1;
}
if( VFL_TYPE_GRABBER == type ) {
- vv->video_minor = vid->minor;
- INFO(("%s: registered device video%d [v4l2]\n", dev->name,vid->minor & 0x1f));
+ vv->video_minor = vfd->minor;
+ INFO(("%s: registered device video%d [v4l2]\n",
+ dev->name, vfd->minor & 0x1f));
} else {
- vv->vbi_minor = vid->minor;
- INFO(("%s: registered device vbi%d [v4l2]\n", dev->name,vid->minor & 0x1f));
+ vv->vbi_minor = vfd->minor;
+ INFO(("%s: registered device vbi%d [v4l2]\n",
+ dev->name, vfd->minor & 0x1f));
}
+ *vid = vfd;
return 0;
}
-int saa7146_unregister_device(struct video_device *vid, struct saa7146_dev* dev)
+int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
{
struct saa7146_vv *vv = dev->vv_data;
DEB_EE(("dev:%p\n",dev));
- if( VFL_TYPE_GRABBER == vid->type ) {
+ if( VFL_TYPE_GRABBER == (*vid)->type ) {
vv->video_minor = -1;
} else {
vv->vbi_minor = -1;
}
- video_unregister_device(vid);
+
+ video_unregister_device(*vid);
+ *vid = NULL;
return 0;
}