Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] [PATCH] Fix xx: videodev has no release callback.



Hi,

would this be an okay change to fix the saa7146 extension videodev sysfs 
release problem? I also thought about only modifying the dvb drivers to fix 
this, but because of the device_template in saa7146_fops, it is impossible to 
remove the warning from v4l.


Kenneth
Index: linux/include/media/saa7146_vv.h
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/include/media/saa7146_vv.h,v
retrieving revision 1.16
diff -u -r1.16 saa7146_vv.h
--- linux/include/media/saa7146_vv.h	28 Apr 2004 16:31:39 -0000	1.16
+++ linux/include/media/saa7146_vv.h	28 Jul 2004 14:27:58 -0000
@@ -189,8 +189,8 @@
 };
 
 /* from saa7146_fops.c */
-int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, char *name, int type);
-int saa7146_unregister_device(struct video_device *vid, struct saa7146_dev* dev);
+int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, char *name, int type);
+int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev);
 void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, int state);
 void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
 int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
Index: linux/drivers/media/common/saa7146_fops.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/common/saa7146_fops.c,v
retrieving revision 1.26
diff -u -r1.26 saa7146_fops.c
--- linux/drivers/media/common/saa7146_fops.c	28 Apr 2004 16:31:39 -0000	1.26
+++ linux/drivers/media/common/saa7146_fops.c	28 Jul 2004 14:28:04 -0000
@@ -506,45 +506,58 @@
 	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;
 }
Index: linux/drivers/media/dvb/ttpci/av7110.h
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.h,v
retrieving revision 1.23
diff -u -r1.23 av7110.h
--- linux/drivers/media/dvb/ttpci/av7110.h	24 Jun 2004 10:00:34 -0000	1.23
+++ linux/drivers/media/dvb/ttpci/av7110.h	28 Jul 2004 14:28:20 -0000
@@ -61,8 +61,8 @@
 	struct dvb_device	dvb_dev;
 	struct dvb_net		dvb_net;
 
-	struct video_device	v4l_dev;
-	struct video_device	vbi_dev;
+	struct video_device	*v4l_dev;
+	struct video_device	*vbi_dev;
 
 	struct saa7146_dev	*dev;
 
Index: linux/drivers/media/dvb/ttpci/budget-av.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/budget-av.c,v
retrieving revision 1.21
diff -u -r1.21 budget-av.c
--- linux/drivers/media/dvb/ttpci/budget-av.c	24 Jun 2004 10:43:55 -0000	1.21
+++ linux/drivers/media/dvb/ttpci/budget-av.c	28 Jul 2004 14:28:23 -0000
@@ -35,7 +35,7 @@
 
 struct budget_av {
 	struct budget budget;
-	struct video_device vd;
+	struct video_device *vd;
 	int cur_input;
 	int has_saa7113;
 };

Home | Main Index | Thread Index