[PATCH] v4l: 802: replaced kmalloc kfree with usb buffer alloc usb buffer free to get
authorMarkus Rechberger <mrechberger@gmail.com>
Wed, 9 Nov 2005 05:37:46 +0000 (21:37 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 9 Nov 2005 15:56:21 +0000 (07:56 -0800)
- Replaced kmalloc/kfree with usb_buffer_alloc/usb_buffer_free to get

Signed-off-by: Markus Rechberger <mrechberger@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/media/video/em28xx/em28xx-core.c

index 227a47d6e4bda230921467ac04c19867cd30a1b5..ba2d986c6dfc94fcf968e58baf70fa69be1af57f 100644 (file)
@@ -714,11 +714,12 @@ void em2820_uninit_isoc(struct em2820 *dev)
        for (i = 0; i < EM2820_NUM_BUFS; i++) {
                if (dev->urb[i]) {
                        usb_kill_urb(dev->urb[i]);
+                       if (dev->transfer_buffer[i]){
+                               usb_buffer_free(dev->udev,(EM2820_NUM_PACKETS*dev->max_pkt_size),dev->transfer_buffer[i],dev->urb[i]->transfer_dma);
+                       }
                        usb_free_urb(dev->urb[i]);
                }
                dev->urb[i] = NULL;
-               if (dev->transfer_buffer[i])
-                       kfree(dev->transfer_buffer[i]);
                dev->transfer_buffer[i] = NULL;
        }
        em2820_capture_start(dev, 0);
@@ -743,7 +744,13 @@ int em2820_init_isoc(struct em2820 *dev)
                struct urb *urb;
                int j, k;
                /* allocate transfer buffer */
-               dev->transfer_buffer[i] = kmalloc(sb_size, GFP_KERNEL);
+               urb = usb_alloc_urb(EM2820_NUM_PACKETS, GFP_KERNEL);
+               if (!urb){
+                       em2820_errdev("cannot alloc urb %i\n", i);
+                       em2820_uninit_isoc(dev);
+                       return -ENOMEM;
+               }
+               dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,&urb->transfer_dma);
                if (!dev->transfer_buffer[i]) {
                        em2820_errdev
                                        ("unable to allocate %i bytes for transfer buffer %i\n",
@@ -752,29 +759,22 @@ int em2820_init_isoc(struct em2820 *dev)
                        return -ENOMEM;
                }
                memset(dev->transfer_buffer[i], 0, sb_size);
-               urb = usb_alloc_urb(EM2820_NUM_PACKETS, GFP_KERNEL);
-               if (urb) {
-                       urb->dev = dev->udev;
-                       urb->context = dev;
-                       urb->pipe = usb_rcvisocpipe(dev->udev, 0x82);
-                       urb->transfer_flags = URB_ISO_ASAP;
-                       urb->interval = 1;
-                       urb->transfer_buffer = dev->transfer_buffer[i];
-                       urb->complete = em2820_isocIrq;
-                       urb->number_of_packets = EM2820_NUM_PACKETS;
-                       urb->transfer_buffer_length = sb_size;
-                       for (j = k = 0; j < EM2820_NUM_PACKETS;
-                                                 j++, k += dev->max_pkt_size) {
-                                                         urb->iso_frame_desc[j].offset = k;
-                                                         urb->iso_frame_desc[j].length =
-                                                                         dev->max_pkt_size;
-                                                 }
-                                                 dev->urb[i] = urb;
-               } else {
-                       em2820_errdev("cannot alloc urb %i\n", i);
-                       em2820_uninit_isoc(dev);
-                       return -ENOMEM;
+               urb->dev = dev->udev;
+               urb->context = dev;
+               urb->pipe = usb_rcvisocpipe(dev->udev, 0x82);
+               urb->transfer_flags = URB_ISO_ASAP;
+               urb->interval = 1;
+               urb->transfer_buffer = dev->transfer_buffer[i];
+               urb->complete = em2820_isocIrq;
+               urb->number_of_packets = EM2820_NUM_PACKETS;
+               urb->transfer_buffer_length = sb_size;
+               for (j = k = 0; j < EM2820_NUM_PACKETS;
+                               j++, k += dev->max_pkt_size) {
+                       urb->iso_frame_desc[j].offset = k;
+                       urb->iso_frame_desc[j].length =
+                               dev->max_pkt_size;
                }
+               dev->urb[i] = urb;
        }
 
        /* submit urbs */