aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usbmidi.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-08-15 02:34:16 -0400
committerJaroslav Kysela <perex@suse.cz>2005-08-30 02:45:53 -0400
commit55851f734d7af7e5362d43b60331c95c32a3b027 (patch)
tree6eef6e6915e459f959a596fa37b6c2f87b55f863 /sound/usb/usbmidi.c
parentdaa150ef7d437d17973210f47a1c58623415df94 (diff)
[ALSA] usb-audio: use usb_buffer_alloc/free
USB generic driver Use the USB buffer allocation functions to avoid repeated DMA mappings of our buffers, which are re-used quite a lot. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/usb/usbmidi.c')
-rw-r--r--sound/usb/usbmidi.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 5778a9b725ec..d0d895df5375 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -765,7 +765,10 @@ static snd_rawmidi_ops_t snd_usbmidi_input_ops = {
765static void snd_usbmidi_in_endpoint_delete(snd_usb_midi_in_endpoint_t* ep) 765static void snd_usbmidi_in_endpoint_delete(snd_usb_midi_in_endpoint_t* ep)
766{ 766{
767 if (ep->urb) { 767 if (ep->urb) {
768 kfree(ep->urb->transfer_buffer); 768 usb_buffer_free(ep->umidi->chip->dev,
769 ep->urb->transfer_buffer_length,
770 ep->urb->transfer_buffer,
771 ep->urb->transfer_dma);
769 usb_free_urb(ep->urb); 772 usb_free_urb(ep->urb);
770 } 773 }
771 kfree(ep); 774 kfree(ep);
@@ -799,7 +802,8 @@ static int snd_usbmidi_in_endpoint_create(snd_usb_midi_t* umidi,
799 else 802 else
800 pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep); 803 pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep);
801 length = usb_maxpacket(umidi->chip->dev, pipe, 0); 804 length = usb_maxpacket(umidi->chip->dev, pipe, 0);
802 buffer = kmalloc(length, GFP_KERNEL); 805 buffer = usb_buffer_alloc(umidi->chip->dev, length, GFP_KERNEL,
806 &ep->urb->transfer_dma);
803 if (!buffer) { 807 if (!buffer) {
804 snd_usbmidi_in_endpoint_delete(ep); 808 snd_usbmidi_in_endpoint_delete(ep);
805 return -ENOMEM; 809 return -ENOMEM;
@@ -812,6 +816,7 @@ static int snd_usbmidi_in_endpoint_create(snd_usb_midi_t* umidi,
812 usb_fill_bulk_urb(ep->urb, umidi->chip->dev, pipe, buffer, length, 816 usb_fill_bulk_urb(ep->urb, umidi->chip->dev, pipe, buffer, length,
813 snd_usb_complete_callback(snd_usbmidi_in_urb_complete), 817 snd_usb_complete_callback(snd_usbmidi_in_urb_complete),
814 ep); 818 ep);
819 ep->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
815 820
816 rep->in = ep; 821 rep->in = ep;
817 return 0; 822 return 0;
@@ -835,7 +840,9 @@ static void snd_usbmidi_out_endpoint_delete(snd_usb_midi_out_endpoint_t* ep)
835 if (ep->tasklet.func) 840 if (ep->tasklet.func)
836 tasklet_kill(&ep->tasklet); 841 tasklet_kill(&ep->tasklet);
837 if (ep->urb) { 842 if (ep->urb) {
838 kfree(ep->urb->transfer_buffer); 843 usb_buffer_free(ep->umidi->chip->dev, ep->max_transfer,
844 ep->urb->transfer_buffer,
845 ep->urb->transfer_dma);
839 usb_free_urb(ep->urb); 846 usb_free_urb(ep->urb);
840 } 847 }
841 kfree(ep); 848 kfree(ep);
@@ -867,7 +874,8 @@ static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi,
867 /* we never use interrupt output pipes */ 874 /* we never use interrupt output pipes */
868 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); 875 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep);
869 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); 876 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1);
870 buffer = kmalloc(ep->max_transfer, GFP_KERNEL); 877 buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer,
878 GFP_KERNEL, &ep->urb->transfer_dma);
871 if (!buffer) { 879 if (!buffer) {
872 snd_usbmidi_out_endpoint_delete(ep); 880 snd_usbmidi_out_endpoint_delete(ep);
873 return -ENOMEM; 881 return -ENOMEM;
@@ -875,6 +883,7 @@ static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi,
875 usb_fill_bulk_urb(ep->urb, umidi->chip->dev, pipe, buffer, 883 usb_fill_bulk_urb(ep->urb, umidi->chip->dev, pipe, buffer,
876 ep->max_transfer, 884 ep->max_transfer,
877 snd_usb_complete_callback(snd_usbmidi_out_urb_complete), ep); 885 snd_usb_complete_callback(snd_usbmidi_out_urb_complete), ep);
886 ep->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
878 887
879 spin_lock_init(&ep->buffer_lock); 888 spin_lock_init(&ep->buffer_lock);
880 tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep); 889 tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep);