summaryrefslogtreecommitdiff
path: root/xpp/xpp_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/xpp_usb.c')
-rw-r--r--xpp/xpp_usb.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/xpp/xpp_usb.c b/xpp/xpp_usb.c
index 8403777..9ad8f27 100644
--- a/xpp/xpp_usb.c
+++ b/xpp/xpp_usb.c
@@ -91,6 +91,7 @@ enum {
XUSB_N_TX_FRAMES,
XUSB_N_RX_ERRORS,
XUSB_N_TX_ERRORS,
+ XUSB_N_RCV_ZERO_LEN,
};
#define XUSB_COUNTER(xusb, counter) ((xusb)->counters[XUSB_N_ ## counter])
@@ -104,6 +105,7 @@ static struct xusb_counters {
C_(TX_FRAMES),
C_(RX_ERRORS),
C_(TX_ERRORS),
+ C_(RCV_ZERO_LEN),
};
#undef C_
@@ -164,7 +166,13 @@ static int xusb_release (struct inode *inode, struct file *file);
static void xusb_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+/*
+ * AsteriskNow kernel has backported the "lean" callback from 2.6.20
+ * to 2.6.19 without any macro to notify of this fact -- how lovely.
+ * Debian-Etch and Centos5 are using 2.6.18 for now (lucky for us).
+ * Fedora6 jumped from 2.6.18 to 2.6.20. So far luck is on our side ;-)
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
#define USB_PASS_CB(u) struct urb *u, struct pt_regs *regs
#else
#define USB_PASS_CB(u) struct urb *u
@@ -281,8 +289,6 @@ static int xusb_xframe_send(xbus_t *xbus, xframe_t *xframe)
ret = -ENODEV;
goto freepack;
}
- if (print_dbg)
- dump_xframe("USB_FRAME_SEND", xbus, xframe);
size = XFRAME_LEN(xframe);
xusb_ep = &xusb->endpoints[XUSB_SEND];
urb = xpp_urb_new(xusb, XUSB_SEND, size);
@@ -306,6 +312,8 @@ static int xusb_xframe_send(xbus_t *xbus, xframe_t *xframe)
ret = -EBADF;
goto freepack;
}
+ if (print_dbg)
+ dump_xframe("USB_FRAME_SEND", xbus, xframe);
do_gettimeofday(&xusb->last_tx);
atomic_inc(&xusb->pending_writes);
freepack:
@@ -807,12 +815,20 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
do_resubmit = 0;
goto end;
}
+ size = urb->actual_length;
+ if(size == 0) {
+ static int rate_limit;
+
+ if((rate_limit++ % 5003) == 0)
+ NOTICE("%s: Received a zero length URBs (%d)\n", xbus->busname, rate_limit);
+ XUSB_COUNTER(xusb, RCV_ZERO_LEN)++;
+ goto end;
+ }
xframe = xbus->ops->xframe_new(xbus, GFP_ATOMIC);
if(!xframe) {
ERR("%s: Not enough memory for packets. Dropping\n", __FUNCTION__);
goto end;
}
- size = urb->actual_length;
atomic_set(&xframe->frame_len, size);
pack = (xpacket_t *)xframe->packets;
memcpy(xframe->packets, urb->transfer_buffer, size);