patch-2.1.10 linux/drivers/cdrom/mcd.c

Next file: linux/drivers/char/ChangeLog
Previous file: linux/drivers/cdrom/cdrom.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.9/linux/drivers/cdrom/mcd.c linux/drivers/cdrom/mcd.c
@@ -61,6 +61,10 @@
 	07 July 1995 Modifications by Andrew J. Kroll
 
 	Bjorn Ekwall <bj0rn@blox.se> added unregister_blkdev to mcd_init()
+
+	Michael K. Johnson <johnsonm@redhat.com> added retries on open
+	for slow drives which take a while to recognize that they contain
+	a CD.
 */
 
 #include <linux/module.h>
@@ -1095,6 +1099,7 @@
 mcd_open(struct inode *ip, struct file *fp)
 {
 	int st;
+	int count = 0;
 
 	if (mcdPresent == 0)
 		return -ENXIO;			/* no hardware */
@@ -1106,9 +1111,16 @@
 
 	mcd_invalidate_buffers();
 
-	st = statusCmd();			/* check drive status */
-	if (st == -1)
-		return -EIO;			/* drive doesn't respond */
+	do {
+		st = statusCmd();		/* check drive status */
+		if (st == -1)
+			return -EIO;		/* drive doesn't respond */
+		if ((st & MST_READY) == 0) {	/* no disk? wait a sec... */
+			current->state = TASK_INTERRUPTIBLE;
+			current->timeout = jiffies + HZ;
+			schedule();
+		}
+	} while (((st & MST_READY) == 0) && count++ < MCD_RETRY_ATTEMPTS);
 
 	if ((st & MST_READY) == 0)		/* no disk in drive */
 	{

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov