Javier-Elias Vasquez-Vivas wrote:
> I'm attaching dmesg output redirected to the provided file... It's
> still weird how 1st a message shows up saying:
>
> usbat_flash_transport: INQUIRY. Returning bogus response.
Don't worry about that. You captured the important part below.
> usb-storage: usbat_identify_device: Cylinder low is 00
> usb-storage: usbat_identify_device: Detected Flash reader/writer
When I was extending the driver, one problem I faced was how to distinguish
between the CompactFlash readers and the HP cdroms. I tried, but couldn't find
anyone with one of the HP devices to confirm the behaviour, so I assumed it
would follow the ATAPI specs in terms of providing a device signature on
reset. Your report shows that this is not the case though.
Please try the attached patch. It should be a more solid check for which
device type we are dealing with.
Thanks,
Daniel
--- linux/drivers/usb/storage/shuttle_usbat.c.orig 2005-06-29 10:59:04.000000000 +0100
+++ linux/drivers/usb/storage/shuttle_usbat.c 2005-06-29 11:36:52.000000000 +0100
@@ -836,39 +836,35 @@ static int usbat_identify_device(struct
if (!us || !info)
return USB_STOR_TRANSPORT_ERROR;
- rc = usbat_device_reset(us);
- if (rc != USB_STOR_TRANSPORT_GOOD)
- return rc;
-
/*
- * By examining the device signature after a reset, we can identify
- * whether the device supports the ATAPI packet interface.
- * The flash-devices do not support this, whereas the HP CDRW's obviously
- * do.
- *
- * This method is not ideal, but works because no other devices have been
- * produced based on the USBAT/USBAT02.
- *
- * Section 9.1 of the ATAPI-4 spec states (amongst other things) that
- * after a device reset, a Cylinder low of 0x14 indicates that the device
- * does support packet commands.
+ * To figure out if we're dealing with a CompactFlash reader (ATA) or an HP CD
+ * writer (ATAPI), we send the ATAPI IDENTIFY PACKET DEVICE command. On non-packet
+ * devices (ATA), this will result in an error. On packet devices (ATAPI), this
+ * will return successfully.
*/
- rc = usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, &status);
+ rc = usbat_write(us, USBAT_ATA, USBAT_ATA_CMD, 0xA1);
if (rc != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
- US_DEBUGP("usbat_identify_device: Cylinder low is %02X\n", status);
+ rc = usbat_get_status(us, &status);
+ if (rc != USB_STOR_XFER_GOOD)
+ return USB_STOR_TRANSPORT_ERROR;
- if (status == 0x14) {
- // Device is HP 8200
- US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n");
- info->devicetype = USBAT_DEV_HP8200;
- } else {
+ // Check for error bit
+ if (status & 0x01) {
// Device is a CompactFlash reader/writer
US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n");
info->devicetype = USBAT_DEV_FLASH;
+ } else {
+ // Device is HP 8200
+ US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n");
+ info->devicetype = USBAT_DEV_HP8200;
}
+ rc = usbat_device_reset(us);
+ if (rc != USB_STOR_TRANSPORT_GOOD)
+ return rc;
+
return USB_STOR_TRANSPORT_GOOD;
}