diff driver/pt1_pci.c @ 50:23b6f99f65b2

propagate upstream change: - adapted to FastBoot. use spinlock to avoid resource contention between multiple number of cards.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 27 Aug 2009 21:39:14 +0900
parents 07d71b1484a8
children c915076353ae
line wrap: on
line diff
--- a/driver/pt1_pci.c	Tue Jul 21 00:08:47 2009 +0900
+++ b/driver/pt1_pci.c	Thu Aug 27 21:39:14 2009 +0900
@@ -51,8 +51,10 @@
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
-static int debug = 7;			/* 1 normal messages, 0 quiet .. 7 verbose. */
-static int lnb = 0;			/* LNB OFF:0 +11V:1 +15V:2 */
+static int          debug = 7;  /* 1 normal messages, 0 quiet ..
+                                   7 verbose. */
+static int          lnb = 0;    /* LNB OFF:0 +11V:1 +15V:2 */
+static spinlock_t   lock;       /* to synchronize at probing */
 
 module_param(debug, int, 0);
 module_param(lnb, int, 0);
@@ -698,6 +700,9 @@
 			goto out_err_fpga;
 		}
 	}
+
+	spin_lock(&lock);
+
 	// ½é´ü²½´°Î»
 	for(lp = 0 ; lp < MAX_CHANNEL ; lp++){
 		set_sleepmode(dev_conf->regs, &dev_conf->lock,
@@ -707,6 +712,7 @@
 	}
 	rc = alloc_chrdev_region(&dev_conf->dev, 0, MAX_CHANNEL, DEV_NAME);
 	if(rc < 0){
+		spin_unlock(&lock);
 		goto out_err_fpga;
 	}
 
@@ -723,6 +729,9 @@
 			break ;
 		}
 	}
+
+	spin_unlock(&lock);
+
 	for(lp = 0 ; lp < MAX_CHANNEL ; lp++){
 		cdev_init(&dev_conf->cdev[lp], &pt1_fops);
 		dev_conf->cdev[lp].owner = THIS_MODULE;
@@ -910,6 +919,7 @@
 	pt1video_class = class_create(THIS_MODULE, DRIVERNAME);
 	if (IS_ERR(pt1video_class))
 		return PTR_ERR(pt1video_class);
+	spin_lock_init(&lock);
 	return pci_register_driver(&pt1_driver);
 }