USB: Add URB_FREE_BUFFER flag and the logic behind it
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 13 Jun 2007 06:02:11 +0000 (08:02 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Jul 2007 23:34:38 +0000 (16:34 -0700)
USB: Add URB_FREE_BUFFER flag for freeing the transfer buffer

In some cases it is not needed that the driver keeps track of the
transfer buffer of an URB. It can be simply freed along with the
URB itself when the reference count goes down to zero. The new
flag URB_FREE_BUFFER enables this behavior.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/urb.c
include/linux/usb.h

index ac4273dddf34a59c0ccb0f7d0a4c62880674978c..52ec44b828f3530dd8dfdb33e8452be6aa2a819f 100644 (file)
@@ -13,6 +13,9 @@ static void urb_destroy(struct kref *kref)
 {
        struct urb *urb = to_urb(kref);
 
+       if (urb->transfer_flags & URB_FREE_BUFFER)
+               kfree(urb->transfer_buffer);
+
        kfree(urb);
 }
 
index efce9a4c511c6bead63767868e919500ea89f6f1..533c32374e01e58e36509a86695608060adf4761 100644 (file)
@@ -994,6 +994,7 @@ extern int usb_disabled(void);
 #define URB_ZERO_PACKET                0x0040  /* Finish bulk OUT with short packet */
 #define URB_NO_INTERRUPT       0x0080  /* HINT: no non-error interrupt
                                         * needed */
+#define URB_FREE_BUFFER                0x0100  /* Free transfer buffer with the URB */
 
 struct usb_iso_packet_descriptor {
        unsigned int offset;