diff options
author | Matthew Dharm <mdharm-usb@one-eyed-alien.net> | 2005-07-28 17:43:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-08 19:22:54 -0400 |
commit | 0f64e078139109d1902e5b1274c23cec9a9ad12e (patch) | |
tree | 282cb78a17c0ed2dc403dc7712cda1fc348e2123 /drivers/usb/storage | |
parent | 9a57116bc9e36c9accc869f666e1d25c5e2cdcbf (diff) |
[PATCH] USB Storage: remove dependency on SCSI-provided serial/tag number
This patch started life as as531 from Alan Stern. It has been rediffed
against the latest tree.
The SCSI people have deprecated the use of scsi_cmnd.serial_number for
anything other than printk. Worse than that, the SCSI core doesn't
always increment the number (when the error handler is running, for
example). So this patch creates a locally-stored value for use in
bulk-only tags. The net result is a simplification, since we no longer
have to save & restore the serial_number value while autosensing.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: 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/transport.c | 10 | ||||
-rw-r--r-- | drivers/usb/storage/usb.h | 1 |
2 files changed, 3 insertions, 8 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index e6b1c6cf07f2..e42875152c34 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -611,7 +611,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
611 | unsigned char old_sc_data_direction; | 611 | unsigned char old_sc_data_direction; |
612 | unsigned char old_cmd_len; | 612 | unsigned char old_cmd_len; |
613 | unsigned char old_cmnd[MAX_COMMAND_SIZE]; | 613 | unsigned char old_cmnd[MAX_COMMAND_SIZE]; |
614 | unsigned long old_serial_number; | ||
615 | int old_resid; | 614 | int old_resid; |
616 | 615 | ||
617 | US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); | 616 | US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); |
@@ -648,10 +647,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
648 | old_sg = srb->use_sg; | 647 | old_sg = srb->use_sg; |
649 | srb->use_sg = 0; | 648 | srb->use_sg = 0; |
650 | 649 | ||
651 | /* change the serial number -- toggle the high bit*/ | ||
652 | old_serial_number = srb->serial_number; | ||
653 | srb->serial_number ^= 0x80000000; | ||
654 | |||
655 | /* issue the auto-sense command */ | 650 | /* issue the auto-sense command */ |
656 | old_resid = srb->resid; | 651 | old_resid = srb->resid; |
657 | srb->resid = 0; | 652 | srb->resid = 0; |
@@ -662,7 +657,6 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
662 | srb->request_buffer = old_request_buffer; | 657 | srb->request_buffer = old_request_buffer; |
663 | srb->request_bufflen = old_request_bufflen; | 658 | srb->request_bufflen = old_request_bufflen; |
664 | srb->use_sg = old_sg; | 659 | srb->use_sg = old_sg; |
665 | srb->serial_number = old_serial_number; | ||
666 | srb->sc_data_direction = old_sc_data_direction; | 660 | srb->sc_data_direction = old_sc_data_direction; |
667 | srb->cmd_len = old_cmd_len; | 661 | srb->cmd_len = old_cmd_len; |
668 | memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE); | 662 | memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE); |
@@ -985,7 +979,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
985 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 979 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
986 | bcb->DataTransferLength = cpu_to_le32(transfer_length); | 980 | bcb->DataTransferLength = cpu_to_le32(transfer_length); |
987 | bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; | 981 | bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; |
988 | bcb->Tag = srb->serial_number; | 982 | bcb->Tag = ++us->tag; |
989 | bcb->Lun = srb->device->lun; | 983 | bcb->Lun = srb->device->lun; |
990 | if (us->flags & US_FL_SCM_MULT_TARG) | 984 | if (us->flags & US_FL_SCM_MULT_TARG) |
991 | bcb->Lun |= srb->device->id << 4; | 985 | bcb->Lun |= srb->device->id << 4; |
@@ -1074,7 +1068,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1074 | US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", | 1068 | US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", |
1075 | le32_to_cpu(bcs->Signature), bcs->Tag, | 1069 | le32_to_cpu(bcs->Signature), bcs->Tag, |
1076 | residue, bcs->Status); | 1070 | residue, bcs->Status); |
1077 | if (bcs->Tag != srb->serial_number || bcs->Status > US_BULK_STAT_PHASE) { | 1071 | if (bcs->Tag != us->tag || bcs->Status > US_BULK_STAT_PHASE) { |
1078 | US_DEBUGP("Bulk logical error\n"); | 1072 | US_DEBUGP("Bulk logical error\n"); |
1079 | return USB_STOR_TRANSPORT_ERROR; | 1073 | return USB_STOR_TRANSPORT_ERROR; |
1080 | } | 1074 | } |
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 625b7aa98074..a195adae57b6 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h | |||
@@ -158,6 +158,7 @@ struct us_data { | |||
158 | 158 | ||
159 | /* SCSI interfaces */ | 159 | /* SCSI interfaces */ |
160 | struct scsi_cmnd *srb; /* current srb */ | 160 | struct scsi_cmnd *srb; /* current srb */ |
161 | unsigned int tag; /* current dCBWTag */ | ||
161 | 162 | ||
162 | /* thread information */ | 163 | /* thread information */ |
163 | int pid; /* control thread */ | 164 | int pid; /* control thread */ |