diff options
author | Bjørn Mork <bjorn@mork.no> | 2012-01-16 09:12:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-24 17:34:09 -0500 |
commit | 8457d99cab81e91724b43363f7fccd851d766187 (patch) | |
tree | 92b6e613c007894e2da249008b68b9bd7637b26f /drivers/usb/class/cdc-wdm.c | |
parent | cafbe85fb0d00d32988905c4978df433ca9b6512 (diff) |
USB: cdc-wdm: no need to use usb_alloc_coherent
As Documentation/usb/dma.txt states:
Most drivers should *NOT* be using these primitives; they don't need
to use this type of memory (dma-coherent), and memory returned from
kmalloc() will work just fine.
This driver handle only very low bandwith transfers. It is not an
obvious candidate for usb_alloc_coherent().
Using these calls only serves to complicate the code for no gain,
as has been shown by multiple bugs related to this allocation path.
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/class/cdc-wdm.c')
-rw-r--r-- | drivers/usb/class/cdc-wdm.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 846dfa603447..8909058b1bb1 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -256,14 +256,8 @@ static void free_urbs(struct wdm_device *desc) | |||
256 | 256 | ||
257 | static void cleanup(struct wdm_device *desc) | 257 | static void cleanup(struct wdm_device *desc) |
258 | { | 258 | { |
259 | usb_free_coherent(interface_to_usbdev(desc->intf), | 259 | kfree(desc->sbuf); |
260 | desc->wMaxPacketSize, | 260 | kfree(desc->inbuf); |
261 | desc->sbuf, | ||
262 | desc->validity->transfer_dma); | ||
263 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
264 | desc->bMaxPacketSize0, | ||
265 | desc->inbuf, | ||
266 | desc->response->transfer_dma); | ||
267 | kfree(desc->orq); | 261 | kfree(desc->orq); |
268 | kfree(desc->irq); | 262 | kfree(desc->irq); |
269 | kfree(desc->ubuf); | 263 | kfree(desc->ubuf); |
@@ -688,19 +682,13 @@ next_desc: | |||
688 | if (!desc->ubuf) | 682 | if (!desc->ubuf) |
689 | goto err; | 683 | goto err; |
690 | 684 | ||
691 | desc->sbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 685 | desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL); |
692 | desc->wMaxPacketSize, | ||
693 | GFP_KERNEL, | ||
694 | &desc->validity->transfer_dma); | ||
695 | if (!desc->sbuf) | 686 | if (!desc->sbuf) |
696 | goto err; | 687 | goto err; |
697 | 688 | ||
698 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 689 | desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL); |
699 | desc->wMaxCommand, | ||
700 | GFP_KERNEL, | ||
701 | &desc->response->transfer_dma); | ||
702 | if (!desc->inbuf) | 690 | if (!desc->inbuf) |
703 | goto err2; | 691 | goto err; |
704 | 692 | ||
705 | usb_fill_int_urb( | 693 | usb_fill_int_urb( |
706 | desc->validity, | 694 | desc->validity, |
@@ -712,7 +700,6 @@ next_desc: | |||
712 | desc, | 700 | desc, |
713 | ep->bInterval | 701 | ep->bInterval |
714 | ); | 702 | ); |
715 | desc->validity->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
716 | 703 | ||
717 | desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); | 704 | desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); |
718 | desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | 705 | desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; |
@@ -731,30 +718,22 @@ next_desc: | |||
731 | wdm_in_callback, | 718 | wdm_in_callback, |
732 | desc | 719 | desc |
733 | ); | 720 | ); |
734 | desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
735 | 721 | ||
736 | usb_set_intfdata(intf, desc); | 722 | usb_set_intfdata(intf, desc); |
737 | rv = usb_register_dev(intf, &wdm_class); | 723 | rv = usb_register_dev(intf, &wdm_class); |
738 | if (rv < 0) | 724 | if (rv < 0) |
739 | goto err3; | 725 | goto err2; |
740 | else | 726 | else |
741 | dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n", | 727 | dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n", |
742 | intf->minor - WDM_MINOR_BASE); | 728 | intf->minor - WDM_MINOR_BASE); |
743 | out: | 729 | out: |
744 | return rv; | 730 | return rv; |
745 | err3: | ||
746 | usb_set_intfdata(intf, NULL); | ||
747 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
748 | desc->bMaxPacketSize0, | ||
749 | desc->inbuf, | ||
750 | desc->response->transfer_dma); | ||
751 | err2: | 731 | err2: |
752 | usb_free_coherent(interface_to_usbdev(desc->intf), | 732 | usb_set_intfdata(intf, NULL); |
753 | desc->wMaxPacketSize, | ||
754 | desc->sbuf, | ||
755 | desc->validity->transfer_dma); | ||
756 | err: | 733 | err: |
757 | free_urbs(desc); | 734 | free_urbs(desc); |
735 | kfree(desc->inbuf); | ||
736 | kfree(desc->sbuf); | ||
758 | kfree(desc->ubuf); | 737 | kfree(desc->ubuf); |
759 | kfree(desc->orq); | 738 | kfree(desc->orq); |
760 | kfree(desc->irq); | 739 | kfree(desc->irq); |