]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/storage/scsiglue.c
HP-WMI: additional keycode (or typo)
[linux-2.6-omap-h63xx.git] / drivers / usb / storage / scsiglue.c
index 3fcde9f0fa5fe64df4484fbcb068b5109b858650..09779f6a8179944c922b9e5d7c43b1839c5fbc06 100644 (file)
@@ -1,8 +1,6 @@
 /* Driver for USB Mass Storage compliant devices
  * SCSI layer glue code
  *
- * $Id: scsiglue.c,v 1.26 2002/04/22 03:39:43 mdharm Exp $
- *
  * Current development and maintenance by:
  *   (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
  *
@@ -73,7 +71,6 @@ static const char* host_info(struct Scsi_Host *host)
 static int slave_alloc (struct scsi_device *sdev)
 {
        struct us_data *us = host_to_us(sdev->host);
-       struct usb_host_endpoint *bulk_in_ep;
 
        /*
         * Set the INQUIRY transfer length to 36.  We don't use any of
@@ -82,16 +79,22 @@ static int slave_alloc (struct scsi_device *sdev)
         */
        sdev->inquiry_len = 36;
 
-       /* Scatter-gather buffers (all but the last) must have a length
-        * divisible by the bulk maxpacket size.  Otherwise a data packet
-        * would end up being short, causing a premature end to the data
-        * transfer.  We'll use the maxpacket value of the bulk-IN pipe
-        * to set the SCSI device queue's DMA alignment mask.
+       /* USB has unusual DMA-alignment requirements: Although the
+        * starting address of each scatter-gather element doesn't matter,
+        * the length of each element except the last must be divisible
+        * by the Bulk maxpacket value.  There's currently no way to
+        * express this by block-layer constraints, so we'll cop out
+        * and simply require addresses to be aligned at 512-byte
+        * boundaries.  This is okay since most block I/O involves
+        * hardware sectors that are multiples of 512 bytes in length,
+        * and since host controllers up through USB 2.0 have maxpacket
+        * values no larger than 512.
+        *
+        * But it doesn't suffice for Wireless USB, where Bulk maxpacket
+        * values can be as large as 2048.  To make that work properly
+        * will require changes to the block layer.
         */
-       bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)];
-       blk_queue_update_dma_alignment(sdev->request_queue,
-                       le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1);
-                       /* wMaxPacketSize must be a power of 2 */
+       blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
 
        /*
         * The UFI spec treates the Peripheral Qualifier bits in an
@@ -116,10 +119,10 @@ static int slave_configure(struct scsi_device *sdev)
         * while others have trouble with more than 64K. At this time we
         * are limiting both to 32K (64 sectores).
         */
-       if (us->flags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
+       if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
                unsigned int max_sectors = 64;
 
-               if (us->flags & US_FL_MAX_SECTORS_MIN)
+               if (us->fflags & US_FL_MAX_SECTORS_MIN)
                        max_sectors = PAGE_CACHE_SIZE >> 9;
                if (sdev->request_queue->max_sectors > max_sectors)
                        blk_queue_max_sectors(sdev->request_queue,
@@ -148,7 +151,7 @@ static int slave_configure(struct scsi_device *sdev)
                 * majority of devices work fine, but a few still can't
                 * handle it.  The sd driver will simply assume those
                 * devices are write-enabled. */
-               if (us->flags & US_FL_NO_WP_DETECT)
+               if (us->fflags & US_FL_NO_WP_DETECT)
                        sdev->skip_ms_page_3f = 1;
 
                /* A number of devices have problems with MODE SENSE for
@@ -158,13 +161,13 @@ static int slave_configure(struct scsi_device *sdev)
                /* Some disks return the total number of blocks in response
                 * to READ CAPACITY rather than the highest block number.
                 * If this device makes that mistake, tell the sd driver. */
-               if (us->flags & US_FL_FIX_CAPACITY)
+               if (us->fflags & US_FL_FIX_CAPACITY)
                        sdev->fix_capacity = 1;
 
                /* A few disks have two indistinguishable version, one of
                 * which reports the correct capacity and the other does not.
                 * The sd driver has to guess which is the case. */
-               if (us->flags & US_FL_CAPACITY_HEURISTICS)
+               if (us->fflags & US_FL_CAPACITY_HEURISTICS)
                        sdev->guess_capacity = 1;
 
                /* Some devices report a SCSI revision level above 2 but are
@@ -213,7 +216,7 @@ static int slave_configure(struct scsi_device *sdev)
 
        /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM
         * REMOVAL command, so suppress those commands. */
-       if (us->flags & US_FL_NOT_LOCKABLE)
+       if (us->fflags & US_FL_NOT_LOCKABLE)
                sdev->lockable = 0;
 
        /* this is to satisfy the compiler, tho I don't think the 
@@ -238,7 +241,7 @@ static int queuecommand(struct scsi_cmnd *srb,
        }
 
        /* fail the command if we are disconnecting */
-       if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
                US_DEBUGP("Fail command during disconnect\n");
                srb->result = DID_NO_CONNECT << 16;
                done(srb);
@@ -248,7 +251,7 @@ static int queuecommand(struct scsi_cmnd *srb,
        /* enqueue the command and wake up the control thread */
        srb->scsi_done = done;
        us->srb = srb;
-       up(&(us->sema));
+       complete(&us->cmnd_ready);
 
        return 0;
 }
@@ -280,9 +283,9 @@ static int command_abort(struct scsi_cmnd *srb)
         * with the reset).  Note that we must retain the host lock while
         * calling usb_stor_stop_transport(); otherwise it might interfere
         * with an auto-reset that begins as soon as we release the lock. */
-       set_bit(US_FLIDX_TIMED_OUT, &us->flags);
-       if (!test_bit(US_FLIDX_RESETTING, &us->flags)) {
-               set_bit(US_FLIDX_ABORTING, &us->flags);
+       set_bit(US_FLIDX_TIMED_OUT, &us->dflags);
+       if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) {
+               set_bit(US_FLIDX_ABORTING, &us->dflags);
                usb_stor_stop_transport(us);
        }
        scsi_unlock(us_to_host(us));
@@ -329,7 +332,7 @@ void usb_stor_report_device_reset(struct us_data *us)
        struct Scsi_Host *host = us_to_host(us);
 
        scsi_report_device_reset(host, 0, 0);
-       if (us->flags & US_FL_SCM_MULT_TARG) {
+       if (us->fflags & US_FL_SCM_MULT_TARG) {
                for (i = 1; i < host->max_id; ++i)
                        scsi_report_device_reset(host, 0, i);
        }
@@ -400,7 +403,7 @@ static int proc_info (struct Scsi_Host *host, char *buffer,
                pos += sprintf(pos, "       Quirks:");
 
 #define US_FLAG(name, value) \
-       if (us->flags & value) pos += sprintf(pos, " " #name);
+       if (us->fflags & value) pos += sprintf(pos, " " #name);
 US_DO_ALL_FLAGS
 #undef US_FLAG