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;
98 //+Wilson05112005, Indicate clearly of IDE HDD existence
100 us->host->ide_hdd = 0; //No IDE HDD
102 us->host->ide_hdd = 1; //IDE HDD exist
107 /* odd... didn't register properly. Abort and free pointers */
108 kfree(sht->proc_name);
109 sht->proc_name = NULL;
113 /* Release all resources used by the virtual host
115 * NOTE: There is no contention here, because we're already deregistered
116 * the driver and we're doing each virtual host in turn, not in parallel
118 static int release(struct Scsi_Host *psh)
120 struct us_data *us = (struct us_data *)psh->hostdata[0];
122 US_DEBUGP("release() called for host %s\n", us->htmplt.name);
124 /* Kill the control threads
126 * Enqueue the command, wake up the thread, and wait for
127 * notification that it's exited.
129 US_DEBUGP("-- sending US_ACT_EXIT command to thread\n");
130 us->action = US_ACT_EXIT;
133 wait_for_completion(&(us->notify));
135 /* remove the pointer to the data structure we were using */
136 psh->hostdata[0] = (unsigned long)NULL;
138 /* we always have a successful release */
143 static int command( Scsi_Cmnd *srb )
145 US_DEBUGP("Bad use of us_command\n");
147 return DID_BAD_TARGET << 16;
151 static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *))
153 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
156 US_DEBUGP("queuecommand() called\n");
157 srb->host_scribble = (unsigned char *)us;
159 /* get exclusive access to the structures we want */
160 spin_lock_irqsave(&(us->queue_exclusion), flags);
162 /* enqueue the command */
164 srb->scsi_done = done;
165 us->action = US_ACT_COMMAND;
167 /* release the lock on the structure */
168 spin_unlock_irqrestore(&(us->queue_exclusion), flags);
170 /* wake up the process task */
176 /***********************************************************************
177 * Error handling functions
178 ***********************************************************************/
181 static int command_abort( Scsi_Cmnd *srb )
183 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
185 US_DEBUGP("command_abort() called\n");
187 /* if we're stuck waiting for an IRQ, simulate it */
188 if (atomic_read(us->ip_wanted)) {
189 US_DEBUGP("-- simulating missing IRQ\n");
193 /* if the device has been removed, this worked */
195 US_DEBUGP("-- device removed already\n");
199 /* if we have an urb pending, let's wake the control thread up */
200 if (!us->current_done.done) {
201 atomic_inc(&us->abortcnt);
202 spin_unlock_irq(&io_request_lock);
203 /* cancel the URB -- this will automatically wake the thread */
204 usb_unlink_urb(us->current_urb);
206 /* wait for us to be done */
207 wait_for_completion(&(us->notify));
208 spin_lock_irq(&io_request_lock);
209 atomic_dec(&us->abortcnt);
213 US_DEBUGP ("-- nothing to abort\n");
217 /* This invokes the transport reset mechanism to reset the state of the
219 static int device_reset( Scsi_Cmnd *srb )
221 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
224 US_DEBUGP("device_reset() called\n" );
226 spin_unlock_irq(&io_request_lock);
227 down(&(us->dev_semaphore));
229 up(&(us->dev_semaphore));
230 spin_lock_irq(&io_request_lock);
233 rc = us->transport_reset(us);
234 up(&(us->dev_semaphore));
235 spin_lock_irq(&io_request_lock);
239 /* This resets the device port, and simulates the device
240 * disconnect/reconnect for all drivers which have claimed other
242 static int bus_reset( Scsi_Cmnd *srb )
244 struct us_data *us = (struct us_data *)srb->host->hostdata[0];
248 /* we use the usb_reset_device() function to handle this for us */
249 US_DEBUGP("bus_reset() called\n");
251 spin_unlock_irq(&io_request_lock);
253 down(&(us->dev_semaphore));
255 /* if the device has been removed, this worked */
257 US_DEBUGP("-- device removed already\n");
258 up(&(us->dev_semaphore));
259 spin_lock_irq(&io_request_lock);
263 /* The USB subsystem doesn't handle synchronisation between
264 * a device's several drivers. Therefore we reset only devices
265 * with just one interface, which we of course own. */
266 if (us->pusb_dev->actconfig->bNumInterfaces != 1) {
267 printk(KERN_NOTICE "usb-storage: "
268 "Refusing to reset a multi-interface device\n");
269 up(&(us->dev_semaphore));
270 spin_lock_irq(&io_request_lock);
271 /* XXX Don't just return success, make sure current cmd fails */
275 /* release the IRQ, if we have one */
277 US_DEBUGP("-- releasing irq URB\n");
278 result = usb_unlink_urb(us->irq_urb);
279 US_DEBUGP("-- usb_unlink_urb() returned %d\n", result);
282 /* attempt to reset the port */
283 if (usb_reset_device(us->pusb_dev) < 0) {
285 * Do not return errors, or else the error handler might
286 * invoke host_reset, which is not implemented.
291 /* FIXME: This needs to lock out driver probing while it's working
292 * or we can have race conditions */
293 for (i = 0; i < us->pusb_dev->actconfig->bNumInterfaces; i++) {
294 struct usb_interface *intf =
295 &us->pusb_dev->actconfig->interface[i];
296 const struct usb_device_id *id;
298 /* if this is an unclaimed interface, skip it */
303 US_DEBUGP("Examinging driver %s...", intf->driver->name);
304 /* skip interfaces which we've claimed */
305 if (intf->driver == &usb_storage_driver) {
306 US_DEBUGPX("skipping ourselves.\n");
310 /* simulate a disconnect and reconnect for all interfaces */
311 US_DEBUGPX("simulating disconnect/reconnect.\n");
312 down(&intf->driver->serialize);
313 intf->driver->disconnect(us->pusb_dev, intf->private_data);
314 id = usb_match_id(us->pusb_dev, intf, intf->driver->id_table);
315 intf->driver->probe(us->pusb_dev, i, id);
316 up(&intf->driver->serialize);
320 /* re-allocate the IRQ URB and submit it to restore connectivity
323 if (us->protocol == US_PR_CBI) {
324 us->irq_urb->dev = us->pusb_dev;
325 result = usb_submit_urb(us->irq_urb);
326 US_DEBUGP("usb_submit_urb() returns %d\n", result);
329 up(&(us->dev_semaphore));
331 spin_lock_irq(&io_request_lock);
333 US_DEBUGP("bus_reset() complete\n");
337 /* FIXME: This doesn't do anything right now */
338 static int host_reset( Scsi_Cmnd *srb )
340 printk(KERN_CRIT "usb-storage: host_reset() requested but not implemented\n" );
344 /***********************************************************************
345 * /proc/scsi/ functions
346 ***********************************************************************/
348 /* we use this macro to help us write into the buffer */
350 #define SPRINTF(args...) \
351 do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
353 static int proc_info (char *buffer, char **start, off_t offset, int length,
354 int hostno, int inout)
359 /* if someone is sending us data, just throw it away */
363 /* lock the data structures */
364 down(&us_list_semaphore);
366 /* find our data from hostno */
369 if (us->host_no == hostno)
374 /* release our lock on the data structures */
375 up(&us_list_semaphore);
377 /* if we couldn't find it, we return an error */
382 /* print the controller name */
383 SPRINTF(" Host scsi%d: usb-storage\n", hostno);
385 /* print product, vendor, and serial number strings */
386 SPRINTF(" Vendor: %s\n", us->vendor);
387 SPRINTF(" Product: %s\n", us->product);
388 SPRINTF("Serial Number: %s\n", us->serial);
390 /* show the protocol and transport */
391 SPRINTF(" Protocol: %s\n", us->protocol_name);
392 SPRINTF(" Transport: %s\n", us->transport_name);
394 /* show the GUID of the device */
395 SPRINTF(" GUID: " GUID_FORMAT "\n", GUID_ARGS(us->guid));
396 SPRINTF(" Attached: %s\n", us->pusb_dev ? "Yes" : "No");
399 * Calculate start of next buffer, and return value.
401 *start = buffer + offset;
403 if ((pos - buffer) < offset)
405 else if ((pos - buffer - offset) < length)
406 return (pos - buffer - offset);
412 * this defines our 'host'
415 Scsi_Host_Template usb_stor_host_template = {
417 proc_info: proc_info,
423 queuecommand: queuecommand,
425 eh_abort_handler: command_abort,
426 eh_device_reset_handler:device_reset,
427 eh_bus_reset_handler: bus_reset,
428 eh_host_reset_handler: host_reset,
433 sg_tablesize: SG_ALL,
436 unchecked_isa_dma: FALSE,
437 use_clustering: TRUE,
438 use_new_eh_code: TRUE,
442 unsigned char usb_stor_sense_notready[18] = {
443 [0] = 0x70, /* current error */
444 [2] = 0x02, /* not ready */
445 [5] = 0x0a, /* additional length */
446 [10] = 0x04, /* not ready */
447 [11] = 0x03 /* manual intervention */
450 #define USB_STOR_SCSI_SENSE_HDRSZ 4
451 #define USB_STOR_SCSI_SENSE_10_HDRSZ 8
453 struct usb_stor_scsi_sense_hdr
461 typedef struct usb_stor_scsi_sense_hdr Usb_Stor_Scsi_Sense_Hdr;
463 union usb_stor_scsi_sense_hdr_u
465 Usb_Stor_Scsi_Sense_Hdr hdr;
466 __u8* array[USB_STOR_SCSI_SENSE_HDRSZ];
469 typedef union usb_stor_scsi_sense_hdr_u Usb_Stor_Scsi_Sense_Hdr_u;
471 struct usb_stor_scsi_sense_hdr_10
479 __u8* blkDescLengthMSB;
480 __u8* blkDescLengthLSB;
483 typedef struct usb_stor_scsi_sense_hdr_10 Usb_Stor_Scsi_Sense_Hdr_10;
485 union usb_stor_scsi_sense_hdr_10_u
487 Usb_Stor_Scsi_Sense_Hdr_10 hdr;
488 __u8* array[USB_STOR_SCSI_SENSE_10_HDRSZ];
491 typedef union usb_stor_scsi_sense_hdr_10_u Usb_Stor_Scsi_Sense_Hdr_10_u;
493 void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* , Usb_Stor_Scsi_Sense_Hdr_u*,
494 Usb_Stor_Scsi_Sense_Hdr_10_u*, int* );
496 int usb_stor_scsiSense10to6( Scsi_Cmnd* the10 )
499 int outputBufferSize = 0;
501 struct scatterlist *sg = 0;
502 int i=0, j=0, element=0;
503 Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
504 Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
505 int sb=0,si=0,db=0,di=0;
508 US_DEBUGP("-- converting 10 byte sense data to 6 byte\n");
509 the10->cmnd[0] = the10->cmnd[0] & 0xBF;
511 /* Determine buffer locations */
512 usb_stor_scsiSenseParseBuffer( the10, &the6Locations, &the10Locations,
515 /* Work out minimum buffer to output */
516 outputBufferSize = *the10Locations.hdr.dataLengthLSB;
517 outputBufferSize += USB_STOR_SCSI_SENSE_HDRSZ;
519 /* Check to see if we need to trucate the output */
520 if ( outputBufferSize > length )
522 printk( KERN_WARNING USB_STORAGE
523 "Had to truncate MODE_SENSE_10 buffer into MODE_SENSE.\n" );
524 printk( KERN_WARNING USB_STORAGE
525 "outputBufferSize is %d and length is %d.\n",
526 outputBufferSize, length );
528 outputBufferSize = length;
531 if ( *the10Locations.hdr.dataLengthMSB != 0 ) /* MSB must be zero */
533 printk( KERN_WARNING USB_STORAGE
534 "Command will be truncated to fit in SENSE6 buffer.\n" );
535 *the6Locations.hdr.dataLength = 0xff;
539 *the6Locations.hdr.dataLength = *the10Locations.hdr.dataLengthLSB;
542 /* Medium type and DevSpecific parms */
543 *the6Locations.hdr.mediumType = *the10Locations.hdr.mediumType;
544 *the6Locations.hdr.devSpecParms = *the10Locations.hdr.devSpecParms;
546 /* Block descriptor length */
547 if ( *the10Locations.hdr.blkDescLengthMSB != 0 ) /* MSB must be zero */
549 printk( KERN_WARNING USB_STORAGE
550 "Command will be truncated to fit in SENSE6 buffer.\n" );
551 *the6Locations.hdr.blkDescLength = 0xff;
555 *the6Locations.hdr.blkDescLength = *the10Locations.hdr.blkDescLengthLSB;
558 if ( the10->use_sg == 0 )
560 buffer = the10->request_buffer;
561 /* Copy the rest of the data */
562 memmove( &(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
563 &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
564 outputBufferSize - USB_STOR_SCSI_SENSE_HDRSZ );
565 /* initialise last bytes left in buffer due to smaller header */
566 memset( &(buffer[outputBufferSize
567 -(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ)]),
569 USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
573 sg = (struct scatterlist *) the10->request_buffer;
574 /* scan through this scatterlist and figure out starting positions */
575 for ( i=0; i < the10->use_sg; i++)
577 sgLength = sg[i].length;
578 for ( j=0; j<sgLength; j++ )
580 /* get to end of header */
581 if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
586 if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
590 /* we've found both sets now, exit loops */
598 /* Now we know where to start the copy from */
599 element = USB_STOR_SCSI_SENSE_HDRSZ;
600 while ( element < outputBufferSize
601 -(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
604 if ( sb >= the10->use_sg ||
605 si >= sg[sb].length ||
606 db >= the10->use_sg ||
607 di >= sg[db].length )
609 printk( KERN_ERR USB_STORAGE
610 "Buffer overrun averted, this shouldn't happen!\n" );
615 sg[db].address[di] = sg[sb].address[si];
617 /* get next destination */
618 if ( sg[db].length-1 == di )
628 /* get next source */
629 if ( sg[sb].length-1 == si )
641 /* zero the remaining bytes */
642 while ( element < outputBufferSize )
645 if ( db >= the10->use_sg ||
646 di >= sg[db].length )
648 printk( KERN_ERR USB_STORAGE
649 "Buffer overrun averted, this shouldn't happen!\n" );
653 sg[db].address[di] = 0;
655 /* get next destination */
656 if ( sg[db].length-1 == di )
669 /* All done any everything was fine */
673 int usb_stor_scsiSense6to10( Scsi_Cmnd* the6 )
675 /* will be used to store part of buffer */
676 __u8 tempBuffer[USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ],
678 int outputBufferSize = 0;
680 struct scatterlist *sg = 0;
681 int i=0, j=0, element=0;
682 Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
683 Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
684 int sb=0,si=0,db=0,di=0;
685 int lsb=0,lsi=0,ldb=0,ldi=0;
687 US_DEBUGP("-- converting 6 byte sense data to 10 byte\n");
688 the6->cmnd[0] = the6->cmnd[0] | 0x40;
690 /* Determine buffer locations */
691 usb_stor_scsiSenseParseBuffer( the6, &the6Locations, &the10Locations,
694 /* Work out minimum buffer to output */
695 outputBufferSize = *the6Locations.hdr.dataLength;
696 outputBufferSize += USB_STOR_SCSI_SENSE_10_HDRSZ;
698 /* Check to see if we need to trucate the output */
699 if ( outputBufferSize > length )
701 printk( KERN_WARNING USB_STORAGE
702 "Had to truncate MODE_SENSE into MODE_SENSE_10 buffer.\n" );
703 printk( KERN_WARNING USB_STORAGE
704 "outputBufferSize is %d and length is %d.\n",
705 outputBufferSize, length );
707 outputBufferSize = length;
709 /* Block descriptor length - save these before overwriting */
710 tempBuffer[2] = *the10Locations.hdr.blkDescLengthMSB;
711 tempBuffer[3] = *the10Locations.hdr.blkDescLengthLSB;
712 *the10Locations.hdr.blkDescLengthLSB = *the6Locations.hdr.blkDescLength;
713 *the10Locations.hdr.blkDescLengthMSB = 0;
715 /* reserved - save these before overwriting */
716 tempBuffer[0] = *the10Locations.hdr.reserved1;
717 tempBuffer[1] = *the10Locations.hdr.reserved2;
718 *the10Locations.hdr.reserved1 = *the10Locations.hdr.reserved2 = 0;
720 /* Medium type and DevSpecific parms */
721 *the10Locations.hdr.devSpecParms = *the6Locations.hdr.devSpecParms;
722 *the10Locations.hdr.mediumType = *the6Locations.hdr.mediumType;
725 *the10Locations.hdr.dataLengthLSB = *the6Locations.hdr.dataLength;
726 *the10Locations.hdr.dataLengthMSB = 0;
730 buffer = the6->request_buffer;
731 /* Copy the rest of the data */
732 memmove( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
733 &(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
734 outputBufferSize-USB_STOR_SCSI_SENSE_10_HDRSZ );
735 /* Put the first four bytes (after header) in place */
736 memcpy( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
738 USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
742 sg = (struct scatterlist *) the6->request_buffer;
743 /* scan through this scatterlist and figure out ending positions */
744 for ( i=0; i < the6->use_sg; i++)
746 for ( j=0; j<sg[i].length; j++ )
748 /* get to end of header */
749 if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
754 if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
758 /* we've found both sets now, exit loops */
766 /* scan through this scatterlist and figure out starting positions */
768 /* destination is the last element */
771 for ( i=the6->use_sg-1; i >= 0; i--)
773 for ( j=sg[i].length-1; j>=0; j-- )
775 /* get to end of header and find source for copy */
776 if ( element == length - 1
777 - (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
781 /* we've found both sets now, exit loops */
788 /* Now we know where to start the copy from */
790 - (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ);
791 while ( element >= USB_STOR_SCSI_SENSE_10_HDRSZ )
794 if ( ( sb <= lsb && si < lsi ) ||
795 ( db <= ldb && di < ldi ) )
797 printk( KERN_ERR USB_STORAGE
798 "Buffer overrun averted, this shouldn't happen!\n" );
803 sg[db].address[di] = sg[sb].address[si];
805 /* get next destination */
816 /* get next source */
829 /* copy the remaining four bytes */
830 while ( element >= USB_STOR_SCSI_SENSE_HDRSZ )
833 if ( db <= ldb && di < ldi )
835 printk( KERN_ERR USB_STORAGE
836 "Buffer overrun averted, this shouldn't happen!\n" );
840 sg[db].address[di] = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
842 /* get next destination */
856 /* All done and everything was fine */
860 void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* srb, Usb_Stor_Scsi_Sense_Hdr_u* the6,
861 Usb_Stor_Scsi_Sense_Hdr_10_u* the10,
865 int i = 0, j=0, element=0;
866 struct scatterlist *sg = 0;
870 /* are we scatter-gathering? */
871 if ( srb->use_sg != 0 )
873 /* loop over all the scatter gather structures and
874 * get pointer to the data members in the headers
875 * (also work out the length while we're here)
877 sg = (struct scatterlist *) srb->request_buffer;
878 for (i = 0; i < srb->use_sg; i++)
880 length += sg[i].length;
881 /* We only do the inner loop for the headers */
882 if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
884 /* scan through this scatterlist */
885 for ( j=0; j<sg[i].length; j++ )
887 if ( element < USB_STOR_SCSI_SENSE_HDRSZ )
889 /* fill in the pointers for both header types */
890 the6->array[element] = &(sg[i].address[j]);
891 the10->array[element] = &(sg[i].address[j]);
893 else if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
895 /* only the longer headers still cares now */
896 the10->array[element] = &(sg[i].address[j]);
898 /* increase element counter */
906 length = srb->request_bufflen;
907 buffer = srb->request_buffer;
908 if ( length < USB_STOR_SCSI_SENSE_10_HDRSZ )
909 printk( KERN_ERR USB_STORAGE
910 "Buffer length smaller than header!!" );
911 for( i=0; i<USB_STOR_SCSI_SENSE_10_HDRSZ; i++ )
913 if ( i < USB_STOR_SCSI_SENSE_HDRSZ )
915 the6->array[i] = &(buffer[i]);
916 the10->array[i] = &(buffer[i]);
920 the10->array[i] = &(buffer[i]);
925 /* Set value of length passed in */