Okay.. now try this attached patch.  You apparently uncovered a bug which
affected CBI devices that are not also UFI.  It was a suprising simple
error... tho I still can't test this fix, since I don't have any devices
like that.

This patch is, once again, not for general consumption.  It is alos
against 2.3.99-pre3 clean.  Thus, you either have to (a) reverse the last
patch I sent you, or (b) get a clean copy of usb-storage.c to patch.

Give this a try.  I think I have the logic right this time.  Hopefully it
will only be a few more iterations of this before we have it working.

Matt Dharm

On Mon, 27 Mar 2000, Aaron C wrote:

> Matt:
> 
> I'm excited now.  The patch worked great for the most part.  I now get a
> /proc/scsi/scsi entry.  Only problem is that I cannot mount the drive.
> The error says that there is no media.
> 
> I am again including all the specs and halfway through the long kernel
> listing I have put a comment where the mount failed.  
> 
> This is starting to get cool.  Thanks.  You guys deserve a grant ;)
> 
> Aaron J. Cline
> University of Nebraska
> [EMAIL PROTECTED]
> http://tutcline.yi.org
> 
> "... the injury therefore that we do to a man must be such that we do not
> fear his vengence."  Machiavelli
> 

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Engineer, Qualcomm, Inc.                         Work: [EMAIL PROTECTED]

Why am I talking to a toilet brush?
                                        -- CEO
User Friendly, 4/30/1998
diff -ur -X exclusions linux-2.3.99-pre3/drivers/usb/usb-storage.c 
linux-2.3.99-pre3mdd/drivers/usb/usb-storage.c
--- linux-2.3.99-pre3/drivers/usb/usb-storage.c Thu Mar 23 15:15:18 2000
+++ linux-2.3.99-pre3mdd/drivers/usb/usb-storage.c      Mon Mar 27 23:10:07 2000
@@ -351,6 +351,7 @@
   
        /* send the command to the transport layer */
        result = us->transport(srb, us);
+       US_DEBUGP("return code from transport is 0x%x\n", result);
 
        /* If we got a short transfer, but it was for a command that
         * can have short transfers, we're actually okay
@@ -821,7 +822,7 @@
        /* transfer the data payload for this command, if one exists*/
        if (us_transfer_length(srb)) {
                us_transfer(srb, US_DIRECTION(srb->cmnd[0]));
-               US_DEBUGP("CBI data stage result is 0x%x\n", result);
+               US_DEBUGP("CBI data stage result is 0x%x\n", srb->result);
        }
 
        /* STATUS STAGE */
@@ -840,8 +841,10 @@
        
        /* UFI gives us ASC and ASCQ, like a request sense
         *
-        * REQUEST_SENSE and INQUIRY don't affect the sense data, so we
-        * ignore the information for those commands
+        * REQUEST_SENSE and INQUIRY don't affect the sense data on UFI
+        * devices, so we ignore the information for those commands.  Note
+        * that this means we could be ignoring a real error on these
+        * commands, but that can't be helped.
         */
        if (us->subclass == US_SC_UFI) {
                if (srb->cmnd[0] == REQUEST_SENSE ||
@@ -854,11 +857,14 @@
                                return USB_STOR_TRANSPORT_GOOD;
        }
        
-       /* otherwise, we interpret the data normally */
-       switch (us->ip_data) {
-       case 0x0001: 
+       /* If not UFI, we interpret the data as a result code 
+        * The first byte should always be a 0x0
+        * The second byte & 0x0F should be 0x0 for good, otherwise error 
+        */
+       switch ((us->ip_data & 0xFF0F)) {
+       case 0x0000: 
                return USB_STOR_TRANSPORT_GOOD;
-       case 0x0002: 
+       case 0x0001: 
                return USB_STOR_TRANSPORT_FAILED;
        default: 
                return USB_STOR_TRANSPORT_ERROR;
@@ -876,7 +882,7 @@
        int result;
        __u8 status[2];
 
-       US_DEBUGP("CBC gets a command:\n");
+       US_DEBUGP("CB gets a command:\n");
        US_DEBUG(us_show_command(srb));
 
        /* COMMAND STAGE */
@@ -908,7 +914,7 @@
        /* transfer the data payload for this command, if one exists*/
        if (us_transfer_length(srb)) {
                us_transfer(srb, US_DIRECTION(srb->cmnd[0]));
-               US_DEBUGP("CBC data stage result is 0x%x\n", result);
+               US_DEBUGP("CB data stage result is 0x%x\n", srb->result);
        }
        
        
@@ -1174,6 +1180,7 @@
 /* FIXME: This doesn't actually abort anything */
 static int us_abort( Scsi_Cmnd *srb )
 {
+       printk(KERN_CRIT "usb-storage: abort() requested but not implemented\n" );
        return 0;
 }
 
@@ -1182,6 +1189,7 @@
 {
        struct us_data *us = (struct us_data *)srb->host->hostdata[0];
 
+       printk(KERN_CRIT "usb-storage: bus_reset() requested but not implemented\n" );
        US_DEBUGP("Bus reset requested\n");
        if (us->ip_wanted)
                up(&(us->ip_waitq));
@@ -1192,6 +1200,7 @@
 /* FIXME: This doesn't actually reset anything */
 static int us_host_reset( Scsi_Cmnd *srb )
 {
+       printk(KERN_CRIT "usb-storage: host_reset() requested but not implemented\n" 
+);
        return 0;
 }
 
@@ -1298,36 +1307,27 @@
  */
 
 static Scsi_Host_Template my_host_template = {
-       NULL,                       /* next */
-       NULL,                       /* module */
-       NULL,                       /* proc_dir */
-       usb_stor_proc_info,
-       NULL,                       /* name - points to unique */
-       us_detect,
-       us_release,
-       NULL,                       /* info */
-       NULL,                       /* ioctl */
-       us_command,
-       us_queuecommand,
-       NULL,                       /* eh_strategy */
-       us_abort,
-       us_bus_reset,
-       us_bus_reset,
-       us_host_reset,
-       NULL,                       /* abort */
-       NULL,                       /* reset */
-       NULL,                       /* slave_attach */
-       NULL,                       /* bios_param */
-       NULL,                       /* select_queue_depths */
-       1,                          /* can_queue */
-       -1,                         /* this_id */
-       SG_ALL,                     /* sg_tablesize */
-       1,                          /* cmd_per_lun */
-       0,                          /* present */
-       FALSE,                      /* unchecked_isa_dma */
-       TRUE,                       /* use_clustering */
-       TRUE,                       /* use_new_eh_code */
-       TRUE                        /* emulated */
+       proc_info:      usb_stor_proc_info,
+       detect:         us_detect,
+       release:        us_release,
+       command:        us_command,
+       queuecommand:   us_queuecommand,
+
+       eh_abort_handler:       us_abort,
+       eh_device_reset_handler:us_bus_reset,
+       eh_bus_reset_handler:   us_bus_reset,
+       eh_host_reset_handler:  us_host_reset,
+
+       can_queue:      1,
+       this_id:        -1,
+
+       sg_tablesize:      SG_ALL,
+       cmd_per_lun:       1,
+       present:           0,
+       unchecked_isa_dma: FALSE,
+       use_clustering:    TRUE,
+       use_new_eh_code:   TRUE,
+       emulated:          TRUE,
 };
 
 static unsigned char sense_notready[] = {
@@ -1795,7 +1795,7 @@
                down(&(ss->notify));
                        
                /* now register - our detect function will be called */
-               ss->htmplt.module = &__this_module;
+               ss->htmplt.module = THIS_MODULE;
                scsi_register_module(MODULE_SCSI_HA, &(ss->htmplt));
                
                /* put us in the list */
@@ -1849,19 +1849,6 @@
 
 int __init usb_stor_init(void)
 {
-       /* 
-        * Check to see if the host template is a different size from
-        * what we're expected -- people have updated this in the past
-        * and forgotten about this driver.
-        */
-       if (sizeof(my_host_template) != SCSI_HOST_TEMPLATE_SIZE) {
-               printk(KERN_ERR "usb-storage: SCSI_HOST_TEMPLATE_SIZE bad\n");
-               printk(KERN_ERR 
-                      "usb-storage: expected %d bytes, got %d bytes\n", 
-                      SCSI_HOST_TEMPLATE_SIZE, sizeof(my_host_template)) ;
-               return -1 ;
-       }
-
        /* register the driver, return -1 if error */
        if (usb_register(&storage_driver) < 0)
                return -1;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to