aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-05-01 15:35:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-21 18:15:53 -0400
commit7e4d6c387994294ac8198b624ee71e75de60dfd2 (patch)
tree09c8c519a6284f79c38f49347eb7fdf44d8de13e /drivers/usb/storage
parent2742fd8899328345d97a3443fb787b051b79ebae (diff)
usb-storage: separate dynamic flags from fixed flags
This patch (as1089) separates out the dynamic atomic bitflags and the static bitfields in usb-storage. Until now the two sorts of flags have been sharing the same word; this has always been awkward. To help prevent possible confusion, the two new fields each have a different name from the original. us->fflags contains the fixed bitfields (mostly taken from the USB ID table in unusual_devs.h), and us->dflags contains the dynamic atomic bitflags (used with set_bit, test_bit, and so on). Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/isd200.c6
-rw-r--r--drivers/usb/storage/scsiglue.c24
-rw-r--r--drivers/usb/storage/transport.c68
-rw-r--r--drivers/usb/storage/usb.c34
-rw-r--r--drivers/usb/storage/usb.h17
5 files changed, 75 insertions, 74 deletions
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 3addcd8f827b..a153335f3648 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -586,7 +586,7 @@ static void isd200_invoke_transport( struct us_data *us,
586 /* if the command gets aborted by the higher layers, we need to 586 /* if the command gets aborted by the higher layers, we need to
587 * short-circuit all other processing 587 * short-circuit all other processing
588 */ 588 */
589 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 589 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
590 US_DEBUGP("-- command was aborted\n"); 590 US_DEBUGP("-- command was aborted\n");
591 goto Handle_Abort; 591 goto Handle_Abort;
592 } 592 }
@@ -633,7 +633,7 @@ static void isd200_invoke_transport( struct us_data *us,
633 633
634 if (need_auto_sense) { 634 if (need_auto_sense) {
635 result = isd200_read_regs(us); 635 result = isd200_read_regs(us);
636 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 636 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
637 US_DEBUGP("-- auto-sense aborted\n"); 637 US_DEBUGP("-- auto-sense aborted\n");
638 goto Handle_Abort; 638 goto Handle_Abort;
639 } 639 }
@@ -663,7 +663,7 @@ static void isd200_invoke_transport( struct us_data *us,
663 srb->result = DID_ABORT << 16; 663 srb->result = DID_ABORT << 16;
664 664
665 /* permit the reset transfer to take place */ 665 /* permit the reset transfer to take place */
666 clear_bit(US_FLIDX_ABORTING, &us->flags); 666 clear_bit(US_FLIDX_ABORTING, &us->dflags);
667 /* Need reset here */ 667 /* Need reset here */
668} 668}
669 669
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 3fcde9f0fa5f..1caf3f7af349 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -116,10 +116,10 @@ static int slave_configure(struct scsi_device *sdev)
116 * while others have trouble with more than 64K. At this time we 116 * while others have trouble with more than 64K. At this time we
117 * are limiting both to 32K (64 sectores). 117 * are limiting both to 32K (64 sectores).
118 */ 118 */
119 if (us->flags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { 119 if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
120 unsigned int max_sectors = 64; 120 unsigned int max_sectors = 64;
121 121
122 if (us->flags & US_FL_MAX_SECTORS_MIN) 122 if (us->fflags & US_FL_MAX_SECTORS_MIN)
123 max_sectors = PAGE_CACHE_SIZE >> 9; 123 max_sectors = PAGE_CACHE_SIZE >> 9;
124 if (sdev->request_queue->max_sectors > max_sectors) 124 if (sdev->request_queue->max_sectors > max_sectors)
125 blk_queue_max_sectors(sdev->request_queue, 125 blk_queue_max_sectors(sdev->request_queue,
@@ -148,7 +148,7 @@ static int slave_configure(struct scsi_device *sdev)
148 * majority of devices work fine, but a few still can't 148 * majority of devices work fine, but a few still can't
149 * handle it. The sd driver will simply assume those 149 * handle it. The sd driver will simply assume those
150 * devices are write-enabled. */ 150 * devices are write-enabled. */
151 if (us->flags & US_FL_NO_WP_DETECT) 151 if (us->fflags & US_FL_NO_WP_DETECT)
152 sdev->skip_ms_page_3f = 1; 152 sdev->skip_ms_page_3f = 1;
153 153
154 /* A number of devices have problems with MODE SENSE for 154 /* A number of devices have problems with MODE SENSE for
@@ -158,13 +158,13 @@ static int slave_configure(struct scsi_device *sdev)
158 /* Some disks return the total number of blocks in response 158 /* Some disks return the total number of blocks in response
159 * to READ CAPACITY rather than the highest block number. 159 * to READ CAPACITY rather than the highest block number.
160 * If this device makes that mistake, tell the sd driver. */ 160 * If this device makes that mistake, tell the sd driver. */
161 if (us->flags & US_FL_FIX_CAPACITY) 161 if (us->fflags & US_FL_FIX_CAPACITY)
162 sdev->fix_capacity = 1; 162 sdev->fix_capacity = 1;
163 163
164 /* A few disks have two indistinguishable version, one of 164 /* A few disks have two indistinguishable version, one of
165 * which reports the correct capacity and the other does not. 165 * which reports the correct capacity and the other does not.
166 * The sd driver has to guess which is the case. */ 166 * The sd driver has to guess which is the case. */
167 if (us->flags & US_FL_CAPACITY_HEURISTICS) 167 if (us->fflags & US_FL_CAPACITY_HEURISTICS)
168 sdev->guess_capacity = 1; 168 sdev->guess_capacity = 1;
169 169
170 /* Some devices report a SCSI revision level above 2 but are 170 /* Some devices report a SCSI revision level above 2 but are
@@ -213,7 +213,7 @@ static int slave_configure(struct scsi_device *sdev)
213 213
214 /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM 214 /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM
215 * REMOVAL command, so suppress those commands. */ 215 * REMOVAL command, so suppress those commands. */
216 if (us->flags & US_FL_NOT_LOCKABLE) 216 if (us->fflags & US_FL_NOT_LOCKABLE)
217 sdev->lockable = 0; 217 sdev->lockable = 0;
218 218
219 /* this is to satisfy the compiler, tho I don't think the 219 /* this is to satisfy the compiler, tho I don't think the
@@ -238,7 +238,7 @@ static int queuecommand(struct scsi_cmnd *srb,
238 } 238 }
239 239
240 /* fail the command if we are disconnecting */ 240 /* fail the command if we are disconnecting */
241 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 241 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
242 US_DEBUGP("Fail command during disconnect\n"); 242 US_DEBUGP("Fail command during disconnect\n");
243 srb->result = DID_NO_CONNECT << 16; 243 srb->result = DID_NO_CONNECT << 16;
244 done(srb); 244 done(srb);
@@ -280,9 +280,9 @@ static int command_abort(struct scsi_cmnd *srb)
280 * with the reset). Note that we must retain the host lock while 280 * with the reset). Note that we must retain the host lock while
281 * calling usb_stor_stop_transport(); otherwise it might interfere 281 * calling usb_stor_stop_transport(); otherwise it might interfere
282 * with an auto-reset that begins as soon as we release the lock. */ 282 * with an auto-reset that begins as soon as we release the lock. */
283 set_bit(US_FLIDX_TIMED_OUT, &us->flags); 283 set_bit(US_FLIDX_TIMED_OUT, &us->dflags);
284 if (!test_bit(US_FLIDX_RESETTING, &us->flags)) { 284 if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) {
285 set_bit(US_FLIDX_ABORTING, &us->flags); 285 set_bit(US_FLIDX_ABORTING, &us->dflags);
286 usb_stor_stop_transport(us); 286 usb_stor_stop_transport(us);
287 } 287 }
288 scsi_unlock(us_to_host(us)); 288 scsi_unlock(us_to_host(us));
@@ -329,7 +329,7 @@ void usb_stor_report_device_reset(struct us_data *us)
329 struct Scsi_Host *host = us_to_host(us); 329 struct Scsi_Host *host = us_to_host(us);
330 330
331 scsi_report_device_reset(host, 0, 0); 331 scsi_report_device_reset(host, 0, 0);
332 if (us->flags & US_FL_SCM_MULT_TARG) { 332 if (us->fflags & US_FL_SCM_MULT_TARG) {
333 for (i = 1; i < host->max_id; ++i) 333 for (i = 1; i < host->max_id; ++i)
334 scsi_report_device_reset(host, 0, i); 334 scsi_report_device_reset(host, 0, i);
335 } 335 }
@@ -400,7 +400,7 @@ static int proc_info (struct Scsi_Host *host, char *buffer,
400 pos += sprintf(pos, " Quirks:"); 400 pos += sprintf(pos, " Quirks:");
401 401
402#define US_FLAG(name, value) \ 402#define US_FLAG(name, value) \
403 if (us->flags & value) pos += sprintf(pos, " " #name); 403 if (us->fflags & value) pos += sprintf(pos, " " #name);
404US_DO_ALL_FLAGS 404US_DO_ALL_FLAGS
405#undef US_FLAG 405#undef US_FLAG
406 406
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 6610d2dd1e7f..2f88bb958bad 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -75,14 +75,14 @@
75 * by a separate code path.) 75 * by a separate code path.)
76 * 76 *
77 * The abort function (usb_storage_command_abort() in scsiglue.c) first 77 * The abort function (usb_storage_command_abort() in scsiglue.c) first
78 * sets the machine state and the ABORTING bit in us->flags to prevent 78 * sets the machine state and the ABORTING bit in us->dflags to prevent
79 * new URBs from being submitted. It then calls usb_stor_stop_transport() 79 * new URBs from being submitted. It then calls usb_stor_stop_transport()
80 * below, which atomically tests-and-clears the URB_ACTIVE bit in us->flags 80 * below, which atomically tests-and-clears the URB_ACTIVE bit in us->dflags
81 * to see if the current_urb needs to be stopped. Likewise, the SG_ACTIVE 81 * to see if the current_urb needs to be stopped. Likewise, the SG_ACTIVE
82 * bit is tested to see if the current_sg scatter-gather request needs to be 82 * bit is tested to see if the current_sg scatter-gather request needs to be
83 * stopped. The timeout callback routine does much the same thing. 83 * stopped. The timeout callback routine does much the same thing.
84 * 84 *
85 * When a disconnect occurs, the DISCONNECTING bit in us->flags is set to 85 * When a disconnect occurs, the DISCONNECTING bit in us->dflags is set to
86 * prevent new URBs from being submitted, and usb_stor_stop_transport() is 86 * prevent new URBs from being submitted, and usb_stor_stop_transport() is
87 * called to stop any ongoing requests. 87 * called to stop any ongoing requests.
88 * 88 *
@@ -128,7 +128,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
128 int status; 128 int status;
129 129
130 /* don't submit URBs during abort/disconnect processing */ 130 /* don't submit URBs during abort/disconnect processing */
131 if (us->flags & ABORTING_OR_DISCONNECTING) 131 if (us->dflags & ABORTING_OR_DISCONNECTING)
132 return -EIO; 132 return -EIO;
133 133
134 /* set up data structures for the wakeup system */ 134 /* set up data structures for the wakeup system */
@@ -159,13 +159,13 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
159 159
160 /* since the URB has been submitted successfully, it's now okay 160 /* since the URB has been submitted successfully, it's now okay
161 * to cancel it */ 161 * to cancel it */
162 set_bit(US_FLIDX_URB_ACTIVE, &us->flags); 162 set_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
163 163
164 /* did an abort/disconnect occur during the submission? */ 164 /* did an abort/disconnect occur during the submission? */
165 if (us->flags & ABORTING_OR_DISCONNECTING) { 165 if (us->dflags & ABORTING_OR_DISCONNECTING) {
166 166
167 /* cancel the URB, if it hasn't been cancelled already */ 167 /* cancel the URB, if it hasn't been cancelled already */
168 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->flags)) { 168 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
169 US_DEBUGP("-- cancelling URB\n"); 169 US_DEBUGP("-- cancelling URB\n");
170 usb_unlink_urb(us->current_urb); 170 usb_unlink_urb(us->current_urb);
171 } 171 }
@@ -175,7 +175,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
175 timeleft = wait_for_completion_interruptible_timeout( 175 timeleft = wait_for_completion_interruptible_timeout(
176 &urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT); 176 &urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT);
177 177
178 clear_bit(US_FLIDX_URB_ACTIVE, &us->flags); 178 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
179 179
180 if (timeleft <= 0) { 180 if (timeleft <= 0) {
181 US_DEBUGP("%s -- cancelling URB\n", 181 US_DEBUGP("%s -- cancelling URB\n",
@@ -420,7 +420,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
420 int result; 420 int result;
421 421
422 /* don't submit s-g requests during abort/disconnect processing */ 422 /* don't submit s-g requests during abort/disconnect processing */
423 if (us->flags & ABORTING_OR_DISCONNECTING) 423 if (us->dflags & ABORTING_OR_DISCONNECTING)
424 return USB_STOR_XFER_ERROR; 424 return USB_STOR_XFER_ERROR;
425 425
426 /* initialize the scatter-gather request block */ 426 /* initialize the scatter-gather request block */
@@ -435,13 +435,13 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
435 435
436 /* since the block has been initialized successfully, it's now 436 /* since the block has been initialized successfully, it's now
437 * okay to cancel it */ 437 * okay to cancel it */
438 set_bit(US_FLIDX_SG_ACTIVE, &us->flags); 438 set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
439 439
440 /* did an abort/disconnect occur during the submission? */ 440 /* did an abort/disconnect occur during the submission? */
441 if (us->flags & ABORTING_OR_DISCONNECTING) { 441 if (us->dflags & ABORTING_OR_DISCONNECTING) {
442 442
443 /* cancel the request, if it hasn't been cancelled already */ 443 /* cancel the request, if it hasn't been cancelled already */
444 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) { 444 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
445 US_DEBUGP("-- cancelling sg request\n"); 445 US_DEBUGP("-- cancelling sg request\n");
446 usb_sg_cancel(&us->current_sg); 446 usb_sg_cancel(&us->current_sg);
447 } 447 }
@@ -449,7 +449,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
449 449
450 /* wait for the completion of the transfer */ 450 /* wait for the completion of the transfer */
451 usb_sg_wait(&us->current_sg); 451 usb_sg_wait(&us->current_sg);
452 clear_bit(US_FLIDX_SG_ACTIVE, &us->flags); 452 clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
453 453
454 result = us->current_sg.status; 454 result = us->current_sg.status;
455 if (act_len) 455 if (act_len)
@@ -530,7 +530,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
530 /* if the command gets aborted by the higher layers, we need to 530 /* if the command gets aborted by the higher layers, we need to
531 * short-circuit all other processing 531 * short-circuit all other processing
532 */ 532 */
533 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 533 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
534 US_DEBUGP("-- command was aborted\n"); 534 US_DEBUGP("-- command was aborted\n");
535 srb->result = DID_ABORT << 16; 535 srb->result = DID_ABORT << 16;
536 goto Handle_Errors; 536 goto Handle_Errors;
@@ -616,7 +616,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
616 /* let's clean up right away */ 616 /* let's clean up right away */
617 scsi_eh_restore_cmnd(srb, &ses); 617 scsi_eh_restore_cmnd(srb, &ses);
618 618
619 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 619 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
620 US_DEBUGP("-- auto-sense aborted\n"); 620 US_DEBUGP("-- auto-sense aborted\n");
621 srb->result = DID_ABORT << 16; 621 srb->result = DID_ABORT << 16;
622 goto Handle_Errors; 622 goto Handle_Errors;
@@ -629,7 +629,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
629 * auto-sense is perfectly valid 629 * auto-sense is perfectly valid
630 */ 630 */
631 srb->result = DID_ERROR << 16; 631 srb->result = DID_ERROR << 16;
632 if (!(us->flags & US_FL_SCM_MULT_TARG)) 632 if (!(us->fflags & US_FL_SCM_MULT_TARG))
633 goto Handle_Errors; 633 goto Handle_Errors;
634 return; 634 return;
635 } 635 }
@@ -679,8 +679,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
679 /* Set the RESETTING bit, and clear the ABORTING bit so that 679 /* Set the RESETTING bit, and clear the ABORTING bit so that
680 * the reset may proceed. */ 680 * the reset may proceed. */
681 scsi_lock(us_to_host(us)); 681 scsi_lock(us_to_host(us));
682 set_bit(US_FLIDX_RESETTING, &us->flags); 682 set_bit(US_FLIDX_RESETTING, &us->dflags);
683 clear_bit(US_FLIDX_ABORTING, &us->flags); 683 clear_bit(US_FLIDX_ABORTING, &us->dflags);
684 scsi_unlock(us_to_host(us)); 684 scsi_unlock(us_to_host(us));
685 685
686 /* We must release the device lock because the pre_reset routine 686 /* We must release the device lock because the pre_reset routine
@@ -695,7 +695,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
695 scsi_unlock(us_to_host(us)); 695 scsi_unlock(us_to_host(us));
696 us->transport_reset(us); 696 us->transport_reset(us);
697 } 697 }
698 clear_bit(US_FLIDX_RESETTING, &us->flags); 698 clear_bit(US_FLIDX_RESETTING, &us->dflags);
699} 699}
700 700
701/* Stop the current URB transfer */ 701/* Stop the current URB transfer */
@@ -707,13 +707,13 @@ void usb_stor_stop_transport(struct us_data *us)
707 * let's wake it up. The test_and_clear_bit() call 707 * let's wake it up. The test_and_clear_bit() call
708 * guarantees that if a URB has just been submitted, 708 * guarantees that if a URB has just been submitted,
709 * it won't be cancelled more than once. */ 709 * it won't be cancelled more than once. */
710 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->flags)) { 710 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
711 US_DEBUGP("-- cancelling URB\n"); 711 US_DEBUGP("-- cancelling URB\n");
712 usb_unlink_urb(us->current_urb); 712 usb_unlink_urb(us->current_urb);
713 } 713 }
714 714
715 /* If we are waiting for a scatter-gather operation, cancel it. */ 715 /* If we are waiting for a scatter-gather operation, cancel it. */
716 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) { 716 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
717 US_DEBUGP("-- cancelling sg request\n"); 717 US_DEBUGP("-- cancelling sg request\n");
718 usb_sg_cancel(&us->current_sg); 718 usb_sg_cancel(&us->current_sg);
719 } 719 }
@@ -914,7 +914,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
914 unsigned int cbwlen = US_BULK_CB_WRAP_LEN; 914 unsigned int cbwlen = US_BULK_CB_WRAP_LEN;
915 915
916 /* Take care of BULK32 devices; set extra byte to 0 */ 916 /* Take care of BULK32 devices; set extra byte to 0 */
917 if ( unlikely(us->flags & US_FL_BULK32)) { 917 if (unlikely(us->fflags & US_FL_BULK32)) {
918 cbwlen = 32; 918 cbwlen = 32;
919 us->iobuf[31] = 0; 919 us->iobuf[31] = 0;
920 } 920 }
@@ -925,7 +925,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
925 bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; 925 bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0;
926 bcb->Tag = ++us->tag; 926 bcb->Tag = ++us->tag;
927 bcb->Lun = srb->device->lun; 927 bcb->Lun = srb->device->lun;
928 if (us->flags & US_FL_SCM_MULT_TARG) 928 if (us->fflags & US_FL_SCM_MULT_TARG)
929 bcb->Lun |= srb->device->id << 4; 929 bcb->Lun |= srb->device->id << 4;
930 bcb->Length = srb->cmd_len; 930 bcb->Length = srb->cmd_len;
931 931
@@ -951,7 +951,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
951 /* Some USB-IDE converter chips need a 100us delay between the 951 /* Some USB-IDE converter chips need a 100us delay between the
952 * command phase and the data phase. Some devices need a little 952 * command phase and the data phase. Some devices need a little
953 * more than that, probably because of clock rate inaccuracies. */ 953 * more than that, probably because of clock rate inaccuracies. */
954 if (unlikely(us->flags & US_FL_GO_SLOW)) 954 if (unlikely(us->fflags & US_FL_GO_SLOW))
955 udelay(125); 955 udelay(125);
956 956
957 if (transfer_length) { 957 if (transfer_length) {
@@ -1010,7 +1010,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1010 US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", 1010 US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
1011 le32_to_cpu(bcs->Signature), bcs->Tag, 1011 le32_to_cpu(bcs->Signature), bcs->Tag,
1012 residue, bcs->Status); 1012 residue, bcs->Status);
1013 if (!(bcs->Tag == us->tag || (us->flags & US_FL_BULK_IGNORE_TAG)) || 1013 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) ||
1014 bcs->Status > US_BULK_STAT_PHASE) { 1014 bcs->Status > US_BULK_STAT_PHASE) {
1015 US_DEBUGP("Bulk logical error\n"); 1015 US_DEBUGP("Bulk logical error\n");
1016 return USB_STOR_TRANSPORT_ERROR; 1016 return USB_STOR_TRANSPORT_ERROR;
@@ -1035,7 +1035,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1035 /* try to compute the actual residue, based on how much data 1035 /* try to compute the actual residue, based on how much data
1036 * was really transferred and what the device tells us */ 1036 * was really transferred and what the device tells us */
1037 if (residue) { 1037 if (residue) {
1038 if (!(us->flags & US_FL_IGNORE_RESIDUE)) { 1038 if (!(us->fflags & US_FL_IGNORE_RESIDUE)) {
1039 residue = min(residue, transfer_length); 1039 residue = min(residue, transfer_length);
1040 scsi_set_resid(srb, max(scsi_get_resid(srb), 1040 scsi_set_resid(srb, max(scsi_get_resid(srb),
1041 (int) residue)); 1041 (int) residue));
@@ -1090,7 +1090,7 @@ static int usb_stor_reset_common(struct us_data *us,
1090 int result; 1090 int result;
1091 int result2; 1091 int result2;
1092 1092
1093 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 1093 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1094 US_DEBUGP("No reset during disconnect\n"); 1094 US_DEBUGP("No reset during disconnect\n");
1095 return -EIO; 1095 return -EIO;
1096 } 1096 }
@@ -1103,12 +1103,12 @@ static int usb_stor_reset_common(struct us_data *us,
1103 return result; 1103 return result;
1104 } 1104 }
1105 1105
1106 /* Give the device some time to recover from the reset, 1106 /* Give the device some time to recover from the reset,
1107 * but don't delay disconnect processing. */ 1107 * but don't delay disconnect processing. */
1108 wait_event_interruptible_timeout(us->delay_wait, 1108 wait_event_interruptible_timeout(us->delay_wait,
1109 test_bit(US_FLIDX_DISCONNECTING, &us->flags), 1109 test_bit(US_FLIDX_DISCONNECTING, &us->dflags),
1110 HZ*6); 1110 HZ*6);
1111 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 1111 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1112 US_DEBUGP("Reset interrupted by disconnect\n"); 1112 US_DEBUGP("Reset interrupted by disconnect\n");
1113 return -EIO; 1113 return -EIO;
1114 } 1114 }
@@ -1170,7 +1170,7 @@ int usb_stor_port_reset(struct us_data *us)
1170 US_DEBUGP("unable to lock device for reset: %d\n", result); 1170 US_DEBUGP("unable to lock device for reset: %d\n", result);
1171 else { 1171 else {
1172 /* Were we disconnected while waiting for the lock? */ 1172 /* Were we disconnected while waiting for the lock? */
1173 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 1173 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1174 result = -EIO; 1174 result = -EIO;
1175 US_DEBUGP("No reset during disconnect\n"); 1175 US_DEBUGP("No reset during disconnect\n");
1176 } else { 1176 } else {
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e268aacb773a..78c0c7ee6b99 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -321,7 +321,7 @@ static int usb_stor_control_thread(void * __us)
321 mutex_lock(&(us->dev_mutex)); 321 mutex_lock(&(us->dev_mutex));
322 322
323 /* if the device has disconnected, we are free to exit */ 323 /* if the device has disconnected, we are free to exit */
324 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 324 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
325 US_DEBUGP("-- exiting\n"); 325 US_DEBUGP("-- exiting\n");
326 mutex_unlock(&us->dev_mutex); 326 mutex_unlock(&us->dev_mutex);
327 break; 327 break;
@@ -331,7 +331,7 @@ static int usb_stor_control_thread(void * __us)
331 scsi_lock(host); 331 scsi_lock(host);
332 332
333 /* has the command timed out *already* ? */ 333 /* has the command timed out *already* ? */
334 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 334 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
335 us->srb->result = DID_ABORT << 16; 335 us->srb->result = DID_ABORT << 16;
336 goto SkipForAbort; 336 goto SkipForAbort;
337 } 337 }
@@ -350,7 +350,7 @@ static int usb_stor_control_thread(void * __us)
350 * the maximum known LUN 350 * the maximum known LUN
351 */ 351 */
352 else if (us->srb->device->id && 352 else if (us->srb->device->id &&
353 !(us->flags & US_FL_SCM_MULT_TARG)) { 353 !(us->fflags & US_FL_SCM_MULT_TARG)) {
354 US_DEBUGP("Bad target number (%d:%d)\n", 354 US_DEBUGP("Bad target number (%d:%d)\n",
355 us->srb->device->id, us->srb->device->lun); 355 us->srb->device->id, us->srb->device->lun);
356 us->srb->result = DID_BAD_TARGET << 16; 356 us->srb->result = DID_BAD_TARGET << 16;
@@ -365,7 +365,7 @@ static int usb_stor_control_thread(void * __us)
365 /* Handle those devices which need us to fake 365 /* Handle those devices which need us to fake
366 * their inquiry data */ 366 * their inquiry data */
367 else if ((us->srb->cmnd[0] == INQUIRY) && 367 else if ((us->srb->cmnd[0] == INQUIRY) &&
368 (us->flags & US_FL_FIX_INQUIRY)) { 368 (us->fflags & US_FL_FIX_INQUIRY)) {
369 unsigned char data_ptr[36] = { 369 unsigned char data_ptr[36] = {
370 0x00, 0x80, 0x02, 0x02, 370 0x00, 0x80, 0x02, 0x02,
371 0x1F, 0x00, 0x00, 0x00}; 371 0x1F, 0x00, 0x00, 0x00};
@@ -403,12 +403,12 @@ SkipForAbort:
403 * the TIMED_OUT flag, not srb->result == DID_ABORT, because 403 * the TIMED_OUT flag, not srb->result == DID_ABORT, because
404 * the timeout might have occurred after the command had 404 * the timeout might have occurred after the command had
405 * already completed with a different result code. */ 405 * already completed with a different result code. */
406 if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { 406 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
407 complete(&(us->notify)); 407 complete(&(us->notify));
408 408
409 /* Allow USB transfers to resume */ 409 /* Allow USB transfers to resume */
410 clear_bit(US_FLIDX_ABORTING, &us->flags); 410 clear_bit(US_FLIDX_ABORTING, &us->dflags);
411 clear_bit(US_FLIDX_TIMED_OUT, &us->flags); 411 clear_bit(US_FLIDX_TIMED_OUT, &us->dflags);
412 } 412 }
413 413
414 /* finished working on this command */ 414 /* finished working on this command */
@@ -500,9 +500,9 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
500 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? 500 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
501 idesc->bInterfaceProtocol : 501 idesc->bInterfaceProtocol :
502 unusual_dev->useTransport; 502 unusual_dev->useTransport;
503 us->flags = USB_US_ORIG_FLAGS(id->driver_info); 503 us->fflags = USB_US_ORIG_FLAGS(id->driver_info);
504 504
505 if (us->flags & US_FL_IGNORE_DEVICE) { 505 if (us->fflags & US_FL_IGNORE_DEVICE) {
506 printk(KERN_INFO USB_STORAGE "device ignored\n"); 506 printk(KERN_INFO USB_STORAGE "device ignored\n");
507 return -ENODEV; 507 return -ENODEV;
508 } 508 }
@@ -512,7 +512,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
512 * disable it if we're in full-speed 512 * disable it if we're in full-speed
513 */ 513 */
514 if (dev->speed != USB_SPEED_HIGH) 514 if (dev->speed != USB_SPEED_HIGH)
515 us->flags &= ~US_FL_GO_SLOW; 515 us->fflags &= ~US_FL_GO_SLOW;
516 516
517 /* Log a message if a non-generic unusual_dev entry contains an 517 /* Log a message if a non-generic unusual_dev entry contains an
518 * unnecessary subclass or protocol override. This may stimulate 518 * unnecessary subclass or protocol override. This may stimulate
@@ -533,7 +533,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
533 if (unusual_dev->useTransport != US_PR_DEVICE && 533 if (unusual_dev->useTransport != US_PR_DEVICE &&
534 us->protocol == idesc->bInterfaceProtocol) 534 us->protocol == idesc->bInterfaceProtocol)
535 msg += 2; 535 msg += 2;
536 if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE)) 536 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE))
537 printk(KERN_NOTICE USB_STORAGE "This device " 537 printk(KERN_NOTICE USB_STORAGE "This device "
538 "(%04x,%04x,%04x S %02x P %02x)" 538 "(%04x,%04x,%04x S %02x P %02x)"
539 " has %s in unusual_devs.h (kernel" 539 " has %s in unusual_devs.h (kernel"
@@ -663,7 +663,7 @@ static int get_transport(struct us_data *us)
663 US_DEBUGP("Transport: %s\n", us->transport_name); 663 US_DEBUGP("Transport: %s\n", us->transport_name);
664 664
665 /* fix for single-lun devices */ 665 /* fix for single-lun devices */
666 if (us->flags & US_FL_SINGLE_LUN) 666 if (us->fflags & US_FL_SINGLE_LUN)
667 us->max_lun = 0; 667 us->max_lun = 0;
668 return 0; 668 return 0;
669} 669}
@@ -824,7 +824,7 @@ static void usb_stor_release_resources(struct us_data *us)
824 * any more commands. 824 * any more commands.
825 */ 825 */
826 US_DEBUGP("-- sending exit command to thread\n"); 826 US_DEBUGP("-- sending exit command to thread\n");
827 set_bit(US_FLIDX_DISCONNECTING, &us->flags); 827 set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
828 up(&us->sema); 828 up(&us->sema);
829 if (us->ctl_thread) 829 if (us->ctl_thread)
830 kthread_stop(us->ctl_thread); 830 kthread_stop(us->ctl_thread);
@@ -868,7 +868,7 @@ static void quiesce_and_remove_host(struct us_data *us)
868 /* Prevent new USB transfers, stop the current command, and 868 /* Prevent new USB transfers, stop the current command, and
869 * interrupt a SCSI-scan or device-reset delay */ 869 * interrupt a SCSI-scan or device-reset delay */
870 scsi_lock(host); 870 scsi_lock(host);
871 set_bit(US_FLIDX_DISCONNECTING, &us->flags); 871 set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
872 scsi_unlock(host); 872 scsi_unlock(host);
873 usb_stor_stop_transport(us); 873 usb_stor_stop_transport(us);
874 wake_up(&us->delay_wait); 874 wake_up(&us->delay_wait);
@@ -919,16 +919,16 @@ static int usb_stor_scan_thread(void * __us)
919 printk(KERN_DEBUG "usb-storage: waiting for device " 919 printk(KERN_DEBUG "usb-storage: waiting for device "
920 "to settle before scanning\n"); 920 "to settle before scanning\n");
921 wait_event_freezable_timeout(us->delay_wait, 921 wait_event_freezable_timeout(us->delay_wait,
922 test_bit(US_FLIDX_DISCONNECTING, &us->flags), 922 test_bit(US_FLIDX_DISCONNECTING, &us->dflags),
923 delay_use * HZ); 923 delay_use * HZ);
924 } 924 }
925 925
926 /* If the device is still connected, perform the scanning */ 926 /* If the device is still connected, perform the scanning */
927 if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 927 if (!test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
928 928
929 /* For bulk-only devices, determine the max LUN value */ 929 /* For bulk-only devices, determine the max LUN value */
930 if (us->protocol == US_PR_BULK && 930 if (us->protocol == US_PR_BULK &&
931 !(us->flags & US_FL_SINGLE_LUN)) { 931 !(us->fflags & US_FL_SINGLE_LUN)) {
932 mutex_lock(&us->dev_mutex); 932 mutex_lock(&us->dev_mutex);
933 us->max_lun = usb_stor_Bulk_max_lun(us); 933 us->max_lun = usb_stor_Bulk_max_lun(us);
934 mutex_unlock(&us->dev_mutex); 934 mutex_unlock(&us->dev_mutex);
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 8d87503e2560..b169132f021b 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -67,15 +67,15 @@ struct us_unusual_dev {
67}; 67};
68 68
69 69
70/* Dynamic flag definitions: used in set_bit() etc. */ 70/* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
71#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */ 71#define US_FLIDX_URB_ACTIVE 0 /* current_urb is in use */
72#define US_FLIDX_SG_ACTIVE 19 /* 0x00080000 current_sg is in use */ 72#define US_FLIDX_SG_ACTIVE 1 /* current_sg is in use */
73#define US_FLIDX_ABORTING 20 /* 0x00100000 abort is in progress */ 73#define US_FLIDX_ABORTING 2 /* abort is in progress */
74#define US_FLIDX_DISCONNECTING 21 /* 0x00200000 disconnect in progress */ 74#define US_FLIDX_DISCONNECTING 3 /* disconnect in progress */
75#define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \ 75#define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \
76 (1UL << US_FLIDX_DISCONNECTING)) 76 (1UL << US_FLIDX_DISCONNECTING))
77#define US_FLIDX_RESETTING 22 /* 0x00400000 device reset in progress */ 77#define US_FLIDX_RESETTING 4 /* device reset in progress */
78#define US_FLIDX_TIMED_OUT 23 /* 0x00800000 SCSI midlayer timed out */ 78#define US_FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */
79 79
80 80
81#define USB_STOR_STRING_LEN 32 81#define USB_STOR_STRING_LEN 32
@@ -109,7 +109,8 @@ struct us_data {
109 struct usb_device *pusb_dev; /* this usb_device */ 109 struct usb_device *pusb_dev; /* this usb_device */
110 struct usb_interface *pusb_intf; /* this interface */ 110 struct usb_interface *pusb_intf; /* this interface */
111 struct us_unusual_dev *unusual_dev; /* device-filter entry */ 111 struct us_unusual_dev *unusual_dev; /* device-filter entry */
112 unsigned long flags; /* from filter initially */ 112 unsigned long fflags; /* fixed flags from filter */
113 unsigned long dflags; /* dynamic atomic bitflags */
113 unsigned int send_bulk_pipe; /* cached pipe values */ 114 unsigned int send_bulk_pipe; /* cached pipe values */
114 unsigned int recv_bulk_pipe; 115 unsigned int recv_bulk_pipe;
115 unsigned int send_ctrl_pipe; 116 unsigned int send_ctrl_pipe;