aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/transport.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-11-29 04:51:07 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-11-29 04:51:07 -0500
commit0d2cd91bf7b1a7cc1d638296111fcc2bcf5c0bb4 (patch)
treed2ca69347816c27f9dc352581f5d0fe76811cd49 /drivers/usb/storage/transport.c
parent3d95fd6ad8d3cf582a70ed65660017114b6e4065 (diff)
parentcaca6a03d365883564885f2c1da3e88dcf65d139 (diff)
Merge commit 'v3.2-rc3' into next
Diffstat (limited to 'drivers/usb/storage/transport.c')
-rw-r--r--drivers/usb/storage/transport.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index e8ae21b2d387..0e5c91c6187f 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -46,6 +46,7 @@
46#include <linux/sched.h> 46#include <linux/sched.h>
47#include <linux/gfp.h> 47#include <linux/gfp.h>
48#include <linux/errno.h> 48#include <linux/errno.h>
49#include <linux/export.h>
49 50
50#include <linux/usb/quirks.h> 51#include <linux/usb/quirks.h>
51 52
@@ -691,6 +692,9 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
691 int temp_result; 692 int temp_result;
692 struct scsi_eh_save ses; 693 struct scsi_eh_save ses;
693 int sense_size = US_SENSE_SIZE; 694 int sense_size = US_SENSE_SIZE;
695 struct scsi_sense_hdr sshdr;
696 const u8 *scdd;
697 u8 fm_ili;
694 698
695 /* device supports and needs bigger sense buffer */ 699 /* device supports and needs bigger sense buffer */
696 if (us->fflags & US_FL_SANE_SENSE) 700 if (us->fflags & US_FL_SANE_SENSE)
@@ -774,32 +778,30 @@ Retry_Sense:
774 srb->sense_buffer[7] = (US_SENSE_SIZE - 8); 778 srb->sense_buffer[7] = (US_SENSE_SIZE - 8);
775 } 779 }
776 780
781 scsi_normalize_sense(srb->sense_buffer, SCSI_SENSE_BUFFERSIZE,
782 &sshdr);
783
777 US_DEBUGP("-- Result from auto-sense is %d\n", temp_result); 784 US_DEBUGP("-- Result from auto-sense is %d\n", temp_result);
778 US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", 785 US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n",
779 srb->sense_buffer[0], 786 sshdr.response_code, sshdr.sense_key,
780 srb->sense_buffer[2] & 0xf, 787 sshdr.asc, sshdr.ascq);
781 srb->sense_buffer[12],
782 srb->sense_buffer[13]);
783#ifdef CONFIG_USB_STORAGE_DEBUG 788#ifdef CONFIG_USB_STORAGE_DEBUG
784 usb_stor_show_sense( 789 usb_stor_show_sense(sshdr.sense_key, sshdr.asc, sshdr.ascq);
785 srb->sense_buffer[2] & 0xf,
786 srb->sense_buffer[12],
787 srb->sense_buffer[13]);
788#endif 790#endif
789 791
790 /* set the result so the higher layers expect this data */ 792 /* set the result so the higher layers expect this data */
791 srb->result = SAM_STAT_CHECK_CONDITION; 793 srb->result = SAM_STAT_CHECK_CONDITION;
792 794
795 scdd = scsi_sense_desc_find(srb->sense_buffer,
796 SCSI_SENSE_BUFFERSIZE, 4);
797 fm_ili = (scdd ? scdd[3] : srb->sense_buffer[2]) & 0xA0;
798
793 /* We often get empty sense data. This could indicate that 799 /* We often get empty sense data. This could indicate that
794 * everything worked or that there was an unspecified 800 * everything worked or that there was an unspecified
795 * problem. We have to decide which. 801 * problem. We have to decide which.
796 */ 802 */
797 if ( /* Filemark 0, ignore EOM, ILI 0, no sense */ 803 if (sshdr.sense_key == 0 && sshdr.asc == 0 && sshdr.ascq == 0 &&
798 (srb->sense_buffer[2] & 0xaf) == 0 && 804 fm_ili == 0) {
799 /* No ASC or ASCQ */
800 srb->sense_buffer[12] == 0 &&
801 srb->sense_buffer[13] == 0) {
802
803 /* If things are really okay, then let's show that. 805 /* If things are really okay, then let's show that.
804 * Zero out the sense buffer so the higher layers 806 * Zero out the sense buffer so the higher layers
805 * won't realize we did an unsolicited auto-sense. 807 * won't realize we did an unsolicited auto-sense.
@@ -814,7 +816,10 @@ Retry_Sense:
814 */ 816 */
815 } else { 817 } else {
816 srb->result = DID_ERROR << 16; 818 srb->result = DID_ERROR << 16;
817 srb->sense_buffer[2] = HARDWARE_ERROR; 819 if ((sshdr.response_code & 0x72) == 0x72)
820 srb->sense_buffer[1] = HARDWARE_ERROR;
821 else
822 srb->sense_buffer[2] = HARDWARE_ERROR;
818 } 823 }
819 } 824 }
820 } 825 }