We're definately getting closer here...

I really don't like the 8 byte array.  Partially because you implemented it
as a character string... mostly because I don't think it makes sense to
carry 8 bytes for all devices when, at most, all that is going to change is
the perhiperal device type.

And most (all?) devices which will need this will be direct-access devices.

For now, I'd rather have a patch which uses a "standard" 8 byte header on
the INQUIRY data, and then when we find a device which needs a fake inquiry
response which isn't a direct-access device, we can look at what actually
needs to be changed and change it appropriately.  Right now, we're trying
to solve a problem we may not even have.

Tho I definately like the way to intercept the command and use the flag
now.

Matt

On Sun, Mar 04, 2001 at 12:23:15PM -0600, [EMAIL PROTECTED] wrote:
> On Sat, Mar 03, 2001 at 11:57:25PM -0800, Matthew Dharm wrote:
> > Nope.  Search on the web for the SCSI-II command spec for the info.
> 
> Found a copy.  Wow, everything makes a lot more sense now. :)
> 
> > Close, but I'd rather head it off in the control thread.  Look for the
> > special case code for devices that can't handle START_STOP.
> 
> Found it.  Ah, this would definately be a lot cleaner.  
> 
> > > Am I getting closer?
> > 
> > Yes. :)
> 
> I have created a new patch, which is much smaller than my first attempt.
> This patch is against linux-2.4.1.  I decided to work on my workstation
> and didn't want to reboot.  Here's what I did this time.
> 
> - Added an 8-byte array to struct us_unusual_dev which it the start of
>   the faked inquiry response.  I modeled this after sddr09.c.  
> 
> - Added a block in usb_stor_control_thread() just after the START_STOP
>   check to check for INQUIRY.  I create the fake response using a local
>   buffer, the new array in unusual_dev and a call to
>   fill_inquiry_response().  I fake the command just like the block for
>   START_STOP.  
> 
> - Updated the UNUSUAL_DEV marcos to reflect the new structure.
> 
> This works for me.  I like the idea of the 8-byte array, but having NULL
> characters in there bothers me.  I hope that's just a person stigma.
> 
> So how is this patch?
> 
> diff -ur linux-2.4.1/drivers/usb/storage/unusual_devs.h 
>linux-2.4.1-taz/drivers/usb/storage/unusual_devs.h
> --- linux-2.4.1/drivers/usb/storage/unusual_devs.h    Sun Feb  4 22:42:42 2001
> +++ linux-2.4.1-taz/drivers/usb/storage/unusual_devs.h        Sun Mar  4 12:08:35 
>2001
> @@ -40,28 +40,39 @@
>  UNUSUAL_DEV(  0x03ee, 0x0000, 0x0000, 0x0245, 
>               "Mitsumi",
>               "CD-R/RW Drive",
> +             "",
>               US_SC_8020, US_PR_CBI, NULL, 0), 
>  
>  UNUSUAL_DEV(  0x03f0, 0x0107, 0x0200, 0x0200, 
>               "HP",
>               "CD-Writer+",
> +             "",
>               US_SC_8070, US_PR_CB, NULL, 0), 
>  
>  #ifdef CONFIG_USB_STORAGE_HP8200e
>  UNUSUAL_DEV(  0x03f0, 0x0207, 0x0001, 0x0001, 
>               "HP",
>               "CD-Writer+ 8200e",
> +             "",
>               US_SC_8070, US_PR_SCM_ATAPI, init_8200e, 0), 
>  #endif
>  
> +UNUSUAL_DEV(  0x04cb, 0x0100, 0x0000, 0x2210,
> +             "Fujifilm",
> +             "FinePix 1400Zoom",
> +             "\x00\x80\x02\x02\x1f\x00\x00\x00",
> +             US_SC_8070, US_PR_CBI, NULL, US_FL_FIX_INQUIRY),
> +
>  UNUSUAL_DEV(  0x04e6, 0x0001, 0x0200, 0x0200, 
>               "Matshita",
>               "LS-120",
> +             "",
>               US_SC_8020, US_PR_CB, NULL, 0),
>  
>  UNUSUAL_DEV(  0x04e6, 0x0002, 0x0100, 0x0100, 
>               "Shuttle",
>               "eUSCSI Bridge",
> +             "",
>               US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 
>               US_FL_SCM_MULT_TARG ), 
>  
> @@ -69,6 +80,7 @@
>  UNUSUAL_DEV(  0x04e6, 0x0003, 0x0000, 0x9999, 
>               "Sandisk",
>               "ImageMate SDDR09",
> +             "",
>               US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP ),
>  #endif
> @@ -77,6 +89,7 @@
>  UNUSUAL_DEV(  0x0436, 0x0005, 0x0100, 0x0100,
>               "Microtech",
>               "CameraMate (DPCM_USB)",
> +             "",
>               US_SC_SCSI, US_PR_DPCM_USB, NULL,
>               US_FL_START_STOP ),
>  #endif
> @@ -84,85 +97,100 @@
>  UNUSUAL_DEV(  0x04e6, 0x0006, 0x0100, 0x0200, 
>               "Shuttle",
>               "eUSB MMC Adapter",
> +             "",
>               US_SC_SCSI, US_PR_CB, NULL, 
>               US_FL_SINGLE_LUN), 
>  
>  UNUSUAL_DEV(  0x04e6, 0x0007, 0x0100, 0x0200, 
>               "Sony",
>               "Hifd",
> +             "",
>               US_SC_SCSI, US_PR_CB, NULL, 
>               US_FL_SINGLE_LUN), 
>  
>  UNUSUAL_DEV(  0x04e6, 0x0009, 0x0200, 0x0200, 
>               "Shuttle",
>               "eUSB ATA/ATAPI Adapter",
> +             "",
>               US_SC_8020, US_PR_CB, NULL, 0),
>  
>  UNUSUAL_DEV(  0x04e6, 0x000a, 0x0200, 0x0200, 
>               "Shuttle",
>               "eUSB CompactFlash Adapter",
> +             "",
>               US_SC_8020, US_PR_CB, NULL, 0),
>  
>  UNUSUAL_DEV(  0x04e6, 0x000B, 0x0100, 0x0100, 
>               "Shuttle",
>               "eUSCSI Bridge",
> +             "",
>               US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 
>               US_FL_SCM_MULT_TARG ), 
>  
>  UNUSUAL_DEV(  0x04e6, 0x000C, 0x0100, 0x0100, 
>               "Shuttle",
>               "eUSCSI Bridge",
> +             "",
>               US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 
>               US_FL_SCM_MULT_TARG ), 
>  
>  UNUSUAL_DEV(  0x04e6, 0x0101, 0x0200, 0x0200, 
>               "Shuttle",
>               "CD-RW Device",
> +             "",
>               US_SC_8020, US_PR_CB, NULL, 0),
>  
>  UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0210, 
>               "Sony",
>               "DSC-S30/S70/505V/F505", 
> +             "",
>               US_SC_SCSI, US_PR_CB, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE ),
>  
>  UNUSUAL_DEV(  0x054c, 0x002d, 0x0100, 0x0100, 
>               "Sony",
>               "Memorystick MSAC-US1",
> +             "",
>               US_SC_UFI, US_PR_CB, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP ),
>  
>  UNUSUAL_DEV(  0x057b, 0x0000, 0x0000, 0x0299, 
>               "Y-E Data",
>               "Flashbuster-U",
> +             "",
>               US_SC_UFI,  US_PR_CB, NULL,
>               US_FL_SINGLE_LUN),
>  
>  UNUSUAL_DEV(  0x057b, 0x0000, 0x0300, 0x9999, 
>               "Y-E Data",
>               "Flashbuster-U",
> +             "",
>               US_SC_UFI,  US_PR_CBI, NULL,
>               US_FL_SINGLE_LUN),
>  
>  UNUSUAL_DEV(  0x059f, 0xa601, 0x0200, 0x0200, 
>               "LaCie",
>               "USB Hard Disk",
> +             "",
>               US_SC_RBC, US_PR_CB, NULL, 0 ), 
>  
>  UNUSUAL_DEV(  0x05ab, 0x0031, 0x0100, 0x0100, 
>               "In-System",
>               "USB/IDE Bridge (ATAPI ONLY!)",
> +             "",
>               US_SC_8070, US_PR_BULK, NULL, 0 ), 
>  
>  UNUSUAL_DEV(  0x0644, 0x0000, 0x0100, 0x0100, 
>               "TEAC",
>               "Floppy Drive",
> +             "",
>               US_SC_UFI, US_PR_CB, NULL, 0 ), 
>  
>  #ifdef CONFIG_USB_STORAGE_SDDR09
>  UNUSUAL_DEV(  0x066b, 0x0105, 0x0100, 0x0100, 
>               "Olympus",
>               "Camedia MAUSB-2",
> +             "",
>               US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP ),
>  #endif
> @@ -170,22 +198,26 @@
>  UNUSUAL_DEV(  0x0693, 0x0002, 0x0100, 0x0100, 
>               "Hagiwara",
>               "FlashGate SmartMedia",
> +             "",
>               US_SC_SCSI, US_PR_BULK, NULL, 0 ),
>  
>  UNUSUAL_DEV(  0x0693, 0x0005, 0x0100, 0x0100,
>               "Hagiwara",
>               "Flashgate",
> +             "",
>               US_SC_SCSI, US_PR_BULK, NULL, 0 ), 
>  
>  UNUSUAL_DEV(  0x0781, 0x0001, 0x0200, 0x0200, 
>               "Sandisk",
>               "ImageMate SDDR-05a",
> +             "",
>               US_SC_SCSI, US_PR_CB, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP),
>  
>  UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
>                  "Sandisk",
>                  "ImageMate SDDR-12",
> +             "",
>                  US_SC_SCSI, US_PR_CB, NULL,
>                  US_FL_SINGLE_LUN ),
>  
> @@ -193,6 +225,7 @@
>  UNUSUAL_DEV(  0x0781, 0x0200, 0x0100, 0x0100, 
>               "Sandisk",
>               "ImageMate SDDR-09",
> +             "",
>               US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
>               US_FL_SINGLE_LUN | US_FL_START_STOP ),
>  #endif
> @@ -200,12 +233,14 @@
>  UNUSUAL_DEV(  0x0781, 0x0002, 0x0009, 0x0009, 
>               "Sandisk",
>               "ImageMate SDDR-31",
> +             "",
>               US_SC_SCSI, US_PR_BULK, NULL,
>               US_FL_IGNORE_SER),
>  
>  UNUSUAL_DEV(  0x07af, 0x0004, 0x0100, 0x0100, 
>               "Microtech",
>               "USB-SCSI-DB25",
> +             "",
>               US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
>               US_FL_SCM_MULT_TARG ), 
>  
> @@ -213,12 +248,14 @@
>  UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
>                  "Freecom",
>                  "USB-IDE",
> +             "",
>                  US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
>  #endif
>  
>  UNUSUAL_DEV(  0x07af, 0x0005, 0x0100, 0x0100, 
>               "Microtech",
>               "USB-SCSI-HD50",
> +             "",
>               US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
>               US_FL_SCM_MULT_TARG ), 
>  
> @@ -226,6 +263,7 @@
>  UNUSUAL_DEV(  0x07af, 0x0006, 0x0100, 0x0100,
>               "Microtech",
>               "CameraMate (DPCM_USB)",
> +             "",
>               US_SC_SCSI, US_PR_DPCM_USB, NULL,
>               US_FL_START_STOP ),
>  #endif
> diff -ur linux-2.4.1/drivers/usb/storage/usb.c 
>linux-2.4.1-taz/drivers/usb/storage/usb.c
> --- linux-2.4.1/drivers/usb/storage/usb.c     Sun Feb  4 22:42:42 2001
> +++ linux-2.4.1-taz/drivers/usb/storage/usb.c Sun Mar  4 12:01:26 2001
> @@ -109,8 +109,8 @@
>   */
>  
>  #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
> -                 vendorName, productName,useProtocol, useTransport, \
> -                 initFunction, flags) \
> +                 vendorName, productName, inquiryResponse, \
> +                 useProtocol, useTransport, initFunction, flags) \
>  { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax) }
>  
>  static struct usb_device_id storage_usb_ids [] = {
> @@ -160,11 +160,12 @@
>  
>  #undef UNUSUAL_DEV
>  #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
> -                 vendor_name, product_name, use_protocol, use_transport, \
> -                 init_function, Flags) \
> +                 vendor_name, product_name, inquiry_response, \
> +                 use_protocol, use_transport, init_function, Flags) \
>  { \
>       vendorName: vendor_name,        \
>       productName: product_name,      \
> +     inquiryResponse: inquiry_response, \
>       useProtocol: use_protocol,      \
>       useTransport: use_transport,    \
>       initFunction : init_function,   \
> @@ -377,6 +378,22 @@
>                               us->srb = NULL;
>                               break;
>                       }
> +
> +                     if ((us->srb->cmnd[0] == INQUIRY) &&
> +                         (us->flags & US_FL_FIX_INQUIRY)) {
> +                             char data_ptr[36];
> +                             US_DEBUGP("Faking INQUIRY command\n");
> +                             memcpy(data_ptr, 
> +                                     us->unusual_dev->inquiryResponse, 8);
> +                             fill_inquiry_response(us, data_ptr, 36);
> +                             us->srb->result = GOOD << 1;
> +
> +                             set_current_state(TASK_INTERRUPTIBLE);
> +                             us->srb->scsi_done(us->srb);
> +                             us->srb = NULL;
> +                             break;
> +                     }
> +                             
>  
>                       /* lock the device pointers */
>                       down(&(us->dev_semaphore));
> diff -ur linux-2.4.1/drivers/usb/storage/usb.h 
>linux-2.4.1-taz/drivers/usb/storage/usb.h
> --- linux-2.4.1/drivers/usb/storage/usb.h     Sun Feb  4 22:42:42 2001
> +++ linux-2.4.1-taz/drivers/usb/storage/usb.h Sun Mar  4 11:55:43 2001
> @@ -86,6 +86,7 @@
>  struct us_unusual_dev {
>       const char* vendorName;
>       const char* productName;
> +     const char inquiryResponse[8];  
>       __u8  useProtocol;
>       __u8  useTransport;
>       int (*initFunction)(struct us_data *);
> @@ -99,6 +100,7 @@
>  #define US_FL_START_STOP      0x00000004 /* ignore START_STOP commands           */
>  #define US_FL_IGNORE_SER      0x00000010 /* Ignore the serial number given  */
>  #define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets */
> +#define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs fixing */
>  
>  #define USB_STOR_STRING_LEN 32
>  

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

YOU SEE!!?? It's like being born with only one nipple!
                                        -- Erwin
User Friendly, 10/19/1998

PGP signature

Reply via email to