Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Driver for Lexar "Jumpshot" Compact Flash reader
0004  *
0005  * jumpshot driver v0.1:
0006  *
0007  * First release
0008  *
0009  * Current development and maintenance by:
0010  *   (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
0011  *
0012  *   Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver
0013  *   which I used as a template for this driver.
0014  *
0015  *   Some bugfixes and scatter-gather code by Gregory P. Smith 
0016  *   (greg-usb@electricrain.com)
0017  *
0018  *   Fix for media change by Joerg Schneider (js@joergschneider.com)
0019  *
0020  * Developed with the assistance of:
0021  *
0022  *   (C) 2002 Alan Stern <stern@rowland.org>
0023  */
0024  
0025  /*
0026   * This driver attempts to support the Lexar Jumpshot USB CompactFlash 
0027   * reader.  Like many other USB CompactFlash readers, the Jumpshot contains
0028   * a USB-to-ATA chip. 
0029   *
0030   * This driver supports reading and writing.  If you're truly paranoid,
0031   * however, you can force the driver into a write-protected state by setting
0032   * the WP enable bits in jumpshot_handle_mode_sense.  See the comments
0033   * in that routine.
0034   */
0035 
0036 #include <linux/errno.h>
0037 #include <linux/module.h>
0038 #include <linux/slab.h>
0039 
0040 #include <scsi/scsi.h>
0041 #include <scsi/scsi_cmnd.h>
0042 
0043 #include "usb.h"
0044 #include "transport.h"
0045 #include "protocol.h"
0046 #include "debug.h"
0047 #include "scsiglue.h"
0048 
0049 #define DRV_NAME "ums-jumpshot"
0050 
0051 MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader");
0052 MODULE_AUTHOR("Jimmie Mayfield <mayfield+usb@sackheads.org>");
0053 MODULE_LICENSE("GPL");
0054 MODULE_IMPORT_NS(USB_STORAGE);
0055 
0056 /*
0057  * The table of devices
0058  */
0059 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
0060             vendorName, productName, useProtocol, useTransport, \
0061             initFunction, flags) \
0062 { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
0063   .driver_info = (flags) }
0064 
0065 static struct usb_device_id jumpshot_usb_ids[] = {
0066 #   include "unusual_jumpshot.h"
0067     { }     /* Terminating entry */
0068 };
0069 MODULE_DEVICE_TABLE(usb, jumpshot_usb_ids);
0070 
0071 #undef UNUSUAL_DEV
0072 
0073 /*
0074  * The flags table
0075  */
0076 #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
0077             vendor_name, product_name, use_protocol, use_transport, \
0078             init_function, Flags) \
0079 { \
0080     .vendorName = vendor_name,  \
0081     .productName = product_name,    \
0082     .useProtocol = use_protocol,    \
0083     .useTransport = use_transport,  \
0084     .initFunction = init_function,  \
0085 }
0086 
0087 static struct us_unusual_dev jumpshot_unusual_dev_list[] = {
0088 #   include "unusual_jumpshot.h"
0089     { }     /* Terminating entry */
0090 };
0091 
0092 #undef UNUSUAL_DEV
0093 
0094 
0095 struct jumpshot_info {
0096    unsigned long   sectors;     /* total sector count */
0097    unsigned long   ssize;       /* sector size in bytes */
0098 
0099    /* the following aren't used yet */
0100    unsigned char   sense_key;
0101    unsigned long   sense_asc;   /* additional sense code */
0102    unsigned long   sense_ascq;  /* additional sense code qualifier */
0103 };
0104 
0105 static inline int jumpshot_bulk_read(struct us_data *us,
0106                      unsigned char *data, 
0107                      unsigned int len)
0108 {
0109     if (len == 0)
0110         return USB_STOR_XFER_GOOD;
0111 
0112     usb_stor_dbg(us, "len = %d\n", len);
0113     return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
0114             data, len, NULL);
0115 }
0116 
0117 
0118 static inline int jumpshot_bulk_write(struct us_data *us,
0119                       unsigned char *data, 
0120                       unsigned int len)
0121 {
0122     if (len == 0)
0123         return USB_STOR_XFER_GOOD;
0124 
0125     usb_stor_dbg(us, "len = %d\n", len);
0126     return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
0127             data, len, NULL);
0128 }
0129 
0130 
0131 static int jumpshot_get_status(struct us_data  *us)
0132 {
0133     int rc;
0134 
0135     if (!us)
0136         return USB_STOR_TRANSPORT_ERROR;
0137 
0138     // send the setup
0139     rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
0140                    0, 0xA0, 0, 7, us->iobuf, 1);
0141 
0142     if (rc != USB_STOR_XFER_GOOD)
0143         return USB_STOR_TRANSPORT_ERROR;
0144 
0145     if (us->iobuf[0] != 0x50) {
0146         usb_stor_dbg(us, "0x%2x\n", us->iobuf[0]);
0147         return USB_STOR_TRANSPORT_ERROR;
0148     }
0149 
0150     return USB_STOR_TRANSPORT_GOOD;
0151 }
0152 
0153 static int jumpshot_read_data(struct us_data *us,
0154                   struct jumpshot_info *info,
0155                   u32 sector,
0156                   u32 sectors)
0157 {
0158     unsigned char *command = us->iobuf;
0159     unsigned char *buffer;
0160     unsigned char  thistime;
0161     unsigned int totallen, alloclen;
0162     int len, result;
0163     unsigned int sg_offset = 0;
0164     struct scatterlist *sg = NULL;
0165 
0166     // we're working in LBA mode.  according to the ATA spec, 
0167     // we can support up to 28-bit addressing.  I don't know if Jumpshot
0168     // supports beyond 24-bit addressing.  It's kind of hard to test 
0169     // since it requires > 8GB CF card.
0170 
0171     if (sector > 0x0FFFFFFF)
0172         return USB_STOR_TRANSPORT_ERROR;
0173 
0174     totallen = sectors * info->ssize;
0175 
0176     // Since we don't read more than 64 KB at a time, we have to create
0177     // a bounce buffer and move the data a piece at a time between the
0178     // bounce buffer and the actual transfer buffer.
0179 
0180     alloclen = min(totallen, 65536u);
0181     buffer = kmalloc(alloclen, GFP_NOIO);
0182     if (buffer == NULL)
0183         return USB_STOR_TRANSPORT_ERROR;
0184 
0185     do {
0186         // loop, never allocate or transfer more than 64k at once
0187         // (min(128k, 255*info->ssize) is the real limit)
0188         len = min(totallen, alloclen);
0189         thistime = (len / info->ssize) & 0xff;
0190 
0191         command[0] = 0;
0192         command[1] = thistime;
0193         command[2] = sector & 0xFF;
0194         command[3] = (sector >>  8) & 0xFF;
0195         command[4] = (sector >> 16) & 0xFF;
0196 
0197         command[5] = 0xE0 | ((sector >> 24) & 0x0F);
0198         command[6] = 0x20;
0199 
0200         // send the setup + command
0201         result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
0202                            0, 0x20, 0, 1, command, 7);
0203         if (result != USB_STOR_XFER_GOOD)
0204             goto leave;
0205 
0206         // read the result
0207         result = jumpshot_bulk_read(us, buffer, len);
0208         if (result != USB_STOR_XFER_GOOD)
0209             goto leave;
0210 
0211         usb_stor_dbg(us, "%d bytes\n", len);
0212 
0213         // Store the data in the transfer buffer
0214         usb_stor_access_xfer_buf(buffer, len, us->srb,
0215                  &sg, &sg_offset, TO_XFER_BUF);
0216 
0217         sector += thistime;
0218         totallen -= len;
0219     } while (totallen > 0);
0220 
0221     kfree(buffer);
0222     return USB_STOR_TRANSPORT_GOOD;
0223 
0224  leave:
0225     kfree(buffer);
0226     return USB_STOR_TRANSPORT_ERROR;
0227 }
0228 
0229 
0230 static int jumpshot_write_data(struct us_data *us,
0231                    struct jumpshot_info *info,
0232                    u32 sector,
0233                    u32 sectors)
0234 {
0235     unsigned char *command = us->iobuf;
0236     unsigned char *buffer;
0237     unsigned char  thistime;
0238     unsigned int totallen, alloclen;
0239     int len, result, waitcount;
0240     unsigned int sg_offset = 0;
0241     struct scatterlist *sg = NULL;
0242 
0243     // we're working in LBA mode.  according to the ATA spec, 
0244     // we can support up to 28-bit addressing.  I don't know if Jumpshot
0245     // supports beyond 24-bit addressing.  It's kind of hard to test 
0246     // since it requires > 8GB CF card.
0247     //
0248     if (sector > 0x0FFFFFFF)
0249         return USB_STOR_TRANSPORT_ERROR;
0250 
0251     totallen = sectors * info->ssize;
0252 
0253     // Since we don't write more than 64 KB at a time, we have to create
0254     // a bounce buffer and move the data a piece at a time between the
0255     // bounce buffer and the actual transfer buffer.
0256 
0257     alloclen = min(totallen, 65536u);
0258     buffer = kmalloc(alloclen, GFP_NOIO);
0259     if (buffer == NULL)
0260         return USB_STOR_TRANSPORT_ERROR;
0261 
0262     do {
0263         // loop, never allocate or transfer more than 64k at once
0264         // (min(128k, 255*info->ssize) is the real limit)
0265 
0266         len = min(totallen, alloclen);
0267         thistime = (len / info->ssize) & 0xff;
0268 
0269         // Get the data from the transfer buffer
0270         usb_stor_access_xfer_buf(buffer, len, us->srb,
0271                 &sg, &sg_offset, FROM_XFER_BUF);
0272 
0273         command[0] = 0;
0274         command[1] = thistime;
0275         command[2] = sector & 0xFF;
0276         command[3] = (sector >>  8) & 0xFF;
0277         command[4] = (sector >> 16) & 0xFF;
0278 
0279         command[5] = 0xE0 | ((sector >> 24) & 0x0F);
0280         command[6] = 0x30;
0281 
0282         // send the setup + command
0283         result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
0284             0, 0x20, 0, 1, command, 7);
0285         if (result != USB_STOR_XFER_GOOD)
0286             goto leave;
0287 
0288         // send the data
0289         result = jumpshot_bulk_write(us, buffer, len);
0290         if (result != USB_STOR_XFER_GOOD)
0291             goto leave;
0292 
0293         // read the result.  apparently the bulk write can complete
0294         // before the jumpshot drive is finished writing.  so we loop
0295         // here until we get a good return code
0296         waitcount = 0;
0297         do {
0298             result = jumpshot_get_status(us);
0299             if (result != USB_STOR_TRANSPORT_GOOD) {
0300                 // I have not experimented to find the smallest value.
0301                 //
0302                 msleep(50); 
0303             }
0304         } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
0305 
0306         if (result != USB_STOR_TRANSPORT_GOOD)
0307             usb_stor_dbg(us, "Gah!  Waitcount = 10.  Bad write!?\n");
0308 
0309         sector += thistime;
0310         totallen -= len;
0311     } while (totallen > 0);
0312 
0313     kfree(buffer);
0314     return result;
0315 
0316  leave:
0317     kfree(buffer);
0318     return USB_STOR_TRANSPORT_ERROR;
0319 }
0320 
0321 static int jumpshot_id_device(struct us_data *us,
0322                   struct jumpshot_info *info)
0323 {
0324     unsigned char *command = us->iobuf;
0325     unsigned char *reply;
0326     int      rc;
0327 
0328     if (!info)
0329         return USB_STOR_TRANSPORT_ERROR;
0330 
0331     command[0] = 0xE0;
0332     command[1] = 0xEC;
0333     reply = kmalloc(512, GFP_NOIO);
0334     if (!reply)
0335         return USB_STOR_TRANSPORT_ERROR;
0336 
0337     // send the setup
0338     rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
0339                    0, 0x20, 0, 6, command, 2);
0340 
0341     if (rc != USB_STOR_XFER_GOOD) {
0342         usb_stor_dbg(us, "Gah! send_control for read_capacity failed\n");
0343         rc = USB_STOR_TRANSPORT_ERROR;
0344         goto leave;
0345     }
0346 
0347     // read the reply
0348     rc = jumpshot_bulk_read(us, reply, 512);
0349     if (rc != USB_STOR_XFER_GOOD) {
0350         rc = USB_STOR_TRANSPORT_ERROR;
0351         goto leave;
0352     }
0353 
0354     info->sectors = ((u32)(reply[117]) << 24) |
0355             ((u32)(reply[116]) << 16) |
0356             ((u32)(reply[115]) <<  8) |
0357             ((u32)(reply[114])      );
0358 
0359     rc = USB_STOR_TRANSPORT_GOOD;
0360 
0361  leave:
0362     kfree(reply);
0363     return rc;
0364 }
0365 
0366 static int jumpshot_handle_mode_sense(struct us_data *us,
0367                       struct scsi_cmnd * srb, 
0368                       int sense_6)
0369 {
0370     static unsigned char rw_err_page[12] = {
0371         0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
0372     };
0373     static unsigned char cache_page[12] = {
0374         0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
0375     };
0376     static unsigned char rbac_page[12] = {
0377         0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
0378     };
0379     static unsigned char timer_page[8] = {
0380         0x1C, 0x6, 0, 0, 0, 0
0381     };
0382     unsigned char pc, page_code;
0383     unsigned int i = 0;
0384     struct jumpshot_info *info = (struct jumpshot_info *) (us->extra);
0385     unsigned char *ptr = us->iobuf;
0386 
0387     pc = srb->cmnd[2] >> 6;
0388     page_code = srb->cmnd[2] & 0x3F;
0389 
0390     switch (pc) {
0391        case 0x0:
0392            usb_stor_dbg(us, "Current values\n");
0393            break;
0394        case 0x1:
0395            usb_stor_dbg(us, "Changeable values\n");
0396            break;
0397        case 0x2:
0398            usb_stor_dbg(us, "Default values\n");
0399            break;
0400        case 0x3:
0401            usb_stor_dbg(us, "Saves values\n");
0402            break;
0403     }
0404 
0405     memset(ptr, 0, 8);
0406     if (sense_6) {
0407         ptr[2] = 0x00;      // WP enable: 0x80
0408         i = 4;
0409     } else {
0410         ptr[3] = 0x00;      // WP enable: 0x80
0411         i = 8;
0412     }
0413 
0414     switch (page_code) {
0415        case 0x0:
0416         // vendor-specific mode
0417         info->sense_key = 0x05;
0418         info->sense_asc = 0x24;
0419         info->sense_ascq = 0x00;
0420         return USB_STOR_TRANSPORT_FAILED;
0421 
0422        case 0x1:
0423         memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
0424         i += sizeof(rw_err_page);
0425         break;
0426 
0427        case 0x8:
0428         memcpy(ptr + i, cache_page, sizeof(cache_page));
0429         i += sizeof(cache_page);
0430         break;
0431 
0432        case 0x1B:
0433         memcpy(ptr + i, rbac_page, sizeof(rbac_page));
0434         i += sizeof(rbac_page);
0435         break;
0436 
0437        case 0x1C:
0438         memcpy(ptr + i, timer_page, sizeof(timer_page));
0439         i += sizeof(timer_page);
0440         break;
0441 
0442        case 0x3F:
0443         memcpy(ptr + i, timer_page, sizeof(timer_page));
0444         i += sizeof(timer_page);
0445         memcpy(ptr + i, rbac_page, sizeof(rbac_page));
0446         i += sizeof(rbac_page);
0447         memcpy(ptr + i, cache_page, sizeof(cache_page));
0448         i += sizeof(cache_page);
0449         memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
0450         i += sizeof(rw_err_page);
0451         break;
0452     }
0453 
0454     if (sense_6)
0455         ptr[0] = i - 1;
0456     else
0457         ((__be16 *) ptr)[0] = cpu_to_be16(i - 2);
0458     usb_stor_set_xfer_buf(ptr, i, srb);
0459 
0460     return USB_STOR_TRANSPORT_GOOD;
0461 }
0462 
0463 
0464 static void jumpshot_info_destructor(void *extra)
0465 {
0466     // this routine is a placeholder...
0467     // currently, we don't allocate any extra blocks so we're okay
0468 }
0469 
0470 
0471 
0472 // Transport for the Lexar 'Jumpshot'
0473 //
0474 static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
0475 {
0476     struct jumpshot_info *info;
0477     int rc;
0478     unsigned long block, blocks;
0479     unsigned char *ptr = us->iobuf;
0480     static unsigned char inquiry_response[8] = {
0481         0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
0482     };
0483 
0484     if (!us->extra) {
0485         us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
0486         if (!us->extra)
0487             return USB_STOR_TRANSPORT_ERROR;
0488 
0489         us->extra_destructor = jumpshot_info_destructor;
0490     }
0491 
0492     info = (struct jumpshot_info *) (us->extra);
0493 
0494     if (srb->cmnd[0] == INQUIRY) {
0495         usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
0496         memcpy(ptr, inquiry_response, sizeof(inquiry_response));
0497         fill_inquiry_response(us, ptr, 36);
0498         return USB_STOR_TRANSPORT_GOOD;
0499     }
0500 
0501     if (srb->cmnd[0] == READ_CAPACITY) {
0502         info->ssize = 0x200;  // hard coded 512 byte sectors as per ATA spec
0503 
0504         rc = jumpshot_get_status(us);
0505         if (rc != USB_STOR_TRANSPORT_GOOD)
0506             return rc;
0507 
0508         rc = jumpshot_id_device(us, info);
0509         if (rc != USB_STOR_TRANSPORT_GOOD)
0510             return rc;
0511 
0512         usb_stor_dbg(us, "READ_CAPACITY:  %ld sectors, %ld bytes per sector\n",
0513                  info->sectors, info->ssize);
0514 
0515         // build the reply
0516         //
0517         ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
0518         ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize);
0519         usb_stor_set_xfer_buf(ptr, 8, srb);
0520 
0521         return USB_STOR_TRANSPORT_GOOD;
0522     }
0523 
0524     if (srb->cmnd[0] == MODE_SELECT_10) {
0525         usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
0526         return USB_STOR_TRANSPORT_ERROR;
0527     }
0528 
0529     if (srb->cmnd[0] == READ_10) {
0530         block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
0531             ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
0532 
0533         blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
0534 
0535         usb_stor_dbg(us, "READ_10: read block 0x%04lx  count %ld\n",
0536                  block, blocks);
0537         return jumpshot_read_data(us, info, block, blocks);
0538     }
0539 
0540     if (srb->cmnd[0] == READ_12) {
0541         // I don't think we'll ever see a READ_12 but support it anyway...
0542         //
0543         block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
0544             ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
0545 
0546         blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
0547              ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
0548 
0549         usb_stor_dbg(us, "READ_12: read block 0x%04lx  count %ld\n",
0550                  block, blocks);
0551         return jumpshot_read_data(us, info, block, blocks);
0552     }
0553 
0554     if (srb->cmnd[0] == WRITE_10) {
0555         block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
0556             ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
0557 
0558         blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
0559 
0560         usb_stor_dbg(us, "WRITE_10: write block 0x%04lx  count %ld\n",
0561                  block, blocks);
0562         return jumpshot_write_data(us, info, block, blocks);
0563     }
0564 
0565     if (srb->cmnd[0] == WRITE_12) {
0566         // I don't think we'll ever see a WRITE_12 but support it anyway...
0567         //
0568         block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
0569             ((u32)(srb->cmnd[4]) <<  8) | ((u32)(srb->cmnd[5]));
0570 
0571         blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
0572              ((u32)(srb->cmnd[8]) <<  8) | ((u32)(srb->cmnd[9]));
0573 
0574         usb_stor_dbg(us, "WRITE_12: write block 0x%04lx  count %ld\n",
0575                  block, blocks);
0576         return jumpshot_write_data(us, info, block, blocks);
0577     }
0578 
0579 
0580     if (srb->cmnd[0] == TEST_UNIT_READY) {
0581         usb_stor_dbg(us, "TEST_UNIT_READY\n");
0582         return jumpshot_get_status(us);
0583     }
0584 
0585     if (srb->cmnd[0] == REQUEST_SENSE) {
0586         usb_stor_dbg(us, "REQUEST_SENSE\n");
0587 
0588         memset(ptr, 0, 18);
0589         ptr[0] = 0xF0;
0590         ptr[2] = info->sense_key;
0591         ptr[7] = 11;
0592         ptr[12] = info->sense_asc;
0593         ptr[13] = info->sense_ascq;
0594         usb_stor_set_xfer_buf(ptr, 18, srb);
0595 
0596         return USB_STOR_TRANSPORT_GOOD;
0597     }
0598 
0599     if (srb->cmnd[0] == MODE_SENSE) {
0600         usb_stor_dbg(us, "MODE_SENSE_6 detected\n");
0601         return jumpshot_handle_mode_sense(us, srb, 1);
0602     }
0603 
0604     if (srb->cmnd[0] == MODE_SENSE_10) {
0605         usb_stor_dbg(us, "MODE_SENSE_10 detected\n");
0606         return jumpshot_handle_mode_sense(us, srb, 0);
0607     }
0608 
0609     if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
0610         /*
0611          * sure.  whatever.  not like we can stop the user from popping
0612          * the media out of the device (no locking doors, etc)
0613          */
0614         return USB_STOR_TRANSPORT_GOOD;
0615     }
0616 
0617     if (srb->cmnd[0] == START_STOP) {
0618         /*
0619          * this is used by sd.c'check_scsidisk_media_change to detect
0620          * media change
0621          */
0622         usb_stor_dbg(us, "START_STOP\n");
0623         /*
0624          * the first jumpshot_id_device after a media change returns
0625          * an error (determined experimentally)
0626          */
0627         rc = jumpshot_id_device(us, info);
0628         if (rc == USB_STOR_TRANSPORT_GOOD) {
0629             info->sense_key = NO_SENSE;
0630             srb->result = SUCCESS;
0631         } else {
0632             info->sense_key = UNIT_ATTENTION;
0633             srb->result = SAM_STAT_CHECK_CONDITION;
0634         }
0635         return rc;
0636     }
0637 
0638     usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
0639              srb->cmnd[0], srb->cmnd[0]);
0640     info->sense_key = 0x05;
0641     info->sense_asc = 0x20;
0642     info->sense_ascq = 0x00;
0643     return USB_STOR_TRANSPORT_FAILED;
0644 }
0645 
0646 static struct scsi_host_template jumpshot_host_template;
0647 
0648 static int jumpshot_probe(struct usb_interface *intf,
0649              const struct usb_device_id *id)
0650 {
0651     struct us_data *us;
0652     int result;
0653 
0654     result = usb_stor_probe1(&us, intf, id,
0655             (id - jumpshot_usb_ids) + jumpshot_unusual_dev_list,
0656             &jumpshot_host_template);
0657     if (result)
0658         return result;
0659 
0660     us->transport_name  = "Lexar Jumpshot Control/Bulk";
0661     us->transport = jumpshot_transport;
0662     us->transport_reset = usb_stor_Bulk_reset;
0663     us->max_lun = 1;
0664 
0665     result = usb_stor_probe2(us);
0666     return result;
0667 }
0668 
0669 static struct usb_driver jumpshot_driver = {
0670     .name =     DRV_NAME,
0671     .probe =    jumpshot_probe,
0672     .disconnect =   usb_stor_disconnect,
0673     .suspend =  usb_stor_suspend,
0674     .resume =   usb_stor_resume,
0675     .reset_resume = usb_stor_reset_resume,
0676     .pre_reset =    usb_stor_pre_reset,
0677     .post_reset =   usb_stor_post_reset,
0678     .id_table = jumpshot_usb_ids,
0679     .soft_unbind =  1,
0680     .no_dynamic_id = 1,
0681 };
0682 
0683 module_usb_stor_driver(jumpshot_driver, jumpshot_host_template, DRV_NAME);