1 /* Driver for USB Mass Storage compliant devices
4 * $Id: scsiglue.c,v 1.24 2001/11/11 03:33:58 mdharm Exp $
6 * Current development and maintenance by:
7 * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
9 * Developed with the assistance of:
10 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
11 * (c) 2000 Stephen J. Gowdy (SGowdy@lbl.gov)
14 * (c) 1999 Michael Gee (michael@linuxspecific.com)
16 * This driver is based on the 'USB Mass Storage Class' document. This
17 * describes in detail the protocol used to communicate with such
18 * devices. Clearly, the designers had SCSI and ATAPI commands in
19 * mind when they created this document. The commands are all very
20 * similar to commands in the SCSI-II and ATAPI specifications.
22 * It is important to note that in a number of cases this class
23 * exhibits class-specific exemptions from the USB specification.
24 * Notably the usage of NAK, STALL and ACK differs from the norm, in
25 * that they are used to communicate wait, failed and OK on commands.
27 * Also, for certain devices, the interrupt endpoint is used to convey
28 * status of a command.
30 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
31 * information about this driver.
33 * This program is free software; you can redistribute it and/or modify it
34 * under the terms of the GNU General Public License as published by the
35 * Free Software Foundation; either version 2, or (at your option) any
38 * This program is distributed in the hope that it will be useful, but
39 * WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41 * General Public License for more details.
43 * You should have received a copy of the GNU General Public License along
44 * with this program; if not, write to the Free Software Foundation, Inc.,
45 * 675 Mass Ave, Cambridge, MA 02139, USA.
50 #include "transport.h"
52 #include <linux/slab.h>
55 * kernel thread actions
58 #define US_ACT_COMMAND 1
59 #define US_ACT_DEVICE_RESET 2
60 #define US_ACT_BUS_RESET 3
61 #define US_ACT_HOST_RESET 4
64 /***********************************************************************
66 ***********************************************************************/
68 static const char* host_info(struct Scsi_Host *host)
70 return "SCSI emulation for USB Mass Storage devices";
73 /* detect a virtual adapter (always works) */
74 static int detect(struct SHT *sht)
78 /* Note: this function gets called with io_request_lock spinlock helt! */
79 /* This is not nice at all, but how else are we to get the
81 us = (struct us_data *)sht->proc_dir;
83 /* set up the name of our subdirectory under /proc/scsi/ */
84 sprintf(local_name, "usb-storage-%d", us->host_number);
85 sht->proc_name = kmalloc (strlen(local_name) + 1, GFP_ATOMIC);
88 strcpy(sht->proc_name, local_name);
90 /* we start with no /proc directory entry */
93 /* register the host */
94 us->host = scsi_register(sht, sizeof(us));
96 us->host->hostdata[0] = (unsigned long)us;
97 us->host_no = us->host->host_no;
101 /* odd... didn't register properly. Abort and free pointers */
102 kfree(sht->proc_name);
103 sht->proc_name = NULL;
107 /* Release all resources used by the virtual host
109 * NOTE: There is no contention here, because we're already deregistered
110 * the driver and we're doing each virtual host in turn, not in parallel
112 static int release(struct Scsi_Host *psh)
114 struct us_data *us = (struct us_data *)psh->hostdata[0];
116 US_DEBUGP("release() called for host %s\n", us->htmplt.name);
118 /* Kill the control threads
120 * Enqueue the command, wake up the thread, and wait for
121 * notification that it's exited.
123 US_DEBUGP("-- sending US_ACT_EXIT command to thread\n");
124 us->action = US_ACT_EXIT;
127 wait_for_completion(&(us->notify));
129 /* remove the pointer to the data structure we were using */
130 psh->hostdata[0] = (unsigned long)NULL;
132 /* we always have a successful release */
137 static int command( Scsi_Cmnd *srb )
139 US_DEBUGP("Bad use of us_command\n");
141 return DID_BAD_TARGET << 16;
145 static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *))
147 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
150 US_DEBUGP("queuecommand() called\n");
151 srb->host_scribble = (unsigned char *)us;
153 /* get exclusive access to the structures we want */
154 spin_lock_irqsave(&(us->queue_exclusion), flags);
156 /* enqueue the command */
158 srb->scsi_done = done;
159 us->action = US_ACT_COMMAND;
161 /* release the lock on the structure */
162 spin_unlock_irqrestore(&(us->queue_exclusion), flags);
164 /* wake up the process task */
170 /***********************************************************************
171 * Error handling functions
172 ***********************************************************************/
175 static int command_abort( Scsi_Cmnd *srb )
177 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
179 US_DEBUGP("command_abort() called\n");
181 /* if we're stuck waiting for an IRQ, simulate it */
182 if (atomic_read(us->ip_wanted)) {
183 US_DEBUGP("-- simulating missing IRQ\n");
187 /* if the device has been removed, this worked */
189 US_DEBUGP("-- device removed already\n");
193 /* if we have an urb pending, let's wake the control thread up */
194 if (!us->current_done.done) {
195 atomic_inc(&us->abortcnt);
196 spin_unlock_irq(&io_request_lock);
197 /* cancel the URB -- this will automatically wake the thread */
198 usb_unlink_urb(us->current_urb);
200 /* wait for us to be done */
201 wait_for_completion(&(us->notify));
202 spin_lock_irq(&io_request_lock);
203 atomic_dec(&us->abortcnt);
207 US_DEBUGP ("-- nothing to abort\n");
211 /* This invokes the transport reset mechanism to reset the state of the
213 static int device_reset( Scsi_Cmnd *srb )
215 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
218 US_DEBUGP("device_reset() called\n" );
220 spin_unlock_irq(&io_request_lock);
221 down(&(us->dev_semaphore));
223 up(&(us->dev_semaphore));
224 spin_lock_irq(&io_request_lock);
227 rc = us->transport_reset(us);
228 up(&(us->dev_semaphore));
229 spin_lock_irq(&io_request_lock);
233 /* This resets the device port, and simulates the device
234 * disconnect/reconnect for all drivers which have claimed other
236 static int bus_reset( Scsi_Cmnd *srb )
238 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
242 /* we use the usb_reset_device() function to handle this for us */
243 US_DEBUGP("bus_reset() called\n");
245 spin_unlock_irq(&io_request_lock);
247 down(&(us->dev_semaphore));
249 /* if the device has been removed, this worked */
251 US_DEBUGP("-- device removed already\n");
252 up(&(us->dev_semaphore));
253 spin_lock_irq(&io_request_lock);
257 /* The USB subsystem doesn't handle synchronisation between
258 * a device's several drivers. Therefore we reset only devices
259 * with just one interface, which we of course own. */
260 if (us->pusb_dev->actconfig->bNumInterfaces != 1) {
261 printk(KERN_NOTICE "usb-storage: "
262 "Refusing to reset a multi-interface device\n");
263 up(&(us->dev_semaphore));
264 spin_lock_irq(&io_request_lock);
265 /* XXX Don't just return success, make sure current cmd fails */
269 /* release the IRQ, if we have one */
271 US_DEBUGP("-- releasing irq URB\n");
272 result = usb_unlink_urb(us->irq_urb);
273 US_DEBUGP("-- usb_unlink_urb() returned %d\n", result);
276 /* attempt to reset the port */
277 if (usb_reset_device(us->pusb_dev) < 0) {
279 * Do not return errors, or else the error handler might
280 * invoke host_reset, which is not implemented.
285 /* FIXME: This needs to lock out driver probing while it's working
286 * or we can have race conditions */
287 for (i = 0; i < us->pusb_dev->actconfig->bNumInterfaces; i++) {
288 struct usb_interface *intf =
289 &us->pusb_dev->actconfig->interface[i];
290 const struct usb_device_id *id;
292 /* if this is an unclaimed interface, skip it */
297 US_DEBUGP("Examinging driver %s...", intf->driver->name);
298 /* skip interfaces which we've claimed */
299 if (intf->driver == &usb_storage_driver) {
300 US_DEBUGPX("skipping ourselves.\n");
304 /* simulate a disconnect and reconnect for all interfaces */
305 US_DEBUGPX("simulating disconnect/reconnect.\n");
306 down(&intf->driver->serialize);
307 intf->driver->disconnect(us->pusb_dev, intf->private_data);
308 id = usb_match_id(us->pusb_dev, intf, intf->driver->id_table);
309 intf->driver->probe(us->pusb_dev, i, id);
310 up(&intf->driver->serialize);
314 /* re-allocate the IRQ URB and submit it to restore connectivity
317 if (us->protocol == US_PR_CBI) {
318 us->irq_urb->dev = us->pusb_dev;
319 result = usb_submit_urb(us->irq_urb);
320 US_DEBUGP("usb_submit_urb() returns %d\n", result);
323 up(&(us->dev_semaphore));
325 spin_lock_irq(&io_request_lock);
327 US_DEBUGP("bus_reset() complete\n");
331 /* FIXME: This doesn't do anything right now */
332 static int host_reset( Scsi_Cmnd *srb )
334 printk(KERN_CRIT "usb-storage: host_reset() requested but not implemented\n" );
338 /***********************************************************************
339 * /proc/scsi/ functions
340 ***********************************************************************/
342 /* we use this macro to help us write into the buffer */
344 #define SPRINTF(args...) \
345 do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
347 static int proc_info (char *buffer, char **start, off_t offset, int length,
348 int hostno, int inout)
353 /* if someone is sending us data, just throw it away */
357 /* lock the data structures */
358 down(&us_list_semaphore);
360 /* find our data from hostno */
363 if (us->host_no == hostno)
368 /* release our lock on the data structures */
369 up(&us_list_semaphore);
371 /* if we couldn't find it, we return an error */
376 /* print the controller name */
377 SPRINTF(" Host scsi%d: usb-storage\n", hostno);
379 /* print product, vendor, and serial number strings */
380 SPRINTF(" Vendor: %s\n", us->vendor);
381 SPRINTF(" Product: %s\n", us->product);
382 SPRINTF("Serial Number: %s\n", us->serial);
384 /* show the protocol and transport */
385 SPRINTF(" Protocol: %s\n", us->protocol_name);
386 SPRINTF(" Transport: %s\n", us->transport_name);
388 /* show the GUID of the device */
389 SPRINTF(" GUID: " GUID_FORMAT "\n", GUID_ARGS(us->guid));
390 SPRINTF(" Attached: %s\n", us->pusb_dev ? "Yes" : "No");
393 * Calculate start of next buffer, and return value.
395 *start = buffer + offset;
397 if ((pos - buffer) < offset)
399 else if ((pos - buffer - offset) < length)
400 return (pos - buffer - offset);
406 * this defines our 'host'
409 Scsi_Host_Template usb_stor_host_template = {
411 proc_info: proc_info,
417 queuecommand: queuecommand,
419 eh_abort_handler: command_abort,
420 eh_device_reset_handler:device_reset,
421 eh_bus_reset_handler: bus_reset,
422 eh_host_reset_handler: host_reset,
427 sg_tablesize: SG_ALL,
430 unchecked_isa_dma: FALSE,
431 use_clustering: TRUE,
432 use_new_eh_code: TRUE,
436 unsigned char usb_stor_sense_notready[18] = {
437 [0] = 0x70, /* current error */
438 [2] = 0x02, /* not ready */
439 [5] = 0x0a, /* additional length */
440 [10] = 0x04, /* not ready */
441 [11] = 0x03 /* manual intervention */
444 #define USB_STOR_SCSI_SENSE_HDRSZ 4
445 #define USB_STOR_SCSI_SENSE_10_HDRSZ 8
447 struct usb_stor_scsi_sense_hdr
455 typedef struct usb_stor_scsi_sense_hdr Usb_Stor_Scsi_Sense_Hdr;
457 union usb_stor_scsi_sense_hdr_u
459 Usb_Stor_Scsi_Sense_Hdr hdr;
460 __u8* array[USB_STOR_SCSI_SENSE_HDRSZ];
463 typedef union usb_stor_scsi_sense_hdr_u Usb_Stor_Scsi_Sense_Hdr_u;
465 struct usb_stor_scsi_sense_hdr_10
473 __u8* blkDescLengthMSB;
474 __u8* blkDescLengthLSB;
477 typedef struct usb_stor_scsi_sense_hdr_10 Usb_Stor_Scsi_Sense_Hdr_10;
479 union usb_stor_scsi_sense_hdr_10_u
481 Usb_Stor_Scsi_Sense_Hdr_10 hdr;
482 __u8* array[USB_STOR_SCSI_SENSE_10_HDRSZ];
485 typedef union usb_stor_scsi_sense_hdr_10_u Usb_Stor_Scsi_Sense_Hdr_10_u;
487 void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* , Usb_Stor_Scsi_Sense_Hdr_u*,
488 Usb_Stor_Scsi_Sense_Hdr_10_u*, int* );
490 int usb_stor_scsiSense10to6( Scsi_Cmnd* the10 )
493 int outputBufferSize = 0;
495 struct scatterlist *sg = 0;
496 int i=0, j=0, element=0;
497 Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
498 Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
499 int sb=0,si=0,db=0,di=0;
502 US_DEBUGP("-- converting 10 byte sense data to 6 byte\n");
503 the10->cmnd[0] = the10->cmnd[0] & 0xBF;
505 /* Determine buffer locations */
506 usb_stor_scsiSenseParseBuffer( the10, &the6Locations, &the10Locations,
509 /* Work out minimum buffer to output */
510 outputBufferSize = *the10Locations.hdr.dataLengthLSB;
511 outputBufferSize += USB_STOR_SCSI_SENSE_HDRSZ;
513 /* Check to see if we need to trucate the output */
514 if ( outputBufferSize > length )
516 printk( KERN_WARNING USB_STORAGE
517 "Had to truncate MODE_SENSE_10 buffer into MODE_SENSE.\n" );
518 printk( KERN_WARNING USB_STORAGE
519 "outputBufferSize is %d and length is %d.\n",
520 outputBufferSize, length );
522 outputBufferSize = length;
525 if ( *the10Locations.hdr.dataLengthMSB != 0 ) /* MSB must be zero */
527 printk( KERN_WARNING USB_STORAGE
528 "Command will be truncated to fit in SENSE6 buffer.\n" );
529 *the6Locations.hdr.dataLength = 0xff;
533 *the6Locations.hdr.dataLength = *the10Locations.hdr.dataLengthLSB;
536 /* Medium type and DevSpecific parms */
537 *the6Locations.hdr.mediumType = *the10Locations.hdr.mediumType;
538 *the6Locations.hdr.devSpecParms = *the10Locations.hdr.devSpecParms;
540 /* Block descriptor length */
541 if ( *the10Locations.hdr.blkDescLengthMSB != 0 ) /* MSB must be zero */
543 printk( KERN_WARNING USB_STORAGE
544 "Command will be truncated to fit in SENSE6 buffer.\n" );
545 *the6Locations.hdr.blkDescLength = 0xff;
549 *the6Locations.hdr.blkDescLength = *the10Locations.hdr.blkDescLengthLSB;
552 if ( the10->use_sg == 0 )
554 buffer = the10->request_buffer;
555 /* Copy the rest of the data */
556 memmove( &(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
557 &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
558 outputBufferSize - USB_STOR_SCSI_SENSE_HDRSZ );
559 /* initialise last bytes left in buffer due to smaller header */
560 memset( &(buffer[outputBufferSize
561 -(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ)]),
563 USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
567 sg = (struct scatterlist *) the10->request_buffer;
568 /* scan through this scatterlist and figure out starting positions */
569 for ( i=0; i < the10->use_sg; i++)
571 sgLength = sg[i].length;
572 for ( j=0; j<sgLength; j++ )
574 /* get to end of header */
575 if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
580 if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
584 /* we've found both sets now, exit loops */
592 /* Now we know where to start the copy from */
593 element = USB_STOR_SCSI_SENSE_HDRSZ;
594 while ( element < outputBufferSize
595 -(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
598 if ( sb >= the10->use_sg ||
599 si >= sg[sb].length ||
600 db >= the10->use_sg ||
601 di >= sg[db].length )
603 printk( KERN_ERR USB_STORAGE
604 "Buffer overrun averted, this shouldn't happen!\n" );
609 sg[db].address[di] = sg[sb].address[si];
611 /* get next destination */
612 if ( sg[db].length-1 == di )
622 /* get next source */
623 if ( sg[sb].length-1 == si )
635 /* zero the remaining bytes */
636 while ( element < outputBufferSize )
639 if ( db >= the10->use_sg ||
640 di >= sg[db].length )
642 printk( KERN_ERR USB_STORAGE
643 "Buffer overrun averted, this shouldn't happen!\n" );
647 sg[db].address[di] = 0;
649 /* get next destination */
650 if ( sg[db].length-1 == di )
663 /* All done any everything was fine */
667 int usb_stor_scsiSense6to10( Scsi_Cmnd* the6 )
669 /* will be used to store part of buffer */
670 __u8 tempBuffer[USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ],
672 int outputBufferSize = 0;
674 struct scatterlist *sg = 0;
675 int i=0, j=0, element=0;
676 Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
677 Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
678 int sb=0,si=0,db=0,di=0;
679 int lsb=0,lsi=0,ldb=0,ldi=0;
681 US_DEBUGP("-- converting 6 byte sense data to 10 byte\n");
682 the6->cmnd[0] = the6->cmnd[0] | 0x40;
684 /* Determine buffer locations */
685 usb_stor_scsiSenseParseBuffer( the6, &the6Locations, &the10Locations,
688 /* Work out minimum buffer to output */
689 outputBufferSize = *the6Locations.hdr.dataLength;
690 outputBufferSize += USB_STOR_SCSI_SENSE_10_HDRSZ;
692 /* Check to see if we need to trucate the output */
693 if ( outputBufferSize > length )
695 printk( KERN_WARNING USB_STORAGE
696 "Had to truncate MODE_SENSE into MODE_SENSE_10 buffer.\n" );
697 printk( KERN_WARNING USB_STORAGE
698 "outputBufferSize is %d and length is %d.\n",
699 outputBufferSize, length );
701 outputBufferSize = length;
703 /* Block descriptor length - save these before overwriting */
704 tempBuffer[2] = *the10Locations.hdr.blkDescLengthMSB;
705 tempBuffer[3] = *the10Locations.hdr.blkDescLengthLSB;
706 *the10Locations.hdr.blkDescLengthLSB = *the6Locations.hdr.blkDescLength;
707 *the10Locations.hdr.blkDescLengthMSB = 0;
709 /* reserved - save these before overwriting */
710 tempBuffer[0] = *the10Locations.hdr.reserved1;
711 tempBuffer[1] = *the10Locations.hdr.reserved2;
712 *the10Locations.hdr.reserved1 = *the10Locations.hdr.reserved2 = 0;
714 /* Medium type and DevSpecific parms */
715 *the10Locations.hdr.devSpecParms = *the6Locations.hdr.devSpecParms;
716 *the10Locations.hdr.mediumType = *the6Locations.hdr.mediumType;
719 *the10Locations.hdr.dataLengthLSB = *the6Locations.hdr.dataLength;
720 *the10Locations.hdr.dataLengthMSB = 0;
724 buffer = the6->request_buffer;
725 /* Copy the rest of the data */
726 memmove( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
727 &(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
728 outputBufferSize-USB_STOR_SCSI_SENSE_10_HDRSZ );
729 /* Put the first four bytes (after header) in place */
730 memcpy( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
732 USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
736 sg = (struct scatterlist *) the6->request_buffer;
737 /* scan through this scatterlist and figure out ending positions */
738 for ( i=0; i < the6->use_sg; i++)
740 for ( j=0; j<sg[i].length; j++ )
742 /* get to end of header */
743 if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
748 if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
752 /* we've found both sets now, exit loops */
760 /* scan through this scatterlist and figure out starting positions */
762 /* destination is the last element */
765 for ( i=the6->use_sg-1; i >= 0; i--)
767 for ( j=sg[i].length-1; j>=0; j-- )
769 /* get to end of header and find source for copy */
770 if ( element == length - 1
771 - (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
775 /* we've found both sets now, exit loops */
782 /* Now we know where to start the copy from */
784 - (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ);
785 while ( element >= USB_STOR_SCSI_SENSE_10_HDRSZ )
788 if ( ( sb <= lsb && si < lsi ) ||
789 ( db <= ldb && di < ldi ) )
791 printk( KERN_ERR USB_STORAGE
792 "Buffer overrun averted, this shouldn't happen!\n" );
797 sg[db].address[di] = sg[sb].address[si];
799 /* get next destination */
810 /* get next source */
823 /* copy the remaining four bytes */
824 while ( element >= USB_STOR_SCSI_SENSE_HDRSZ )
827 if ( db <= ldb && di < ldi )
829 printk( KERN_ERR USB_STORAGE
830 "Buffer overrun averted, this shouldn't happen!\n" );
834 sg[db].address[di] = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
836 /* get next destination */
850 /* All done and everything was fine */
854 void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* srb, Usb_Stor_Scsi_Sense_Hdr_u* the6,
855 Usb_Stor_Scsi_Sense_Hdr_10_u* the10,
859 int i = 0, j=0, element=0;
860 struct scatterlist *sg = 0;
864 /* are we scatter-gathering? */
865 if ( srb->use_sg != 0 )
867 /* loop over all the scatter gather structures and
868 * get pointer to the data members in the headers
869 * (also work out the length while we're here)
871 sg = (struct scatterlist *) srb->request_buffer;
872 for (i = 0; i < srb->use_sg; i++)
874 length += sg[i].length;
875 /* We only do the inner loop for the headers */
876 if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
878 /* scan through this scatterlist */
879 for ( j=0; j<sg[i].length; j++ )
881 if ( element < USB_STOR_SCSI_SENSE_HDRSZ )
883 /* fill in the pointers for both header types */
884 the6->array[element] = &(sg[i].address[j]);
885 the10->array[element] = &(sg[i].address[j]);
887 else if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
889 /* only the longer headers still cares now */
890 the10->array[element] = &(sg[i].address[j]);
892 /* increase element counter */
900 length = srb->request_bufflen;
901 buffer = srb->request_buffer;
902 if ( length < USB_STOR_SCSI_SENSE_10_HDRSZ )
903 printk( KERN_ERR USB_STORAGE
904 "Buffer length smaller than header!!" );
905 for( i=0; i<USB_STOR_SCSI_SENSE_10_HDRSZ; i++ )
907 if ( i < USB_STOR_SCSI_SENSE_HDRSZ )
909 the6->array[i] = &(buffer[i]);
910 the10->array[i] = &(buffer[i]);
914 the10->array[i] = &(buffer[i]);
919 /* Set value of length passed in */