On Tue, 21 Dec 2004, Daniel Drake wrote:
> Interesting that this came up at this time. I'm developing a usb-storage
> subdriver for a compact flash reader and was just about to ask the same
> thing,
> while trying to implement the ability to plug the device in with no media
> without it going mad.
>
> Alan, I tried what you have said and it's not working as expected, probably
> something simple that I'm doing wrong. Would you mind taking a quick glance
> over this?
This sounds different from what Sara was asking (unless I misunderstood
the question, which is entirely possible). You're asking about what
should be done when there's no media present, not when the media is
present but uninitialized. The answer is simple: report a Medium Not
Present failure (sense key = 0x02, ASC = 0x3a, ASCQ = 0x00).
> Although its an extension to the usbat subdriver, the transport function is
> based almost entirely on the jumpshot_transport code.
>
> Here is the relevant section of the transport function:
>
> if (srb->cmnd[0] == READ_CAPACITY) {
> info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec
>
> // Handle the situation where no media is present
> rc = usbat_read_user_io(us, &status);
> if (status & USBAT_UIO_UI0) {
> US_DEBUGP("usbat02_transport: no media detected\n");
> info->sense_key = 0x03;
> info->sense_asc = 0x12;
So change the 03, 12 to 02, 3a.
> info->sense_ascq = 0x00;
> return USB_STOR_TRANSPORT_FAILED;
> }
>
> rc = usbat02_id_device(us, info);
> US_DEBUGP("usbat02_transport: READ_CAPACITY: %ld sectors, %ld bytes
> per
> sector\n",
> info->sectors, info->ssize);
>
> // build the reply
> ((u32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
> ((u32 *) ptr)[1] = cpu_to_be32(info->ssize);
> usb_stor_set_xfer_buf(ptr, 8, srb);
> return USB_STOR_TRANSPORT_GOOD;
> }
>
> I get this in the logs:
>
> Dec 21 00:38:39 dsd usb-storage: Command READ_CAPACITY (10 bytes)
> Dec 21 00:38:39 dsd usb-storage: 25 00 00 00 00 00 00 00 00 00
> Dec 21 00:38:39 dsd usb-storage: usb_stor_ctrl_transfer: rq=82 rqtype=c0
> value=0000 index=00 len=1
> Dec 21 00:38:39 dsd usb-storage: Status code 0; transferred 1/1
> Dec 21 00:38:39 dsd usb-storage: -- transfer complete
> Dec 21 00:38:39 dsd usb-storage: usbat02_transport: no media detected
> Dec 21 00:38:39 dsd usb-storage: -- transport indicates command failure
> Dec 21 00:38:39 dsd usb-storage: Issuing auto-REQUEST_SENSE
> Dec 21 00:38:39 dsd usb-storage: usbat02_transport: REQUEST_SENSE.
> Dec 21 00:38:39 dsd usb-storage: -- Result from auto-sense is 0
> Dec 21 00:38:39 dsd usb-storage: -- code: 0xf0, key: 0x3, ASC: 0x12, ASCQ: 0x0
> Dec 21 00:38:39 dsd usb-storage: (Unknown Key): (unknown ASC/ASCQ)
> Dec 21 00:38:39 dsd usb-storage: scsi cmd done, result=0x2
> Dec 21 00:38:39 dsd usb-storage: *** thread sleeping.
>
> This repeats a few times, then it tries to read the partition table anyway.
> The card reader isn't too happy about this.
>
> What am I missing?
You also have to report Media Not Present in response to TEST UNIT READY.
(By definition, a non-failure return for that command means the device is
ready to read data.) And in response to READ(n) and WRITE(n).
Alan Stern
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel