jumpshot.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Driver for Lexar "Jumpshot" Compact Flash reader
  4. *
  5. * jumpshot driver v0.1:
  6. *
  7. * First release
  8. *
  9. * Current development and maintenance by:
  10. * (c) 2000 Jimmie Mayfield (mayfield+usb@sackheads.org)
  11. *
  12. * Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver
  13. * which I used as a template for this driver.
  14. *
  15. * Some bugfixes and scatter-gather code by Gregory P. Smith
  16. * (greg-usb@electricrain.com)
  17. *
  18. * Fix for media change by Joerg Schneider (js@joergschneider.com)
  19. *
  20. * Developed with the assistance of:
  21. *
  22. * (C) 2002 Alan Stern <stern@rowland.org>
  23. */
  24. /*
  25. * This driver attempts to support the Lexar Jumpshot USB CompactFlash
  26. * reader. Like many other USB CompactFlash readers, the Jumpshot contains
  27. * a USB-to-ATA chip.
  28. *
  29. * This driver supports reading and writing. If you're truly paranoid,
  30. * however, you can force the driver into a write-protected state by setting
  31. * the WP enable bits in jumpshot_handle_mode_sense. See the comments
  32. * in that routine.
  33. */
  34. #include <linux/errno.h>
  35. #include <linux/module.h>
  36. #include <linux/slab.h>
  37. #include <scsi/scsi.h>
  38. #include <scsi/scsi_cmnd.h>
  39. #include "usb.h"
  40. #include "transport.h"
  41. #include "protocol.h"
  42. #include "debug.h"
  43. #include "scsiglue.h"
  44. #define DRV_NAME "ums-jumpshot"
  45. MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader");
  46. MODULE_AUTHOR("Jimmie Mayfield <mayfield+usb@sackheads.org>");
  47. MODULE_LICENSE("GPL");
  48. MODULE_IMPORT_NS(USB_STORAGE);
  49. /*
  50. * The table of devices
  51. */
  52. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  53. vendorName, productName, useProtocol, useTransport, \
  54. initFunction, flags) \
  55. { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  56. .driver_info = (flags) }
  57. static struct usb_device_id jumpshot_usb_ids[] = {
  58. # include "unusual_jumpshot.h"
  59. { } /* Terminating entry */
  60. };
  61. MODULE_DEVICE_TABLE(usb, jumpshot_usb_ids);
  62. #undef UNUSUAL_DEV
  63. /*
  64. * The flags table
  65. */
  66. #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
  67. vendor_name, product_name, use_protocol, use_transport, \
  68. init_function, Flags) \
  69. { \
  70. .vendorName = vendor_name, \
  71. .productName = product_name, \
  72. .useProtocol = use_protocol, \
  73. .useTransport = use_transport, \
  74. .initFunction = init_function, \
  75. }
  76. static struct us_unusual_dev jumpshot_unusual_dev_list[] = {
  77. # include "unusual_jumpshot.h"
  78. { } /* Terminating entry */
  79. };
  80. #undef UNUSUAL_DEV
  81. struct jumpshot_info {
  82. unsigned long sectors; /* total sector count */
  83. unsigned long ssize; /* sector size in bytes */
  84. /* the following aren't used yet */
  85. unsigned char sense_key;
  86. unsigned long sense_asc; /* additional sense code */
  87. unsigned long sense_ascq; /* additional sense code qualifier */
  88. };
  89. static inline int jumpshot_bulk_read(struct us_data *us,
  90. unsigned char *data,
  91. unsigned int len)
  92. {
  93. if (len == 0)
  94. return USB_STOR_XFER_GOOD;
  95. usb_stor_dbg(us, "len = %d\n", len);
  96. return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
  97. data, len, NULL);
  98. }
  99. static inline int jumpshot_bulk_write(struct us_data *us,
  100. unsigned char *data,
  101. unsigned int len)
  102. {
  103. if (len == 0)
  104. return USB_STOR_XFER_GOOD;
  105. usb_stor_dbg(us, "len = %d\n", len);
  106. return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
  107. data, len, NULL);
  108. }
  109. static int jumpshot_get_status(struct us_data *us)
  110. {
  111. int rc;
  112. if (!us)
  113. return USB_STOR_TRANSPORT_ERROR;
  114. // send the setup
  115. rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
  116. 0, 0xA0, 0, 7, us->iobuf, 1);
  117. if (rc != USB_STOR_XFER_GOOD)
  118. return USB_STOR_TRANSPORT_ERROR;
  119. if (us->iobuf[0] != 0x50) {
  120. usb_stor_dbg(us, "0x%2x\n", us->iobuf[0]);
  121. return USB_STOR_TRANSPORT_ERROR;
  122. }
  123. return USB_STOR_TRANSPORT_GOOD;
  124. }
  125. static int jumpshot_read_data(struct us_data *us,
  126. struct jumpshot_info *info,
  127. u32 sector,
  128. u32 sectors)
  129. {
  130. unsigned char *command = us->iobuf;
  131. unsigned char *buffer;
  132. unsigned char thistime;
  133. unsigned int totallen, alloclen;
  134. int len, result;
  135. unsigned int sg_offset = 0;
  136. struct scatterlist *sg = NULL;
  137. // we're working in LBA mode. according to the ATA spec,
  138. // we can support up to 28-bit addressing. I don't know if Jumpshot
  139. // supports beyond 24-bit addressing. It's kind of hard to test
  140. // since it requires > 8GB CF card.
  141. if (sector > 0x0FFFFFFF)
  142. return USB_STOR_TRANSPORT_ERROR;
  143. totallen = sectors * info->ssize;
  144. // Since we don't read more than 64 KB at a time, we have to create
  145. // a bounce buffer and move the data a piece at a time between the
  146. // bounce buffer and the actual transfer buffer.
  147. alloclen = min(totallen, 65536u);
  148. buffer = kmalloc(alloclen, GFP_NOIO);
  149. if (buffer == NULL)
  150. return USB_STOR_TRANSPORT_ERROR;
  151. do {
  152. // loop, never allocate or transfer more than 64k at once
  153. // (min(128k, 255*info->ssize) is the real limit)
  154. len = min(totallen, alloclen);
  155. thistime = (len / info->ssize) & 0xff;
  156. command[0] = 0;
  157. command[1] = thistime;
  158. command[2] = sector & 0xFF;
  159. command[3] = (sector >> 8) & 0xFF;
  160. command[4] = (sector >> 16) & 0xFF;
  161. command[5] = 0xE0 | ((sector >> 24) & 0x0F);
  162. command[6] = 0x20;
  163. // send the setup + command
  164. result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
  165. 0, 0x20, 0, 1, command, 7);
  166. if (result != USB_STOR_XFER_GOOD)
  167. goto leave;
  168. // read the result
  169. result = jumpshot_bulk_read(us, buffer, len);
  170. if (result != USB_STOR_XFER_GOOD)
  171. goto leave;
  172. usb_stor_dbg(us, "%d bytes\n", len);
  173. // Store the data in the transfer buffer
  174. usb_stor_access_xfer_buf(buffer, len, us->srb,
  175. &sg, &sg_offset, TO_XFER_BUF);
  176. sector += thistime;
  177. totallen -= len;
  178. } while (totallen > 0);
  179. kfree(buffer);
  180. return USB_STOR_TRANSPORT_GOOD;
  181. leave:
  182. kfree(buffer);
  183. return USB_STOR_TRANSPORT_ERROR;
  184. }
  185. static int jumpshot_write_data(struct us_data *us,
  186. struct jumpshot_info *info,
  187. u32 sector,
  188. u32 sectors)
  189. {
  190. unsigned char *command = us->iobuf;
  191. unsigned char *buffer;
  192. unsigned char thistime;
  193. unsigned int totallen, alloclen;
  194. int len, result, waitcount;
  195. unsigned int sg_offset = 0;
  196. struct scatterlist *sg = NULL;
  197. // we're working in LBA mode. according to the ATA spec,
  198. // we can support up to 28-bit addressing. I don't know if Jumpshot
  199. // supports beyond 24-bit addressing. It's kind of hard to test
  200. // since it requires > 8GB CF card.
  201. //
  202. if (sector > 0x0FFFFFFF)
  203. return USB_STOR_TRANSPORT_ERROR;
  204. totallen = sectors * info->ssize;
  205. // Since we don't write more than 64 KB at a time, we have to create
  206. // a bounce buffer and move the data a piece at a time between the
  207. // bounce buffer and the actual transfer buffer.
  208. alloclen = min(totallen, 65536u);
  209. buffer = kmalloc(alloclen, GFP_NOIO);
  210. if (buffer == NULL)
  211. return USB_STOR_TRANSPORT_ERROR;
  212. do {
  213. // loop, never allocate or transfer more than 64k at once
  214. // (min(128k, 255*info->ssize) is the real limit)
  215. len = min(totallen, alloclen);
  216. thistime = (len / info->ssize) & 0xff;
  217. // Get the data from the transfer buffer
  218. usb_stor_access_xfer_buf(buffer, len, us->srb,
  219. &sg, &sg_offset, FROM_XFER_BUF);
  220. command[0] = 0;
  221. command[1] = thistime;
  222. command[2] = sector & 0xFF;
  223. command[3] = (sector >> 8) & 0xFF;
  224. command[4] = (sector >> 16) & 0xFF;
  225. command[5] = 0xE0 | ((sector >> 24) & 0x0F);
  226. command[6] = 0x30;
  227. // send the setup + command
  228. result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
  229. 0, 0x20, 0, 1, command, 7);
  230. if (result != USB_STOR_XFER_GOOD)
  231. goto leave;
  232. // send the data
  233. result = jumpshot_bulk_write(us, buffer, len);
  234. if (result != USB_STOR_XFER_GOOD)
  235. goto leave;
  236. // read the result. apparently the bulk write can complete
  237. // before the jumpshot drive is finished writing. so we loop
  238. // here until we get a good return code
  239. waitcount = 0;
  240. do {
  241. result = jumpshot_get_status(us);
  242. if (result != USB_STOR_TRANSPORT_GOOD) {
  243. // I have not experimented to find the smallest value.
  244. //
  245. msleep(50);
  246. }
  247. } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
  248. if (result != USB_STOR_TRANSPORT_GOOD)
  249. usb_stor_dbg(us, "Gah! Waitcount = 10. Bad write!?\n");
  250. sector += thistime;
  251. totallen -= len;
  252. } while (totallen > 0);
  253. kfree(buffer);
  254. return result;
  255. leave:
  256. kfree(buffer);
  257. return USB_STOR_TRANSPORT_ERROR;
  258. }
  259. static int jumpshot_id_device(struct us_data *us,
  260. struct jumpshot_info *info)
  261. {
  262. unsigned char *command = us->iobuf;
  263. unsigned char *reply;
  264. int rc;
  265. if (!info)
  266. return USB_STOR_TRANSPORT_ERROR;
  267. command[0] = 0xE0;
  268. command[1] = 0xEC;
  269. reply = kmalloc(512, GFP_NOIO);
  270. if (!reply)
  271. return USB_STOR_TRANSPORT_ERROR;
  272. // send the setup
  273. rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
  274. 0, 0x20, 0, 6, command, 2);
  275. if (rc != USB_STOR_XFER_GOOD) {
  276. usb_stor_dbg(us, "Gah! send_control for read_capacity failed\n");
  277. rc = USB_STOR_TRANSPORT_ERROR;
  278. goto leave;
  279. }
  280. // read the reply
  281. rc = jumpshot_bulk_read(us, reply, 512);
  282. if (rc != USB_STOR_XFER_GOOD) {
  283. rc = USB_STOR_TRANSPORT_ERROR;
  284. goto leave;
  285. }
  286. info->sectors = ((u32)(reply[117]) << 24) |
  287. ((u32)(reply[116]) << 16) |
  288. ((u32)(reply[115]) << 8) |
  289. ((u32)(reply[114]) );
  290. rc = USB_STOR_TRANSPORT_GOOD;
  291. leave:
  292. kfree(reply);
  293. return rc;
  294. }
  295. static int jumpshot_handle_mode_sense(struct us_data *us,
  296. struct scsi_cmnd * srb,
  297. int sense_6)
  298. {
  299. static unsigned char rw_err_page[12] = {
  300. 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0
  301. };
  302. static unsigned char cache_page[12] = {
  303. 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0
  304. };
  305. static unsigned char rbac_page[12] = {
  306. 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0
  307. };
  308. static unsigned char timer_page[8] = {
  309. 0x1C, 0x6, 0, 0, 0, 0
  310. };
  311. unsigned char pc, page_code;
  312. unsigned int i = 0;
  313. struct jumpshot_info *info = (struct jumpshot_info *) (us->extra);
  314. unsigned char *ptr = us->iobuf;
  315. pc = srb->cmnd[2] >> 6;
  316. page_code = srb->cmnd[2] & 0x3F;
  317. switch (pc) {
  318. case 0x0:
  319. usb_stor_dbg(us, "Current values\n");
  320. break;
  321. case 0x1:
  322. usb_stor_dbg(us, "Changeable values\n");
  323. break;
  324. case 0x2:
  325. usb_stor_dbg(us, "Default values\n");
  326. break;
  327. case 0x3:
  328. usb_stor_dbg(us, "Saves values\n");
  329. break;
  330. }
  331. memset(ptr, 0, 8);
  332. if (sense_6) {
  333. ptr[2] = 0x00; // WP enable: 0x80
  334. i = 4;
  335. } else {
  336. ptr[3] = 0x00; // WP enable: 0x80
  337. i = 8;
  338. }
  339. switch (page_code) {
  340. case 0x0:
  341. // vendor-specific mode
  342. info->sense_key = 0x05;
  343. info->sense_asc = 0x24;
  344. info->sense_ascq = 0x00;
  345. return USB_STOR_TRANSPORT_FAILED;
  346. case 0x1:
  347. memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
  348. i += sizeof(rw_err_page);
  349. break;
  350. case 0x8:
  351. memcpy(ptr + i, cache_page, sizeof(cache_page));
  352. i += sizeof(cache_page);
  353. break;
  354. case 0x1B:
  355. memcpy(ptr + i, rbac_page, sizeof(rbac_page));
  356. i += sizeof(rbac_page);
  357. break;
  358. case 0x1C:
  359. memcpy(ptr + i, timer_page, sizeof(timer_page));
  360. i += sizeof(timer_page);
  361. break;
  362. case 0x3F:
  363. memcpy(ptr + i, timer_page, sizeof(timer_page));
  364. i += sizeof(timer_page);
  365. memcpy(ptr + i, rbac_page, sizeof(rbac_page));
  366. i += sizeof(rbac_page);
  367. memcpy(ptr + i, cache_page, sizeof(cache_page));
  368. i += sizeof(cache_page);
  369. memcpy(ptr + i, rw_err_page, sizeof(rw_err_page));
  370. i += sizeof(rw_err_page);
  371. break;
  372. }
  373. if (sense_6)
  374. ptr[0] = i - 1;
  375. else
  376. ((__be16 *) ptr)[0] = cpu_to_be16(i - 2);
  377. usb_stor_set_xfer_buf(ptr, i, srb);
  378. return USB_STOR_TRANSPORT_GOOD;
  379. }
  380. static void jumpshot_info_destructor(void *extra)
  381. {
  382. // this routine is a placeholder...
  383. // currently, we don't allocate any extra blocks so we're okay
  384. }
  385. // Transport for the Lexar 'Jumpshot'
  386. //
  387. static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
  388. {
  389. struct jumpshot_info *info;
  390. int rc;
  391. unsigned long block, blocks;
  392. unsigned char *ptr = us->iobuf;
  393. static unsigned char inquiry_response[8] = {
  394. 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
  395. };
  396. if (!us->extra) {
  397. us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
  398. if (!us->extra)
  399. return USB_STOR_TRANSPORT_ERROR;
  400. us->extra_destructor = jumpshot_info_destructor;
  401. }
  402. info = (struct jumpshot_info *) (us->extra);
  403. if (srb->cmnd[0] == INQUIRY) {
  404. usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
  405. memcpy(ptr, inquiry_response, sizeof(inquiry_response));
  406. fill_inquiry_response(us, ptr, 36);
  407. return USB_STOR_TRANSPORT_GOOD;
  408. }
  409. if (srb->cmnd[0] == READ_CAPACITY) {
  410. info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec
  411. rc = jumpshot_get_status(us);
  412. if (rc != USB_STOR_TRANSPORT_GOOD)
  413. return rc;
  414. rc = jumpshot_id_device(us, info);
  415. if (rc != USB_STOR_TRANSPORT_GOOD)
  416. return rc;
  417. usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
  418. info->sectors, info->ssize);
  419. // build the reply
  420. //
  421. ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
  422. ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize);
  423. usb_stor_set_xfer_buf(ptr, 8, srb);
  424. return USB_STOR_TRANSPORT_GOOD;
  425. }
  426. if (srb->cmnd[0] == MODE_SELECT_10) {
  427. usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
  428. return USB_STOR_TRANSPORT_ERROR;
  429. }
  430. if (srb->cmnd[0] == READ_10) {
  431. block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
  432. ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
  433. blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
  434. usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n",
  435. block, blocks);
  436. return jumpshot_read_data(us, info, block, blocks);
  437. }
  438. if (srb->cmnd[0] == READ_12) {
  439. // I don't think we'll ever see a READ_12 but support it anyway...
  440. //
  441. block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
  442. ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
  443. blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
  444. ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
  445. usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n",
  446. block, blocks);
  447. return jumpshot_read_data(us, info, block, blocks);
  448. }
  449. if (srb->cmnd[0] == WRITE_10) {
  450. block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
  451. ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
  452. blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
  453. usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n",
  454. block, blocks);
  455. return jumpshot_write_data(us, info, block, blocks);
  456. }
  457. if (srb->cmnd[0] == WRITE_12) {
  458. // I don't think we'll ever see a WRITE_12 but support it anyway...
  459. //
  460. block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
  461. ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
  462. blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
  463. ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
  464. usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n",
  465. block, blocks);
  466. return jumpshot_write_data(us, info, block, blocks);
  467. }
  468. if (srb->cmnd[0] == TEST_UNIT_READY) {
  469. usb_stor_dbg(us, "TEST_UNIT_READY\n");
  470. return jumpshot_get_status(us);
  471. }
  472. if (srb->cmnd[0] == REQUEST_SENSE) {
  473. usb_stor_dbg(us, "REQUEST_SENSE\n");
  474. memset(ptr, 0, 18);
  475. ptr[0] = 0xF0;
  476. ptr[2] = info->sense_key;
  477. ptr[7] = 11;
  478. ptr[12] = info->sense_asc;
  479. ptr[13] = info->sense_ascq;
  480. usb_stor_set_xfer_buf(ptr, 18, srb);
  481. return USB_STOR_TRANSPORT_GOOD;
  482. }
  483. if (srb->cmnd[0] == MODE_SENSE) {
  484. usb_stor_dbg(us, "MODE_SENSE_6 detected\n");
  485. return jumpshot_handle_mode_sense(us, srb, 1);
  486. }
  487. if (srb->cmnd[0] == MODE_SENSE_10) {
  488. usb_stor_dbg(us, "MODE_SENSE_10 detected\n");
  489. return jumpshot_handle_mode_sense(us, srb, 0);
  490. }
  491. if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
  492. /*
  493. * sure. whatever. not like we can stop the user from popping
  494. * the media out of the device (no locking doors, etc)
  495. */
  496. return USB_STOR_TRANSPORT_GOOD;
  497. }
  498. if (srb->cmnd[0] == START_STOP) {
  499. /*
  500. * this is used by sd.c'check_scsidisk_media_change to detect
  501. * media change
  502. */
  503. usb_stor_dbg(us, "START_STOP\n");
  504. /*
  505. * the first jumpshot_id_device after a media change returns
  506. * an error (determined experimentally)
  507. */
  508. rc = jumpshot_id_device(us, info);
  509. if (rc == USB_STOR_TRANSPORT_GOOD) {
  510. info->sense_key = NO_SENSE;
  511. srb->result = SUCCESS;
  512. } else {
  513. info->sense_key = UNIT_ATTENTION;
  514. srb->result = SAM_STAT_CHECK_CONDITION;
  515. }
  516. return rc;
  517. }
  518. usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
  519. srb->cmnd[0], srb->cmnd[0]);
  520. info->sense_key = 0x05;
  521. info->sense_asc = 0x20;
  522. info->sense_ascq = 0x00;
  523. return USB_STOR_TRANSPORT_FAILED;
  524. }
  525. static struct scsi_host_template jumpshot_host_template;
  526. static int jumpshot_probe(struct usb_interface *intf,
  527. const struct usb_device_id *id)
  528. {
  529. struct us_data *us;
  530. int result;
  531. result = usb_stor_probe1(&us, intf, id,
  532. (id - jumpshot_usb_ids) + jumpshot_unusual_dev_list,
  533. &jumpshot_host_template);
  534. if (result)
  535. return result;
  536. us->transport_name = "Lexar Jumpshot Control/Bulk";
  537. us->transport = jumpshot_transport;
  538. us->transport_reset = usb_stor_Bulk_reset;
  539. us->max_lun = 1;
  540. result = usb_stor_probe2(us);
  541. return result;
  542. }
  543. static struct usb_driver jumpshot_driver = {
  544. .name = DRV_NAME,
  545. .probe = jumpshot_probe,
  546. .disconnect = usb_stor_disconnect,
  547. .suspend = usb_stor_suspend,
  548. .resume = usb_stor_resume,
  549. .reset_resume = usb_stor_reset_resume,
  550. .pre_reset = usb_stor_pre_reset,
  551. .post_reset = usb_stor_post_reset,
  552. .id_table = jumpshot_usb_ids,
  553. .soft_unbind = 1,
  554. .no_dynamic_id = 1,
  555. };
  556. module_usb_stor_driver(jumpshot_driver, jumpshot_host_template, DRV_NAME);