[PATCH] check dev-core/dvbdev is initialised when an adapter or device is registered [Was: saa7134-dvb initialised before dvbdev]

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

 



The init function in dvbdev isn't called until after saa7134-dvb has finished initialising, so devices can't be registered
properly. No-one else has replied about this yet and someone might the patch I made useful so here it is.

-- 
Simon Arlott


diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 3852430..cb1a49e 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -43,7 +43,12 @@ MODULE_PARM_DESC(dvbdev_debug, "Turn on/
 
 #define dprintk if (dvbdev_debug) printk
 
+static int dvb_dev_init_done;
+static int dvb_dev_init_retval;
+static int dvb_dev_init (void);
+
 static LIST_HEAD(dvb_adapter_list);
+static DEFINE_MUTEX(dvb_dev_init_lock);
 static DEFINE_MUTEX(dvbdev_register_lock);
 
 static const char * const dnames[] = {
@@ -202,6 +207,9 @@ int dvb_register_device(struct dvb_adapt
 	struct dvb_device *dvbdev;
 	int id;
 
+	if (dvb_dev_init() != 0)
+		return -ENFILE;
+
 	if (mutex_lock_interruptible(&dvbdev_register_lock))
 		return -ERESTARTSYS;
 
@@ -289,6 +297,9 @@ int dvb_register_adapter(struct dvb_adap
 {
 	int num;
 
+	if (dvb_dev_init() != 0)
+		return -ENFILE;
+
 	if (mutex_lock_interruptible(&dvbdev_register_lock))
 		return -ERESTARTSYS;
 
@@ -393,13 +404,22 @@ out:
 	return err;
 }
 
-static int __init init_dvbdev(void)
+static int dvb_dev_init(void)
 {
 	int retval;
 	dev_t dev = MKDEV(DVB_MAJOR, 0);
 
+	mutex_lock(&dvb_dev_init_lock);
+	if (dvb_dev_init_done) {
+		mutex_unlock(&dvb_dev_init_lock);
+		return dvb_dev_init_retval;
+	}
+	
 	if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) {
 		printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
+		dvb_dev_init_done = 1;
+		dvb_dev_init_retval = retval;
+		mutex_unlock(&dvb_dev_init_lock);
 		return retval;
 	}
 
@@ -413,17 +433,28 @@ static int __init init_dvbdev(void)
 
 	dvb_class = class_create(THIS_MODULE, "dvb");
 	if (IS_ERR(dvb_class)) {
+		printk ("dvb-core: could create dvb class...\n");
 		retval = PTR_ERR(dvb_class);
 		goto error;
 	}
+	dvb_dev_init_done = 1;
+	dvb_dev_init_retval = 0;
+	mutex_unlock(&dvb_dev_init_lock);
 	return 0;
 
 error:
 	cdev_del(&dvb_device_cdev);
 	unregister_chrdev_region(dev, MAX_DVB_MINORS);
+	dvb_dev_init_done = 1;
+	dvb_dev_init_retval = retval;
+	mutex_unlock(&dvb_dev_init_lock);
 	return retval;
 }
 
+static int __init init_dvbdev(void)
+{
+	return dvb_dev_init();
+}
 
 static void __exit exit_dvbdev(void)
 {

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux