hpusbscsi.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:17k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * hpusbscsi
  3.  * (C) Copyright 2001 Oliver Neukum 
  4.  * Sponsored by the Linux Usb Project
  5.  * Large parts based on or taken from code by John Fremlin and Matt Dharm
  6.  * 
  7.  * This driver is known to work with the following scanners (VID, PID)
  8.  *    (0x03f0, 0x0701)  HP 53xx 
  9.  *    (0x03f0, 0x0801)  HP 7400 
  10.  *    (0x0638, 0x026a)  Minolta Scan Dual II
  11.  *    (0x0686, 0x4004)  Minolta Elite II
  12.  * To load with full debugging load with "insmod hpusbscsi debug=2"
  13.  * 
  14.  * This program is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the
  16.  * Free Software Foundation; either version 2 of the License, or (at your
  17.  * option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful, but
  20.  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  21.  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  22.  * for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software Foundation,
  26.  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  *
  28.  * Contributors:
  29.  *   Oliver Neukum
  30.  *   John Fremlin
  31.  *   Matt Dharm
  32.  *   .
  33.  *   .
  34.  *   Timothy Jedlicka <bonzo@lucent.com>
  35.  *
  36.  * History
  37.  *
  38.  * 22-Apr-2002
  39.  *
  40.  * - Added Elite II scanner - bonzo
  41.  * - Cleaned up the debug statements and made them optional at load time - bonzo
  42.  *
  43.  * 20020618
  44.  *
  45.  * - Confirm to stupid 2.4 rules on io_request_lock
  46.  *
  47.  */
  48. #include <linux/module.h>
  49. #include <linux/kernel.h>
  50. #include <linux/sched.h>
  51. #include <linux/signal.h>
  52. #include <linux/errno.h>
  53. #include <linux/init.h>
  54. #include <linux/slab.h>
  55. #include <linux/spinlock.h>
  56. #include <linux/smp_lock.h>
  57. #include <linux/usb.h>
  58. #include <asm/atomic.h>
  59. #include <linux/blk.h>
  60. #include "../scsi/scsi.h"
  61. #include "../scsi/hosts.h"
  62. #include "../scsi/sd.h"
  63. #include "hpusbscsi.h"
  64. static char *states[]={"FREE", "BEGINNING", "WORKING", "ERROR", "WAIT", "PREMATURE"};
  65. /* DEBUG related parts */
  66. #define HPUSBSCSI_DEBUG
  67. #ifdef HPUSBSCSI_DEBUG
  68. #  define PDEBUG(level, fmt, args...) 
  69.           if (debug >= (level)) info("[" __PRETTY_FUNCTION__ ":%d] " fmt, __LINE__ , 
  70.                  ## args)
  71. #else
  72. #  define PDEBUG(level, fmt, args...) do {} while(0)
  73. #endif
  74. /* 0=no debug messages
  75.  * 1=everything but trace states
  76.  * 2=trace states
  77.  */
  78. static int debug; /* = 0 */
  79. MODULE_PARM(debug, "i");
  80. MODULE_PARM_DESC(debug, "Debug level: 0=none, 1=no trace states, 2=trace states");
  81. /* global variables */
  82. struct list_head hpusbscsi_devices;
  83. //LIST_HEAD(hpusbscsi_devices);
  84. /* USB related parts */
  85. static void *
  86. hpusbscsi_usb_probe (struct usb_device *dev, unsigned int interface,
  87.      const struct usb_device_id *id)
  88. {
  89. struct hpusbscsi *new;
  90. struct usb_interface_descriptor *altsetting =
  91. &(dev->actconfig->interface[interface].altsetting[0]);
  92. int i, result;
  93. /* basic check */
  94. if (altsetting->bNumEndpoints != 3) {
  95. printk (KERN_ERR "Wrong number of endpointsn");
  96. return NULL;
  97. }
  98. /* descriptor allocation */
  99. new =
  100. (struct hpusbscsi *) kmalloc (sizeof (struct hpusbscsi),
  101.       GFP_KERNEL);
  102. if (new == NULL)
  103. return NULL;
  104. PDEBUG (1, "Allocated memory");
  105. memset (new, 0, sizeof (struct hpusbscsi));
  106. spin_lock_init (&new->dataurb.lock);
  107. spin_lock_init (&new->controlurb.lock);
  108. new->dev = dev;
  109. init_waitqueue_head (&new->pending);
  110. init_waitqueue_head (&new->deathrow);
  111. INIT_LIST_HEAD (&new->lh);
  112. /* finding endpoints */
  113. for (i = 0; i < altsetting->bNumEndpoints; i++) {
  114. if (
  115.     (altsetting->endpoint[i].
  116.      bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
  117.     USB_ENDPOINT_XFER_BULK) {
  118. if (altsetting->endpoint[i].
  119.     bEndpointAddress & USB_DIR_IN) {
  120. new->ep_in =
  121. altsetting->endpoint[i].
  122. bEndpointAddress &
  123. USB_ENDPOINT_NUMBER_MASK;
  124. } else {
  125. new->ep_out =
  126. altsetting->endpoint[i].
  127. bEndpointAddress &
  128. USB_ENDPOINT_NUMBER_MASK;
  129. }
  130. } else {
  131. new->ep_int =
  132. altsetting->endpoint[i].
  133. bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
  134. new->interrupt_interval= altsetting->endpoint[i].bInterval;
  135. }
  136. }
  137. /* USB initialisation magic for the simple case */
  138. result = usb_set_interface (dev, altsetting->bInterfaceNumber, 0);
  139. switch (result) {
  140. case 0: /* no error */
  141. break;
  142. case -EPIPE:
  143. usb_clear_halt (dev, usb_sndctrlpipe (dev, 0));
  144. break;
  145. default:
  146. printk (KERN_ERR "unknown error %d from usb_set_interfacen",
  147.  result);
  148. goto err_out;
  149. }
  150. /* making a template for the scsi layer to fake detection of a scsi device */
  151. memcpy (&(new->ctempl), &hpusbscsi_scsi_host_template,
  152. sizeof (hpusbscsi_scsi_host_template));
  153. (struct hpusbscsi *) new->ctempl.proc_dir = new;
  154. new->ctempl.module = THIS_MODULE;
  155. if (scsi_register_module (MODULE_SCSI_HA, &(new->ctempl)))
  156. goto err_out;
  157. new->sense_command[0] = REQUEST_SENSE;
  158. new->sense_command[4] = HPUSBSCSI_SENSE_LENGTH;
  159. /* adding to list for module unload */
  160. list_add (&hpusbscsi_devices, &new->lh);
  161. return new;
  162.       err_out:
  163. kfree (new);
  164. return NULL;
  165. }
  166. static void
  167. hpusbscsi_usb_disconnect (struct usb_device *dev, void *ptr)
  168. {
  169. struct hpusbscsi *hp = (struct hpusbscsi *)ptr;
  170. usb_unlink_urb(&hp->controlurb);
  171. usb_unlink_urb(&hp->dataurb);
  172. spin_lock_irq(&io_request_lock);
  173. hp->dev = NULL;
  174. spin_unlock_irq(&io_request_lock);
  175. }
  176. static struct usb_device_id hpusbscsi_usb_ids[] = {
  177. {USB_DEVICE (0x03f0, 0x0701)}, /* HP 53xx */
  178. {USB_DEVICE (0x03f0, 0x0801)}, /* HP 7400 */
  179. {USB_DEVICE (0x0638, 0x0268)},  /*iVina 1200U */
  180. {USB_DEVICE (0x0638, 0x026a)}, /*Scan Dual II */
  181. {USB_DEVICE (0x0638, 0x0A13)},  /*Avision AV600U */
  182. {USB_DEVICE (0x0638, 0x0A16)},  /*Avision DS610CU Scancopier */
  183. {USB_DEVICE (0x0638, 0x0A18)},  /*Avision AV600U Plus */
  184. {USB_DEVICE (0x0638, 0x0A23)},  /*Avision AV220 */
  185. {USB_DEVICE (0x0638, 0x0A24)},  /*Avision AV210 */
  186. {USB_DEVICE (0x0686, 0x4004)},  /*Minolta Elite II */
  187. {} /* Terminating entry */
  188. };
  189. MODULE_DEVICE_TABLE (usb, hpusbscsi_usb_ids);
  190. MODULE_LICENSE("GPL");
  191. static struct usb_driver hpusbscsi_usb_driver = {
  192. name:"hpusbscsi",
  193. probe:hpusbscsi_usb_probe,
  194. disconnect:hpusbscsi_usb_disconnect,
  195. id_table:hpusbscsi_usb_ids,
  196. };
  197. /* module initialisation */
  198. int __init
  199. hpusbscsi_init (void)
  200. {
  201. int result;
  202. INIT_LIST_HEAD (&hpusbscsi_devices);
  203. PDEBUG(0, "driver loaded, DebugLvel=%d", debug);
  204.  
  205. if ((result = usb_register (&hpusbscsi_usb_driver)) < 0) {
  206. printk (KERN_ERR "hpusbscsi: driver registration failedn");
  207. return -1;
  208. } else {
  209. return 0;
  210. }
  211. }
  212. void __exit
  213. hpusbscsi_exit (void)
  214. {
  215. struct list_head *tmp;
  216. struct list_head *old;
  217. struct hpusbscsi * o;
  218. for (tmp = hpusbscsi_devices.next; tmp != &hpusbscsi_devices;/*nothing */) {
  219. old = tmp;
  220. tmp = tmp->next;
  221. o = (struct hpusbscsi *)old;
  222. usb_unlink_urb(&o->controlurb);
  223. if(scsi_unregister_module(MODULE_SCSI_HA,&o->ctempl)<0)
  224. printk(KERN_CRIT"Deregistering failed!n");
  225. kfree(old);
  226. }
  227. usb_deregister (&hpusbscsi_usb_driver);
  228. }
  229. module_init (hpusbscsi_init);
  230. module_exit (hpusbscsi_exit);
  231. /* interface to the scsi layer */
  232. static int
  233. hpusbscsi_scsi_detect (struct SHT *sht)
  234. {
  235. /* Whole function stolen from usb-storage */
  236. struct hpusbscsi *desc = (struct hpusbscsi *) sht->proc_dir;
  237. /* What a hideous hack! */
  238. char local_name[48];
  239. spin_unlock_irq(&io_request_lock);
  240. /* set up the name of our subdirectory under /proc/scsi/ */
  241. sprintf (local_name, "hpusbscsi-%d", desc->number);
  242. sht->proc_name = kmalloc (strlen (local_name) + 1, GFP_KERNEL);
  243. /* FIXME: where is this freed ? */
  244. if (!sht->proc_name) {
  245. spin_lock_irq(&io_request_lock);
  246. return 0;
  247. }
  248. strcpy (sht->proc_name, local_name);
  249. sht->proc_dir = NULL;
  250. /* build and submit an interrupt URB for status byte handling */
  251.   FILL_INT_URB(&desc->controlurb,
  252. desc->dev,
  253. usb_rcvintpipe(desc->dev,desc->ep_int),
  254. &desc->scsi_state_byte,
  255. 1,
  256. control_interrupt_callback,
  257. desc,
  258. desc->interrupt_interval
  259. );
  260. if ( 0  >  usb_submit_urb(&desc->controlurb)) {
  261. kfree(sht->proc_name);
  262. spin_lock_irq(&io_request_lock);
  263. return 0;
  264. }
  265. /* In host->hostdata we store a pointer to desc */
  266. desc->host = scsi_register (sht, sizeof (desc));
  267. if (desc->host == NULL) {
  268. kfree (sht->proc_name);
  269. usb_unlink_urb(&desc->controlurb);
  270. spin_lock_irq(&io_request_lock);
  271. return 0;
  272. }
  273. desc->host->hostdata[0] = (unsigned long) desc;
  274. spin_lock_irq(&io_request_lock);
  275. return 1;
  276. }
  277. static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback)
  278. {
  279. struct hpusbscsi* hpusbscsi = (struct hpusbscsi*)(srb->host->hostdata[0]);
  280. usb_urb_callback usb_callback;
  281. int res;
  282. spin_unlock_irq(&io_request_lock);
  283. /* we don't answer for anything but our single device on any faked host controller */
  284. if ( srb->device->lun || srb->device->id || srb->device->channel ) {
  285. srb->result = DID_BAD_TARGET;
  286. callback(srb);
  287. goto out;
  288. }
  289. /* Now we need to decide which callback to give to the urb we send the command with */
  290. if (!srb->bufflen) {
  291. if (srb->cmnd[0] == REQUEST_SENSE){
  292. /* the usual buffer is not used, needs a special case */
  293. hpusbscsi->current_data_pipe = usb_rcvbulkpipe(hpusbscsi->dev, hpusbscsi->ep_in);
  294. usb_callback = request_sense_callback;
  295. } else {
  296. usb_callback = simple_command_callback;
  297. }
  298. } else {
  299.          if (srb->use_sg) {
  300. usb_callback = scatter_gather_callback;
  301. hpusbscsi->fragment = 0;
  302. } else {
  303.                  usb_callback = simple_payload_callback;
  304. }
  305. /* Now we find out which direction data is to be transfered in */
  306. hpusbscsi->current_data_pipe = DIRECTION_IS_IN(srb->cmnd[0]) ?
  307. usb_rcvbulkpipe(hpusbscsi->dev, hpusbscsi->ep_in)
  308. :
  309. usb_sndbulkpipe(hpusbscsi->dev, hpusbscsi->ep_out)
  310. ;
  311. }
  312. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  313. if (hpusbscsi->state != HP_STATE_FREE) {
  314. printk(KERN_CRIT"hpusbscsi - Ouch: queueing violation!n");
  315. return 1; /* This must not happen */
  316. }
  317.         /* We zero the sense buffer to avoid confusing user space */
  318.         memset(srb->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
  319. hpusbscsi->state = HP_STATE_BEGINNING;
  320. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  321. /* We prepare the urb for writing out the scsi command */
  322. FILL_BULK_URB(
  323. &hpusbscsi->dataurb,
  324. hpusbscsi->dev,
  325. usb_sndbulkpipe(hpusbscsi->dev,hpusbscsi->ep_out),
  326. srb->cmnd,
  327. srb->cmd_len,
  328. usb_callback,
  329. hpusbscsi
  330. );
  331. hpusbscsi->scallback = callback;
  332. hpusbscsi->srb = srb;
  333. if (hpusbscsi->dev == NULL) {
  334. srb->result = DID_ERROR;
  335. callback(srb);
  336. goto out;
  337. }
  338. res = usb_submit_urb(&hpusbscsi->dataurb);
  339. if (res) {
  340. hpusbscsi->state = HP_STATE_FREE;
  341. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  342. srb->result = DID_ERROR;
  343. callback(srb);
  344. }
  345. out:
  346. spin_lock_irq(&io_request_lock);
  347. return 0;
  348. }
  349. static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb)
  350. {
  351. struct hpusbscsi* hpusbscsi = (struct hpusbscsi*)(srb->host->hostdata[0]);
  352. PDEBUG(1, "SCSI reset requested");
  353. //usb_reset_device(hpusbscsi->dev);
  354. //PDEBUG(1, "SCSI reset completed");
  355. hpusbscsi->state = HP_STATE_FREE;
  356. return 0;
  357. }
  358. static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb)
  359. {
  360. struct hpusbscsi* hpusbscsi = (struct hpusbscsi*)(srb->host->hostdata[0]);
  361. PDEBUG(1, "Request is canceled");
  362. spin_unlock_irq(&io_request_lock);
  363. usb_unlink_urb(&hpusbscsi->dataurb);
  364. hpusbscsi->state = HP_STATE_FREE;
  365. spin_lock_irq(&io_request_lock);
  366. return SCSI_ABORT_PENDING;
  367. }
  368. /* usb interrupt handlers - they are all running IN INTERRUPT ! */
  369. static void handle_usb_error (struct hpusbscsi *hpusbscsi)
  370. {
  371. if (hpusbscsi->scallback != NULL) {
  372. hpusbscsi->srb->result = DID_ERROR;
  373. hpusbscsi->scallback(hpusbscsi->srb);
  374. }
  375. hpusbscsi->state = HP_STATE_FREE;
  376. }
  377. static void  control_interrupt_callback (struct urb *u)
  378. {
  379. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  380. u8 scsi_state;
  381. PDEBUG(1, "Getting status byte %d",hpusbscsi->scsi_state_byte);
  382. if(u->status < 0) {
  383.                 if (hpusbscsi->state != HP_STATE_FREE)
  384.                         handle_usb_error(hpusbscsi);
  385. return;
  386. }
  387. scsi_state = hpusbscsi->scsi_state_byte;
  388.         if (hpusbscsi->state != HP_STATE_ERROR) {
  389.                 hpusbscsi->srb->result &= SCSI_ERR_MASK;
  390.                 hpusbscsi->srb->result |= scsi_state;
  391.         }
  392. if (scsi_state == CHECK_CONDITION << 1) {
  393. if (hpusbscsi->state == HP_STATE_WAIT) {
  394. issue_request_sense(hpusbscsi);
  395. } else {
  396. /* we request sense after an eventual data transfer */
  397. hpusbscsi->state = HP_STATE_ERROR;
  398. }
  399. }
  400. if (hpusbscsi->scallback != NULL && hpusbscsi->state == HP_STATE_WAIT && scsi_state != CHECK_CONDITION <<1)
  401. /* we do a callback to the scsi layer if and only if all data has been transfered */
  402. hpusbscsi->scallback(hpusbscsi->srb);
  403. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  404. switch (hpusbscsi->state) {
  405. case HP_STATE_WAIT:
  406. hpusbscsi->state = HP_STATE_FREE;
  407. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  408. break;
  409. case HP_STATE_WORKING:
  410. case HP_STATE_BEGINNING:
  411. hpusbscsi->state = HP_STATE_PREMATURE;
  412. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  413. break;
  414. case HP_STATE_ERROR:
  415. break;
  416. default:
  417. printk(KERN_ERR"hpusbscsi: Unexpected status report.n");
  418. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  419. hpusbscsi->state = HP_STATE_FREE;
  420. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  421. break;
  422. }
  423. }
  424. static void simple_command_callback(struct urb *u)
  425. {
  426. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  427. if (u->status<0) {
  428. handle_usb_error(hpusbscsi);
  429. return;
  430.         }
  431. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  432. if (hpusbscsi->state != HP_STATE_PREMATURE) {
  433.         PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  434. hpusbscsi->state = HP_STATE_WAIT;
  435. } else {
  436. if (hpusbscsi->scallback != NULL)
  437. hpusbscsi->scallback(hpusbscsi->srb);
  438. hpusbscsi->state = HP_STATE_FREE;
  439. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  440. }
  441. }
  442. static void scatter_gather_callback(struct urb *u)
  443. {
  444. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  445.         struct scatterlist *sg = hpusbscsi->srb->buffer;
  446.         usb_urb_callback callback;
  447.         int res;
  448.         PDEBUG(1, "Going through scatter/gather"); // bonzo - this gets hit a lot - maybe make it a 2
  449.         if (u->status < 0) {
  450.                 handle_usb_error(hpusbscsi);
  451.                 return;
  452.         }
  453.         if (hpusbscsi->fragment + 1 != hpusbscsi->srb->use_sg)
  454.                 callback = scatter_gather_callback;
  455.         else
  456.                 callback = simple_done;
  457. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  458.         if (hpusbscsi->state != HP_STATE_PREMATURE)
  459. hpusbscsi->state = HP_STATE_WORKING;
  460. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  461.         FILL_BULK_URB(
  462.                 u,
  463.                 hpusbscsi->dev,
  464.                 hpusbscsi->current_data_pipe,
  465.                 sg[hpusbscsi->fragment].address,
  466.                 sg[hpusbscsi->fragment++].length,
  467.                 callback,
  468.                 hpusbscsi
  469.         );
  470.         res = usb_submit_urb(u);
  471.         if (res)
  472.          handle_usb_error(hpusbscsi);
  473. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  474. }
  475. static void simple_done (struct urb *u)
  476. {
  477. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  478.         if (u->status < 0) {
  479.                 handle_usb_error(hpusbscsi);
  480.                 return;
  481.         }
  482. PDEBUG(1, "Data transfer done");
  483. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  484. if (hpusbscsi->state != HP_STATE_PREMATURE) {
  485. if (u->status < 0) {
  486. handle_usb_error(hpusbscsi);
  487. } else {
  488. if (hpusbscsi->state != HP_STATE_ERROR) {
  489. hpusbscsi->state = HP_STATE_WAIT;
  490. } else {
  491. issue_request_sense(hpusbscsi);
  492. }
  493. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  494. }
  495. } else {
  496. if (hpusbscsi->scallback != NULL)
  497. hpusbscsi->scallback(hpusbscsi->srb);
  498. hpusbscsi->state = HP_STATE_FREE;
  499. }
  500. }
  501. static void simple_payload_callback (struct urb *u)
  502. {
  503. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  504. int res;
  505. if (u->status<0) {
  506.                 handle_usb_error(hpusbscsi);
  507. return;
  508.         }
  509. FILL_BULK_URB(
  510. u,
  511. hpusbscsi->dev,
  512. hpusbscsi->current_data_pipe,
  513. hpusbscsi->srb->buffer,
  514. hpusbscsi->srb->bufflen,
  515. simple_done,
  516. hpusbscsi
  517. );
  518. res = usb_submit_urb(u);
  519. if (res) {
  520.                 handle_usb_error(hpusbscsi);
  521. return;
  522.         }
  523. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  524. if (hpusbscsi->state != HP_STATE_PREMATURE) {
  525. hpusbscsi->state = HP_STATE_WORKING;
  526. PDEBUG(2, "state= %s", states[hpusbscsi->state]);
  527. }
  528. }
  529. static void request_sense_callback (struct urb *u)
  530. {
  531. struct hpusbscsi * hpusbscsi = (struct hpusbscsi *)u->context;
  532. if (u->status<0) {
  533.                 handle_usb_error(hpusbscsi);
  534. return;
  535.         }
  536. FILL_BULK_URB(
  537. u,
  538. hpusbscsi->dev,
  539. hpusbscsi->current_data_pipe,
  540. hpusbscsi->srb->sense_buffer,
  541. SCSI_SENSE_BUFFERSIZE,
  542. simple_done,
  543. hpusbscsi
  544. );
  545. if (0 > usb_submit_urb(u)) {
  546. handle_usb_error(hpusbscsi);
  547. return;
  548. }
  549. if (hpusbscsi->state != HP_STATE_PREMATURE && hpusbscsi->state != HP_STATE_ERROR)
  550. hpusbscsi->state = HP_STATE_WORKING;
  551. }
  552. static void issue_request_sense (struct hpusbscsi *hpusbscsi)
  553. {
  554. FILL_BULK_URB(
  555. &hpusbscsi->dataurb,
  556. hpusbscsi->dev,
  557. usb_sndbulkpipe(hpusbscsi->dev, hpusbscsi->ep_out),
  558. &hpusbscsi->sense_command,
  559. SENSE_COMMAND_SIZE,
  560. request_sense_callback,
  561. hpusbscsi
  562. );
  563. hpusbscsi->current_data_pipe = usb_rcvbulkpipe(hpusbscsi->dev, hpusbscsi->ep_in);
  564. if (0 > usb_submit_urb(&hpusbscsi->dataurb)) {
  565. handle_usb_error(hpusbscsi);
  566. }
  567. }