ChangeSet 1.988, 2003/02/04 11:47:48+11:00, [EMAIL PROTECTED]
[PATCH] USB speedtouch: re-recycle speedtouch receive buffers
Rediffed version of the original patch - no sk_buff on the stack this time.
speedtouch: recycle the receive urb's buffer. Currently, every time a receive urb
completes, its old buffer is thrown away and replaced with a new one. This patch
performs the minor changes needed to reuse the old buffer.
diff -Nru a/drivers/usb/misc/atmsar.c b/drivers/usb/misc/atmsar.c
--- a/drivers/usb/misc/atmsar.c Tue Feb 4 15:16:27 2003
+++ b/drivers/usb/misc/atmsar.c Tue Feb 4 15:16:27 2003
@@ -701,9 +701,8 @@
} else {
/* If data is corrupt and skb doesn't hold a whole cell, flush
the lot */
if (skb_pull (skb, (list->flags & ATMSAR_USE_53BYTE_CELL ? 53
: 52)) ==
- NULL) {
- skb_trim (skb, 0);
- }
+ NULL)
+ return NULL;
}
}
diff -Nru a/drivers/usb/misc/speedtouch.c b/drivers/usb/misc/speedtouch.c
--- a/drivers/usb/misc/speedtouch.c Tue Feb 4 15:16:27 2003
+++ b/drivers/usb/misc/speedtouch.c Tue Feb 4 15:16:27 2003
@@ -348,9 +348,11 @@
struct udsl_instance_data *instance = (struct udsl_instance_data *) data;
struct udsl_data_ctx *ctx;
unsigned long flags;
+ unsigned char *data_start;
+ struct sk_buff *skb;
struct urb *urb;
struct atmsar_vcc_data *atmsar_vcc = NULL;
- struct sk_buff *new = NULL, *skb = NULL, *tmp = NULL;
+ struct sk_buff *new = NULL, *tmp = NULL;
PDEBUG ("udsl_atm_processqueue entered\n");
@@ -369,22 +371,11 @@
/* update the skb structure */
skb = ctx->skb;
+ skb_trim (skb, 0);
skb_put (skb, urb->actual_length);
+ data_start = skb->data;
- /* get a new skb */
- ctx->skb = dev_alloc_skb (UDSL_RECEIVE_BUFFER_SIZE);
- if (!ctx->skb)
- PDEBUG ("No skb, loosing urb.\n");
- else {
- usb_fill_bulk_urb (urb,
- instance->usb_dev,
- usb_rcvbulkpipe (instance->usb_dev,
UDSL_ENDPOINT_DATA_IN),
- (unsigned char *) ctx->skb->data,
- UDSL_RECEIVE_BUFFER_SIZE,
udsl_usb_data_receive, ctx);
- usb_submit_urb (urb, GFP_ATOMIC);
- }
-
- PDEBUG ("skb = %p, skb->len = %d\n", skb, skb->len);
+ PDEBUG ("skb->len = %d\n", skb->len);
PACKETDEBUG (skb->data, skb->len);
while ((new =
@@ -423,8 +414,20 @@
break;
}
}
- dev_kfree_skb (skb);
- default:
+
+ /* restore skb */
+ skb_push (skb, skb->data - data_start);
+
+ usb_fill_bulk_urb (urb,
+ instance->usb_dev,
+ usb_rcvbulkpipe (instance->usb_dev,
+UDSL_ENDPOINT_DATA_IN),
+ (unsigned char *) ctx->skb->data,
+ UDSL_RECEIVE_BUFFER_SIZE,
+udsl_usb_data_receive, ctx);
+ if (!usb_submit_urb (urb, GFP_ATOMIC))
+ break;
+ PDEBUG ("udsl_atm_processqueue: submission failed\n");
+ /* fall through */
+ default: /* error or urb unlinked */
break;
}
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel