This patch removes the US_FL_DEV_ATTACHED flag, which is now rendered
obsolete by the new hotplug system.

It also adds a comment or two about areas of code that need to be
re-examined.

Greg, please apply.

Matt

# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.670   -> 1.671  
#       drivers/usb/storage/usb.h       1.35    -> 1.36   
#       drivers/usb/storage/scsiglue.c  1.39    -> 1.40   
#       drivers/usb/storage/usb.c       1.71    -> 1.72   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/01/25      [EMAIL PROTECTED]       1.671
# Remove US_FL_DEV_ATTACHED flag.  Added comments to indicate areas that
# need fixing due to new hotplug system.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c    Sat Jan 25 13:08:11 2003
+++ b/drivers/usb/storage/scsiglue.c    Sat Jan 25 13:08:11 2003
@@ -197,11 +197,10 @@
        /* lock the device pointers */
        down(&(us->dev_semaphore));
 
-       /* if the device was removed, then we're already reset */
-       if (!(us->flags & US_FL_DEV_ATTACHED))
-               result = SUCCESS;
-       else
-               result = us->transport_reset(us);
+       /* do the reset */
+       result = us->transport_reset(us);
+
+       /* unlock */
        up(&(us->dev_semaphore));
 
        /* lock access to the state and clear it */
@@ -214,31 +213,27 @@
  * disconnect/reconnect for all drivers which have claimed
  * interfaces, including ourself. */
 /* This is always called with scsi_lock(srb->host) held */
+
+/* FIXME: This needs to be re-examined in the face of the new
+ * hotplug system -- this will implicitly cause a detach/reattach of
+ * usb-storage, which is not what we want now.
+ *
+ * Can we just skip over usb-storage in the while loop?
+ */
 static int usb_storage_bus_reset( Scsi_Cmnd *srb )
 {
-       struct us_data *us = (struct us_data *)srb->host->hostdata[0];
+       struct us_data *us;
        int i;
        int result;
-       struct usb_device *pusb_dev_save;
 
        /* we use the usb_reset_device() function to handle this for us */
        US_DEBUGP("bus_reset() called\n");
 
+               us = (struct us_data *)srb->host->hostdata[0];
        scsi_unlock(srb->host);
 
-       /* if the device has been removed, this worked */
-       down(&us->dev_semaphore);
-       if (!(us->flags & US_FL_DEV_ATTACHED)) {
-               US_DEBUGP("-- device removed already\n");
-               up(&us->dev_semaphore);
-               scsi_lock(srb->host);
-               return SUCCESS;
-       }
-       pusb_dev_save = us->pusb_dev;
-       up(&us->dev_semaphore);
-
        /* attempt to reset the port */
-       result = usb_reset_device(pusb_dev_save);
+       result = usb_reset_device(us->pusb_dev);
        US_DEBUGP("usb_reset_device returns %d\n", result);
        if (result < 0) {
                scsi_lock(srb->host);
@@ -248,9 +243,9 @@
        /* FIXME: This needs to lock out driver probing while it's working
         * or we can have race conditions */
        /* This functionality really should be provided by the khubd thread */
-       for (i = 0; i < pusb_dev_save->actconfig->desc.bNumInterfaces; i++) {
+       for (i = 0; i < us->pusb_dev->actconfig->desc.bNumInterfaces; i++) {
                struct usb_interface *intf =
-                       &pusb_dev_save->actconfig->interface[i];
+                       &us->pusb_dev->actconfig->interface[i];
 
                /* if this is an unclaimed interface, skip it */
                if (!intf->driver) {
@@ -313,10 +308,6 @@
        /* show the protocol and transport */
        SPRINTF("     Protocol: %s\n", us->protocol_name);
        SPRINTF("    Transport: %s\n", us->transport_name);
-
-       /* show attached status of the device */
-       SPRINTF("     Attached: %s\n", (us->flags & US_FL_DEV_ATTACHED ?
-                       "Yes" : "No"));
 
        /*
         * Calculate start of next buffer, and return value.
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Sat Jan 25 13:08:11 2003
+++ b/drivers/usb/storage/usb.c Sat Jan 25 13:08:11 2003
@@ -385,35 +385,6 @@
                                us->srb->result = CHECK_CONDITION << 1;
                }
 
-               /* our device has gone - pretend not ready */
-               else if (!(us->flags & US_FL_DEV_ATTACHED)) {
-                       US_DEBUGP("Request is for removed device\n");
-                       /* For REQUEST_SENSE, it's the data.  But
-                        * for anything else, it should look like
-                        * we auto-sensed for it.
-                        */
-                       if (us->srb->cmnd[0] == REQUEST_SENSE) {
-                               memcpy(us->srb->request_buffer, 
-                                      usb_stor_sense_notready, 
-                                      sizeof(usb_stor_sense_notready));
-                               us->srb->result = GOOD << 1;
-                       } else if(us->srb->cmnd[0] == INQUIRY) {
-                               /* INQUIRY should always work, per spec... */
-                               unsigned char data_ptr[36] = {
-                                   0x20, 0x80, 0x02, 0x02,
-                                   0x1F, 0x00, 0x00, 0x00};
-                               US_DEBUGP("Faking INQUIRY command for disconnected 
device\n");
-                               fill_inquiry_response(us, data_ptr, 36);
-                               us->srb->result = GOOD << 1;
-                       } else {
-                               /* not ready */
-                               memcpy(us->srb->sense_buffer, 
-                                      usb_stor_sense_notready, 
-                                      sizeof(usb_stor_sense_notready));
-                               us->srb->result = CHECK_CONDITION << 1;
-                       }
-               }  /* !(us->flags & US_FL_DEV_ATTACHED) */
-
                /* Handle those devices which need us to fake 
                 * their inquiry data */
                else if ((us->srb->cmnd[0] == INQUIRY) &&
@@ -537,7 +508,6 @@
        }
 
        /* mark the device as gone */
-       ss->flags &= ~ US_FL_DEV_ATTACHED;
        usb_put_dev(ss->pusb_dev);
        ss->pusb_dev = NULL;
 }
@@ -691,7 +661,6 @@
        /* copy over the subclass and protocol data */
        ss->subclass = subclass;
        ss->protocol = protocol;
-       ss->flags = flags | US_FL_DEV_ATTACHED;
        ss->unusual_dev = unusual_dev;
 
        /* copy over the endpoint data */
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h Sat Jan 25 13:08:11 2003
+++ b/drivers/usb/storage/usb.h Sat Jan 25 13:08:11 2003
@@ -77,7 +77,6 @@
 #define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs fixing   */
 #define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */
 
-#define US_FL_DEV_ATTACHED    0x00010000 /* is the device attached?        */
 #define US_FLIDX_CAN_CANCEL  18  /* 0x00040000  okay to cancel current_urb? */
 #define US_FLIDX_CANCEL_SG   19  /* 0x00080000 okay to cancel current_sg?  */
 
@@ -100,7 +99,6 @@
        /* The device we're working with
         * It's important to note:
         *    (o) you must hold dev_semaphore to change pusb_dev
-        *    (o) DEV_ATTACHED in flags should change whenever pusb_dev does
         */
        struct semaphore        dev_semaphore;   /* protect pusb_dev */
        struct usb_device       *pusb_dev;       /* this usb_device */

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

It was a new hope.
                                        -- Dust Puppy
User Friendly, 12/25/1998

Attachment: msg11090/pgp00000.pgp
Description: PGP signature

Reply via email to