# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.512   -> 1.513  
#	drivers/usb/storage/scsiglue.h	1.3     -> 1.4    
#	drivers/usb/storage/usb.c	1.32    -> 1.33   
#	drivers/usb/storage/scsiglue.c	1.28    -> 1.29   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/08/21	mdharm-usb@one-eyed-alien.net	1.513
# [PATCH] PATCH: fix devices which don't support EVPD
# 
# Apparently, some new 2.5 scsi code tries to get the vital product data
# pages using the INQUIRY command.  Unfortunately, most USB devices do not
# support this.
# 
# The following patch intercepts all EVPD requests and responds with the
# per-spec response of "Illegal Request: Invalid field in CDB".
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c	Wed Aug 21 15:45:33 2002
+++ b/drivers/usb/storage/scsiglue.c	Wed Aug 21 15:45:33 2002
@@ -380,12 +380,21 @@
 	.emulated =		TRUE
 };
 
+/* For a device that is "Not Ready" */
 unsigned char usb_stor_sense_notready[18] = {
 	[0]	= 0x70,			    /* current error */
 	[2]	= 0x02,			    /* not ready */
 	[7]	= 0x0a,			    /* additional length */
 	[12]	= 0x04,			    /* not ready */
 	[13]	= 0x03			    /* manual intervention */
+};
+
+/* To Report "Illegal Request: Invalid Field in CDB */
+unsigned char usb_stor_sense_invalidCDB[18] = {
+	[0]	= 0x70,			    /* current error */
+	[2]	= ILLEGAL_REQUEST,	    /* Illegal Request = 0x05 */
+	[7]	= 0x0a,			    /* additional length */
+	[12]	= 0x24			    /* Invalid Field in CDB */
 };
 
 #define USB_STOR_SCSI_SENSE_HDRSZ 4
diff -Nru a/drivers/usb/storage/scsiglue.h b/drivers/usb/storage/scsiglue.h
--- a/drivers/usb/storage/scsiglue.h	Wed Aug 21 15:45:33 2002
+++ b/drivers/usb/storage/scsiglue.h	Wed Aug 21 15:45:33 2002
@@ -46,6 +46,7 @@
 #include "hosts.h"
 
 extern unsigned char usb_stor_sense_notready[18];
+extern unsigned char usb_stor_sense_invalidCDB[18];
 extern Scsi_Host_Template usb_stor_host_template;
 extern int usb_stor_scsiSense10to6(Scsi_Cmnd*);
 extern int usb_stor_scsiSense6to10(Scsi_Cmnd*);
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c	Wed Aug 21 15:45:33 2002
+++ b/drivers/usb/storage/usb.c	Wed Aug 21 15:45:33 2002
@@ -392,6 +392,17 @@
 			us->srb->result = GOOD << 1;
 		}
 
+		/* handle requests for EVPD, which most USB devices do
+		 * not support */
+		else if((us->srb->cmnd[0] == INQUIRY) &&
+				(us->srb->cmnd[1] & 0x1)) {
+				US_DEBUGP("Faking INQUIRY command for EVPD\n");
+				memcpy(us->srb->sense_buffer, 
+				       usb_stor_sense_invalidCDB, 
+				       sizeof(usb_stor_sense_invalidCDB));
+				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");