aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c93
1 files changed, 36 insertions, 57 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d6bee407af02..b4c63fcf7b0b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -183,7 +183,6 @@ int usb_stor_suspend(struct usb_interface *iface, pm_message_t message)
183 /* Wait until no command is running */ 183 /* Wait until no command is running */
184 mutex_lock(&us->dev_mutex); 184 mutex_lock(&us->dev_mutex);
185 185
186 US_DEBUGP("%s\n", __func__);
187 if (us->suspend_resume_hook) 186 if (us->suspend_resume_hook)
188 (us->suspend_resume_hook)(us, US_SUSPEND); 187 (us->suspend_resume_hook)(us, US_SUSPEND);
189 188
@@ -201,7 +200,6 @@ int usb_stor_resume(struct usb_interface *iface)
201 200
202 mutex_lock(&us->dev_mutex); 201 mutex_lock(&us->dev_mutex);
203 202
204 US_DEBUGP("%s\n", __func__);
205 if (us->suspend_resume_hook) 203 if (us->suspend_resume_hook)
206 (us->suspend_resume_hook)(us, US_RESUME); 204 (us->suspend_resume_hook)(us, US_RESUME);
207 205
@@ -214,8 +212,6 @@ int usb_stor_reset_resume(struct usb_interface *iface)
214{ 212{
215 struct us_data *us = usb_get_intfdata(iface); 213 struct us_data *us = usb_get_intfdata(iface);
216 214
217 US_DEBUGP("%s\n", __func__);
218
219 /* Report the reset to the SCSI core */ 215 /* Report the reset to the SCSI core */
220 usb_stor_report_bus_reset(us); 216 usb_stor_report_bus_reset(us);
221 217
@@ -236,8 +232,6 @@ int usb_stor_pre_reset(struct usb_interface *iface)
236{ 232{
237 struct us_data *us = usb_get_intfdata(iface); 233 struct us_data *us = usb_get_intfdata(iface);
238 234
239 US_DEBUGP("%s\n", __func__);
240
241 /* Make sure no command runs during the reset */ 235 /* Make sure no command runs during the reset */
242 mutex_lock(&us->dev_mutex); 236 mutex_lock(&us->dev_mutex);
243 return 0; 237 return 0;
@@ -248,8 +242,6 @@ int usb_stor_post_reset(struct usb_interface *iface)
248{ 242{
249 struct us_data *us = usb_get_intfdata(iface); 243 struct us_data *us = usb_get_intfdata(iface);
250 244
251 US_DEBUGP("%s\n", __func__);
252
253 /* Report the reset to the SCSI core */ 245 /* Report the reset to the SCSI core */
254 usb_stor_report_bus_reset(us); 246 usb_stor_report_bus_reset(us);
255 247
@@ -311,11 +303,11 @@ static int usb_stor_control_thread(void * __us)
311 struct Scsi_Host *host = us_to_host(us); 303 struct Scsi_Host *host = us_to_host(us);
312 304
313 for (;;) { 305 for (;;) {
314 US_DEBUGP("*** thread sleeping.\n"); 306 usb_stor_dbg(us, "*** thread sleeping\n");
315 if (wait_for_completion_interruptible(&us->cmnd_ready)) 307 if (wait_for_completion_interruptible(&us->cmnd_ready))
316 break; 308 break;
317 309
318 US_DEBUGP("*** thread awakened.\n"); 310 usb_stor_dbg(us, "*** thread awakened\n");
319 311
320 /* lock the device pointers */ 312 /* lock the device pointers */
321 mutex_lock(&(us->dev_mutex)); 313 mutex_lock(&(us->dev_mutex));
@@ -327,7 +319,7 @@ static int usb_stor_control_thread(void * __us)
327 if (us->srb == NULL) { 319 if (us->srb == NULL) {
328 scsi_unlock(host); 320 scsi_unlock(host);
329 mutex_unlock(&us->dev_mutex); 321 mutex_unlock(&us->dev_mutex);
330 US_DEBUGP("-- exiting\n"); 322 usb_stor_dbg(us, "-- exiting\n");
331 break; 323 break;
332 } 324 }
333 325
@@ -343,7 +335,7 @@ static int usb_stor_control_thread(void * __us)
343 * is UNKNOWN 335 * is UNKNOWN
344 */ 336 */
345 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { 337 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
346 US_DEBUGP("UNKNOWN data direction\n"); 338 usb_stor_dbg(us, "UNKNOWN data direction\n");
347 us->srb->result = DID_ERROR << 16; 339 us->srb->result = DID_ERROR << 16;
348 } 340 }
349 341
@@ -352,14 +344,14 @@ static int usb_stor_control_thread(void * __us)
352 */ 344 */
353 else if (us->srb->device->id && 345 else if (us->srb->device->id &&
354 !(us->fflags & US_FL_SCM_MULT_TARG)) { 346 !(us->fflags & US_FL_SCM_MULT_TARG)) {
355 US_DEBUGP("Bad target number (%d:%d)\n", 347 usb_stor_dbg(us, "Bad target number (%d:%d)\n",
356 us->srb->device->id, us->srb->device->lun); 348 us->srb->device->id, us->srb->device->lun);
357 us->srb->result = DID_BAD_TARGET << 16; 349 us->srb->result = DID_BAD_TARGET << 16;
358 } 350 }
359 351
360 else if (us->srb->device->lun > us->max_lun) { 352 else if (us->srb->device->lun > us->max_lun) {
361 US_DEBUGP("Bad LUN (%d:%d)\n", 353 usb_stor_dbg(us, "Bad LUN (%d:%d)\n",
362 us->srb->device->id, us->srb->device->lun); 354 us->srb->device->id, us->srb->device->lun);
363 us->srb->result = DID_BAD_TARGET << 16; 355 us->srb->result = DID_BAD_TARGET << 16;
364 } 356 }
365 357
@@ -371,14 +363,14 @@ static int usb_stor_control_thread(void * __us)
371 0x00, 0x80, 0x02, 0x02, 363 0x00, 0x80, 0x02, 0x02,
372 0x1F, 0x00, 0x00, 0x00}; 364 0x1F, 0x00, 0x00, 0x00};
373 365
374 US_DEBUGP("Faking INQUIRY command\n"); 366 usb_stor_dbg(us, "Faking INQUIRY command\n");
375 fill_inquiry_response(us, data_ptr, 36); 367 fill_inquiry_response(us, data_ptr, 36);
376 us->srb->result = SAM_STAT_GOOD; 368 us->srb->result = SAM_STAT_GOOD;
377 } 369 }
378 370
379 /* we've got a command, let's do it! */ 371 /* we've got a command, let's do it! */
380 else { 372 else {
381 US_DEBUG(usb_stor_show_command(us->srb)); 373 US_DEBUG(usb_stor_show_command(us, us->srb));
382 us->proto_handler(us->srb, us); 374 us->proto_handler(us->srb, us);
383 usb_mark_last_busy(us->pusb_dev); 375 usb_mark_last_busy(us->pusb_dev);
384 } 376 }
@@ -388,12 +380,12 @@ static int usb_stor_control_thread(void * __us)
388 380
389 /* indicate that the command is done */ 381 /* indicate that the command is done */
390 if (us->srb->result != DID_ABORT << 16) { 382 if (us->srb->result != DID_ABORT << 16) {
391 US_DEBUGP("scsi cmd done, result=0x%x\n", 383 usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
392 us->srb->result); 384 us->srb->result);
393 us->srb->scsi_done(us->srb); 385 us->srb->scsi_done(us->srb);
394 } else { 386 } else {
395SkipForAbort: 387SkipForAbort:
396 US_DEBUGP("scsi command aborted\n"); 388 usb_stor_dbg(us, "scsi command aborted\n");
397 } 389 }
398 390
399 /* If an abort request was received we need to signal that 391 /* If an abort request was received we need to signal that
@@ -435,34 +427,30 @@ SkipForAbort:
435/* Associate our private data with the USB device */ 427/* Associate our private data with the USB device */
436static int associate_dev(struct us_data *us, struct usb_interface *intf) 428static int associate_dev(struct us_data *us, struct usb_interface *intf)
437{ 429{
438 US_DEBUGP("-- %s\n", __func__);
439
440 /* Fill in the device-related fields */ 430 /* Fill in the device-related fields */
441 us->pusb_dev = interface_to_usbdev(intf); 431 us->pusb_dev = interface_to_usbdev(intf);
442 us->pusb_intf = intf; 432 us->pusb_intf = intf;
443 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; 433 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
444 US_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", 434 usb_stor_dbg(us, "Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
445 le16_to_cpu(us->pusb_dev->descriptor.idVendor), 435 le16_to_cpu(us->pusb_dev->descriptor.idVendor),
446 le16_to_cpu(us->pusb_dev->descriptor.idProduct), 436 le16_to_cpu(us->pusb_dev->descriptor.idProduct),
447 le16_to_cpu(us->pusb_dev->descriptor.bcdDevice)); 437 le16_to_cpu(us->pusb_dev->descriptor.bcdDevice));
448 US_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", 438 usb_stor_dbg(us, "Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
449 intf->cur_altsetting->desc.bInterfaceSubClass, 439 intf->cur_altsetting->desc.bInterfaceSubClass,
450 intf->cur_altsetting->desc.bInterfaceProtocol); 440 intf->cur_altsetting->desc.bInterfaceProtocol);
451 441
452 /* Store our private data in the interface */ 442 /* Store our private data in the interface */
453 usb_set_intfdata(intf, us); 443 usb_set_intfdata(intf, us);
454 444
455 /* Allocate the control/setup and DMA-mapped buffers */ 445 /* Allocate the control/setup and DMA-mapped buffers */
456 us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL); 446 us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL);
457 if (!us->cr) { 447 if (!us->cr)
458 US_DEBUGP("usb_ctrlrequest allocation failed\n");
459 return -ENOMEM; 448 return -ENOMEM;
460 }
461 449
462 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, 450 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE,
463 GFP_KERNEL, &us->iobuf_dma); 451 GFP_KERNEL, &us->iobuf_dma);
464 if (!us->iobuf) { 452 if (!us->iobuf) {
465 US_DEBUGP("I/O buffer allocation failed\n"); 453 usb_stor_dbg(us, "I/O buffer allocation failed\n");
466 return -ENOMEM; 454 return -ENOMEM;
467 } 455 }
468 return 0; 456 return 0;
@@ -738,7 +726,7 @@ static int get_pipes(struct us_data *us)
738 } 726 }
739 727
740 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { 728 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
741 US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); 729 usb_stor_dbg(us, "Endpoint sanity check failed! Rejecting dev.\n");
742 return -EIO; 730 return -EIO;
743 } 731 }
744 732
@@ -765,7 +753,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
765 753
766 us->current_urb = usb_alloc_urb(0, GFP_KERNEL); 754 us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
767 if (!us->current_urb) { 755 if (!us->current_urb) {
768 US_DEBUGP("URB allocation failed\n"); 756 usb_stor_dbg(us, "URB allocation failed\n");
769 return -ENOMEM; 757 return -ENOMEM;
770 } 758 }
771 759
@@ -792,20 +780,18 @@ static int usb_stor_acquire_resources(struct us_data *us)
792/* Release all our dynamic resources */ 780/* Release all our dynamic resources */
793static void usb_stor_release_resources(struct us_data *us) 781static void usb_stor_release_resources(struct us_data *us)
794{ 782{
795 US_DEBUGP("-- %s\n", __func__);
796
797 /* Tell the control thread to exit. The SCSI host must 783 /* Tell the control thread to exit. The SCSI host must
798 * already have been removed and the DISCONNECTING flag set 784 * already have been removed and the DISCONNECTING flag set
799 * so that we won't accept any more commands. 785 * so that we won't accept any more commands.
800 */ 786 */
801 US_DEBUGP("-- sending exit command to thread\n"); 787 usb_stor_dbg(us, "-- sending exit command to thread\n");
802 complete(&us->cmnd_ready); 788 complete(&us->cmnd_ready);
803 if (us->ctl_thread) 789 if (us->ctl_thread)
804 kthread_stop(us->ctl_thread); 790 kthread_stop(us->ctl_thread);
805 791
806 /* Call the destructor routine, if it exists */ 792 /* Call the destructor routine, if it exists */
807 if (us->extra_destructor) { 793 if (us->extra_destructor) {
808 US_DEBUGP("-- calling extra_destructor()\n"); 794 usb_stor_dbg(us, "-- calling extra_destructor()\n");
809 us->extra_destructor(us->extra); 795 us->extra_destructor(us->extra);
810 } 796 }
811 797
@@ -817,8 +803,6 @@ static void usb_stor_release_resources(struct us_data *us)
817/* Dissociate from the USB device */ 803/* Dissociate from the USB device */
818static void dissociate_dev(struct us_data *us) 804static void dissociate_dev(struct us_data *us)
819{ 805{
820 US_DEBUGP("-- %s\n", __func__);
821
822 /* Free the buffers */ 806 /* Free the buffers */
823 kfree(us->cr); 807 kfree(us->cr);
824 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma); 808 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
@@ -918,7 +902,7 @@ int usb_stor_probe1(struct us_data **pus,
918 struct us_data *us; 902 struct us_data *us;
919 int result; 903 int result;
920 904
921 US_DEBUGP("USB Mass Storage device detected\n"); 905 dev_info(&intf->dev, "USB Mass Storage device detected\n");
922 906
923 /* 907 /*
924 * Ask the SCSI layer to allocate a host structure, with extra 908 * Ask the SCSI layer to allocate a host structure, with extra
@@ -926,8 +910,7 @@ int usb_stor_probe1(struct us_data **pus,
926 */ 910 */
927 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); 911 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
928 if (!host) { 912 if (!host) {
929 dev_warn(&intf->dev, 913 dev_warn(&intf->dev, "Unable to allocate the scsi host\n");
930 "Unable to allocate the scsi host\n");
931 return -ENOMEM; 914 return -ENOMEM;
932 } 915 }
933 916
@@ -964,7 +947,7 @@ int usb_stor_probe1(struct us_data **pus,
964 return 0; 947 return 0;
965 948
966BadDevice: 949BadDevice:
967 US_DEBUGP("storage_probe() failed\n"); 950 usb_stor_dbg(us, "storage_probe() failed\n");
968 release_everything(us); 951 release_everything(us);
969 return result; 952 return result;
970} 953}
@@ -981,8 +964,8 @@ int usb_stor_probe2(struct us_data *us)
981 result = -ENXIO; 964 result = -ENXIO;
982 goto BadDevice; 965 goto BadDevice;
983 } 966 }
984 US_DEBUGP("Transport: %s\n", us->transport_name); 967 usb_stor_dbg(us, "Transport: %s\n", us->transport_name);
985 US_DEBUGP("Protocol: %s\n", us->protocol_name); 968 usb_stor_dbg(us, "Protocol: %s\n", us->protocol_name);
986 969
987 /* fix for single-lun devices */ 970 /* fix for single-lun devices */
988 if (us->fflags & US_FL_SINGLE_LUN) 971 if (us->fflags & US_FL_SINGLE_LUN)
@@ -1028,7 +1011,7 @@ int usb_stor_probe2(struct us_data *us)
1028 1011
1029 /* We come here if there are any problems */ 1012 /* We come here if there are any problems */
1030BadDevice: 1013BadDevice:
1031 US_DEBUGP("storage_probe() failed\n"); 1014 usb_stor_dbg(us, "storage_probe() failed\n");
1032 release_everything(us); 1015 release_everything(us);
1033 return result; 1016 return result;
1034} 1017}
@@ -1039,7 +1022,6 @@ void usb_stor_disconnect(struct usb_interface *intf)
1039{ 1022{
1040 struct us_data *us = usb_get_intfdata(intf); 1023 struct us_data *us = usb_get_intfdata(intf);
1041 1024
1042 US_DEBUGP("storage_disconnect() called\n");
1043 quiesce_and_remove_host(us); 1025 quiesce_and_remove_host(us);
1044 release_everything(us); 1026 release_everything(us);
1045} 1027}
@@ -1075,8 +1057,7 @@ static int storage_probe(struct usb_interface *intf,
1075 } else { 1057 } else {
1076 unusual_dev = &for_dynamic_ids; 1058 unusual_dev = &for_dynamic_ids;
1077 1059
1078 US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport", 1060 dev_dbg(&intf->dev, "Use Bulk-Only transport with the Transparent SCSI protocol for dynamic id: 0x%04x 0x%04x\n",
1079 "with the Transparent SCSI protocol for dynamic id:",
1080 id->idVendor, id->idProduct); 1061 id->idVendor, id->idProduct);
1081 } 1062 }
1082 1063
@@ -1117,20 +1098,18 @@ static int __init usb_stor_init(void)
1117 /* register the driver, return usb_register return code if error */ 1098 /* register the driver, return usb_register return code if error */
1118 retval = usb_register(&usb_storage_driver); 1099 retval = usb_register(&usb_storage_driver);
1119 if (retval == 0) 1100 if (retval == 0)
1120 pr_info("USB Mass Storage support registered.\n"); 1101 pr_info("USB Mass Storage support registered\n");
1121 return retval; 1102 return retval;
1122} 1103}
1123 1104
1124static void __exit usb_stor_exit(void) 1105static void __exit usb_stor_exit(void)
1125{ 1106{
1126 US_DEBUGP("usb_stor_exit() called\n");
1127
1128 /* Deregister the driver 1107 /* Deregister the driver
1129 * This will cause disconnect() to be called for each 1108 * This will cause disconnect() to be called for each
1130 * attached unit 1109 * attached unit
1131 */ 1110 */
1132 US_DEBUGP("-- calling usb_deregister()\n"); 1111 pr_info("Deregistering USB Mass Storage driver...\n");
1133 usb_deregister(&usb_storage_driver) ; 1112 usb_deregister(&usb_storage_driver);
1134} 1113}
1135 1114
1136module_init(usb_stor_init); 1115module_init(usb_stor_init);