diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1996-06-09 12:17:53 +0000 | 
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1996-06-09 12:17:53 +0000 | 
| commit | 88926e45d5d7e082bb09aab8df73d0135f5977bf (patch) | |
| tree | 2bb53a1943a21361fc3e5a2ebd22fb7f1a5056fd | |
| parent | 58e025d580f8f37814e5e95bb94b2ea3b4dc7eac (diff) | |
Notes
| -rw-r--r-- | sys/i386/isa/wcd.c | 20 | 
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/i386/isa/wcd.c b/sys/i386/isa/wcd.c index 56182fb09472..2723204a95ba 100644 --- a/sys/i386/isa/wcd.c +++ b/sys/i386/isa/wcd.c @@ -250,7 +250,7 @@ static void wcd_describe (struct wcd *t);  static int wcd_open(dev_t dev, int rawflag);  static int wcd_setchan (struct wcd *t,  	u_char c0, u_char c1, u_char c2, u_char c3); -static int wcd_eject (struct wcd *t); +static int wcd_eject (struct wcd *t, int closeit);  static struct kern_devconf cftemplate = {  	0, 0, 0, "wcd", 0, { MDDT_DISK, 0 }, @@ -740,7 +740,12 @@ int wcdioctl (dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p)  		 * by somebody (not us) in block mode. */  		if ((t->flags & F_BOPEN) && t->refcnt)  			return (EBUSY); -		return wcd_eject (t); +		return wcd_eject (t, 0); + +	case CDIOCCLOSE: +		if ((t->flags & F_BOPEN) && t->refcnt) +			return (0); +		return wcd_eject (t, 1);  	case CDIOREADTOCHEADER:  		if (! t->toc.hdr.ending_track) @@ -1068,7 +1073,7 @@ static int wcd_setchan (struct wcd *t,  		0, (char*) &t->au, - sizeof (t->au));  } -static int wcd_eject (struct wcd *t) +static int wcd_eject (struct wcd *t, int closeit)  {  	struct atapires result; @@ -1081,12 +1086,16 @@ static int wcd_eject (struct wcd *t)  	if (result.code == RES_ERR &&  	    ((result.error & AER_SKEY) == AER_SK_NOT_READY ||  	    (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) { +		int err; + +		if (!closeit) +			return (0);  		/*  		 * The disc was unloaded.  		 * Load it (close tray).  		 * Read the table of contents.  		 */ -		int err = wcd_request_wait (t, ATAPI_START_STOP, +		err = wcd_request_wait (t, ATAPI_START_STOP,  			0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);  		if (err)  			return (err); @@ -1106,6 +1115,9 @@ static int wcd_eject (struct wcd *t)  		return (EIO);  	} +	if (closeit) +		return (0); +  	/* Give it some time to stop spinning. */  	tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej1", 0);  	tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej2", 0);  | 
