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.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index bbeeb92a2131..a7d0bf9d92a7 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -407,15 +407,14 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
407 /* Store our private data in the interface */ 407 /* Store our private data in the interface */
408 usb_set_intfdata(intf, us); 408 usb_set_intfdata(intf, us);
409 409
410 /* Allocate the device-related DMA-mapped buffers */ 410 /* Allocate the control/setup and DMA-mapped buffers */
411 us->cr = usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr), 411 us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL);
412 GFP_KERNEL, &us->cr_dma);
413 if (!us->cr) { 412 if (!us->cr) {
414 US_DEBUGP("usb_ctrlrequest allocation failed\n"); 413 US_DEBUGP("usb_ctrlrequest allocation failed\n");
415 return -ENOMEM; 414 return -ENOMEM;
416 } 415 }
417 416
418 us->iobuf = usb_buffer_alloc(us->pusb_dev, US_IOBUF_SIZE, 417 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE,
419 GFP_KERNEL, &us->iobuf_dma); 418 GFP_KERNEL, &us->iobuf_dma);
420 if (!us->iobuf) { 419 if (!us->iobuf) {
421 US_DEBUGP("I/O buffer allocation failed\n"); 420 US_DEBUGP("I/O buffer allocation failed\n");
@@ -499,9 +498,6 @@ static void adjust_quirks(struct us_data *us)
499 } 498 }
500 } 499 }
501 us->fflags = (us->fflags & ~mask) | f; 500 us->fflags = (us->fflags & ~mask) | f;
502 dev_info(&us->pusb_intf->dev, "Quirks match for "
503 "vid %04x pid %04x: %x\n",
504 vid, pid, f);
505} 501}
506 502
507/* Get the unusual_devs entries and the string descriptors */ 503/* Get the unusual_devs entries and the string descriptors */
@@ -511,6 +507,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
511 struct usb_device *dev = us->pusb_dev; 507 struct usb_device *dev = us->pusb_dev;
512 struct usb_interface_descriptor *idesc = 508 struct usb_interface_descriptor *idesc =
513 &us->pusb_intf->cur_altsetting->desc; 509 &us->pusb_intf->cur_altsetting->desc;
510 struct device *pdev = &us->pusb_intf->dev;
514 511
515 /* Store the entries */ 512 /* Store the entries */
516 us->unusual_dev = unusual_dev; 513 us->unusual_dev = unusual_dev;
@@ -524,7 +521,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
524 adjust_quirks(us); 521 adjust_quirks(us);
525 522
526 if (us->fflags & US_FL_IGNORE_DEVICE) { 523 if (us->fflags & US_FL_IGNORE_DEVICE) {
527 printk(KERN_INFO USB_STORAGE "device ignored\n"); 524 dev_info(pdev, "device ignored\n");
528 return -ENODEV; 525 return -ENODEV;
529 } 526 }
530 527
@@ -535,6 +532,12 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
535 if (dev->speed != USB_SPEED_HIGH) 532 if (dev->speed != USB_SPEED_HIGH)
536 us->fflags &= ~US_FL_GO_SLOW; 533 us->fflags &= ~US_FL_GO_SLOW;
537 534
535 if (us->fflags)
536 dev_info(pdev, "Quirks match for vid %04x pid %04x: %lx\n",
537 le16_to_cpu(dev->descriptor.idVendor),
538 le16_to_cpu(dev->descriptor.idProduct),
539 us->fflags);
540
538 /* Log a message if a non-generic unusual_dev entry contains an 541 /* Log a message if a non-generic unusual_dev entry contains an
539 * unnecessary subclass or protocol override. This may stimulate 542 * unnecessary subclass or protocol override. This may stimulate
540 * reports from users that will help us remove unneeded entries 543 * reports from users that will help us remove unneeded entries
@@ -555,20 +558,20 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
555 us->protocol == idesc->bInterfaceProtocol) 558 us->protocol == idesc->bInterfaceProtocol)
556 msg += 2; 559 msg += 2;
557 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE)) 560 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE))
558 printk(KERN_NOTICE USB_STORAGE "This device " 561 dev_notice(pdev, "This device "
559 "(%04x,%04x,%04x S %02x P %02x)" 562 "(%04x,%04x,%04x S %02x P %02x)"
560 " has %s in unusual_devs.h (kernel" 563 " has %s in unusual_devs.h (kernel"
561 " %s)\n" 564 " %s)\n"
562 " Please send a copy of this message to " 565 " Please send a copy of this message to "
563 "<linux-usb@vger.kernel.org> and " 566 "<linux-usb@vger.kernel.org> and "
564 "<usb-storage@lists.one-eyed-alien.net>\n", 567 "<usb-storage@lists.one-eyed-alien.net>\n",
565 le16_to_cpu(ddesc->idVendor), 568 le16_to_cpu(ddesc->idVendor),
566 le16_to_cpu(ddesc->idProduct), 569 le16_to_cpu(ddesc->idProduct),
567 le16_to_cpu(ddesc->bcdDevice), 570 le16_to_cpu(ddesc->bcdDevice),
568 idesc->bInterfaceSubClass, 571 idesc->bInterfaceSubClass,
569 idesc->bInterfaceProtocol, 572 idesc->bInterfaceProtocol,
570 msgs[msg], 573 msgs[msg],
571 utsname()->release); 574 utsname()->release);
572 } 575 }
573 576
574 return 0; 577 return 0;
@@ -718,8 +721,8 @@ static int usb_stor_acquire_resources(struct us_data *us)
718 /* Start up our control thread */ 721 /* Start up our control thread */
719 th = kthread_run(usb_stor_control_thread, us, "usb-storage"); 722 th = kthread_run(usb_stor_control_thread, us, "usb-storage");
720 if (IS_ERR(th)) { 723 if (IS_ERR(th)) {
721 printk(KERN_WARNING USB_STORAGE 724 dev_warn(&us->pusb_intf->dev,
722 "Unable to start control thread\n"); 725 "Unable to start control thread\n");
723 return PTR_ERR(th); 726 return PTR_ERR(th);
724 } 727 }
725 us->ctl_thread = th; 728 us->ctl_thread = th;
@@ -757,13 +760,9 @@ static void dissociate_dev(struct us_data *us)
757{ 760{
758 US_DEBUGP("-- %s\n", __func__); 761 US_DEBUGP("-- %s\n", __func__);
759 762
760 /* Free the device-related DMA-mapped buffers */ 763 /* Free the buffers */
761 if (us->cr) 764 kfree(us->cr);
762 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, 765 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
763 us->cr_dma);
764 if (us->iobuf)
765 usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf,
766 us->iobuf_dma);
767 766
768 /* Remove our private data from the interface */ 767 /* Remove our private data from the interface */
769 usb_set_intfdata(us->pusb_intf, NULL); 768 usb_set_intfdata(us->pusb_intf, NULL);
@@ -816,13 +815,14 @@ static void release_everything(struct us_data *us)
816static int usb_stor_scan_thread(void * __us) 815static int usb_stor_scan_thread(void * __us)
817{ 816{
818 struct us_data *us = (struct us_data *)__us; 817 struct us_data *us = (struct us_data *)__us;
818 struct device *dev = &us->pusb_intf->dev;
819 819
820 dev_dbg(&us->pusb_intf->dev, "device found\n"); 820 dev_dbg(dev, "device found\n");
821 821
822 set_freezable(); 822 set_freezable();
823 /* Wait for the timeout to expire or for a disconnect */ 823 /* Wait for the timeout to expire or for a disconnect */
824 if (delay_use > 0) { 824 if (delay_use > 0) {
825 dev_dbg(&us->pusb_intf->dev, "waiting for device to settle " 825 dev_dbg(dev, "waiting for device to settle "
826 "before scanning\n"); 826 "before scanning\n");
827 wait_event_freezable_timeout(us->delay_wait, 827 wait_event_freezable_timeout(us->delay_wait,
828 test_bit(US_FLIDX_DONT_SCAN, &us->dflags), 828 test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
@@ -840,7 +840,7 @@ static int usb_stor_scan_thread(void * __us)
840 mutex_unlock(&us->dev_mutex); 840 mutex_unlock(&us->dev_mutex);
841 } 841 }
842 scsi_scan_host(us_to_host(us)); 842 scsi_scan_host(us_to_host(us));
843 dev_dbg(&us->pusb_intf->dev, "scan complete\n"); 843 dev_dbg(dev, "scan complete\n");
844 844
845 /* Should we unbind if no devices were detected? */ 845 /* Should we unbind if no devices were detected? */
846 } 846 }
@@ -876,8 +876,8 @@ int usb_stor_probe1(struct us_data **pus,
876 */ 876 */
877 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); 877 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
878 if (!host) { 878 if (!host) {
879 printk(KERN_WARNING USB_STORAGE 879 dev_warn(&intf->dev,
880 "Unable to allocate the scsi host\n"); 880 "Unable to allocate the scsi host\n");
881 return -ENOMEM; 881 return -ENOMEM;
882 } 882 }
883 883
@@ -925,6 +925,7 @@ int usb_stor_probe2(struct us_data *us)
925{ 925{
926 struct task_struct *th; 926 struct task_struct *th;
927 int result; 927 int result;
928 struct device *dev = &us->pusb_intf->dev;
928 929
929 /* Make sure the transport and protocol have both been set */ 930 /* Make sure the transport and protocol have both been set */
930 if (!us->transport || !us->proto_handler) { 931 if (!us->transport || !us->proto_handler) {
@@ -949,18 +950,18 @@ int usb_stor_probe2(struct us_data *us)
949 goto BadDevice; 950 goto BadDevice;
950 snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s", 951 snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
951 dev_name(&us->pusb_intf->dev)); 952 dev_name(&us->pusb_intf->dev));
952 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev); 953 result = scsi_add_host(us_to_host(us), dev);
953 if (result) { 954 if (result) {
954 printk(KERN_WARNING USB_STORAGE 955 dev_warn(dev,
955 "Unable to add the scsi host\n"); 956 "Unable to add the scsi host\n");
956 goto BadDevice; 957 goto BadDevice;
957 } 958 }
958 959
959 /* Start up the thread for delayed SCSI-device scanning */ 960 /* Start up the thread for delayed SCSI-device scanning */
960 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan"); 961 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan");
961 if (IS_ERR(th)) { 962 if (IS_ERR(th)) {
962 printk(KERN_WARNING USB_STORAGE 963 dev_warn(dev,
963 "Unable to start the device-scanning thread\n"); 964 "Unable to start the device-scanning thread\n");
964 complete(&us->scanning_done); 965 complete(&us->scanning_done);
965 quiesce_and_remove_host(us); 966 quiesce_and_remove_host(us);
966 result = PTR_ERR(th); 967 result = PTR_ERR(th);
@@ -1046,12 +1047,12 @@ static int __init usb_stor_init(void)
1046{ 1047{
1047 int retval; 1048 int retval;
1048 1049
1049 printk(KERN_INFO "Initializing USB Mass Storage driver...\n"); 1050 pr_info("Initializing USB Mass Storage driver...\n");
1050 1051
1051 /* register the driver, return usb_register return code if error */ 1052 /* register the driver, return usb_register return code if error */
1052 retval = usb_register(&usb_storage_driver); 1053 retval = usb_register(&usb_storage_driver);
1053 if (retval == 0) { 1054 if (retval == 0) {
1054 printk(KERN_INFO "USB Mass Storage support registered.\n"); 1055 pr_info("USB Mass Storage support registered.\n");
1055 usb_usual_set_present(USB_US_TYPE_STOR); 1056 usb_usual_set_present(USB_US_TYPE_STOR);
1056 } 1057 }
1057 return retval; 1058 return retval;