[PATCH] Add URB_FREE_BUFFER flag

Marcel Holtmann <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Hi Greg,

here is the patch to add the URB_FREE_BUFFER flag for freeing the
transfer buffer together with the URB itself. Please apply.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
patch-add-urb-free-buffer-option (text/plain, 1.6 KB)
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 <[email protected]>

---
commit f4ff5d567226679db52ddfa87b4fac9b8b81b5fd
tree 78eca1748e58ea5fc587396dfbcd65858655aca8
parent dd14cbc994709a1c5a64ed3621f583c49a27e521
author Marcel Holtmann <[email protected]> Wed, 13 Jun 2007 07:00:43 +0200
committer Marcel Holtmann <[email protected]> Wed, 13 Jun 2007 07:00:43 +0200

 drivers/usb/core/urb.c |    4 ++++
 include/linux/usb.h    |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 94ea972..0601665 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -11,6 +11,10 @@
 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);
 }
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 94bd38a..e751593 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -948,6 +948,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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.