mcd.c module

Michael K. Johnson (johnsonm@redhat.com)
Wed, 30 Oct 1996 16:22:07 -0500


We (at Red Hat) have noticed that some Mitsumi drives which use the
mcd driver aren't quick to recognize that they have a cd in the drive.
I wrote this patch, and it's been reported that it's fixed the problem
where mount fails even though there's a disk in the drive.

I'd appreciate it if other people with access to Mitsumi drives,
particularly ones which manifest the same problem, could test this
fix. I think it's harmless, and if it's proved to help, should
probably go into 2.0.x, for some x...

Thanks,

michaelkjohnson

--- mcd.c.nodelay Fri Oct 25 14:44:07 1996
+++ mcd.c Fri Oct 25 14:58:43 1996
@@ -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 (count++ < MCD_RETRY_ATTEMPTS);

if ((st & MST_READY) == 0) /* no disk in drive */
{