On Fri, Nov 11, 2005 at 11:46:12AM +0100, Oliver Neukum wrote:
>
> + switch (urb->status != 0) {
>
> 1. This is surely not what is intended.
Good catch.
> 2. Would you please leave in unlikely in interrupt handlers.
> 3. -ENOMEM with GFP_KERNEL is not something to write a log entry about.
OK, I've made the changes that you suggested.
[KAWETH] Suppress errors when URB is unlinked
When an URB is unlinked the completion function will be called with
a non-zero status value. Since we can recognise those specific values
we shouldn't print an error message when we detect them.
Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -485,17 +485,21 @@ static void kaweth_resubmit_int_urb(stru
int status;
status = usb_submit_urb (kaweth->irq_urb, mf);
- if (unlikely(status == -ENOMEM)) {
+ kaweth->suspend_lowmem_ctrl = 0;
+ switch (status) {
+ case -ENOMEM:
kaweth->suspend_lowmem_ctrl = 1;
schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
- } else {
- kaweth->suspend_lowmem_ctrl = 0;
- }
-
- if (status)
+ break;
+ default:
err ("can't resubmit intr, %s-%s, status %d",
kaweth->dev->bus->bus_name,
kaweth->dev->devpath, status);
+ break;
+ case -EPERM:
+ case 0:
+ break;
+ }
}
static void int_callback(struct urb *u, struct pt_regs *regs)
@@ -561,13 +565,19 @@ static int kaweth_resubmit_rx_urb(struct
kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle;
- if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) {
- if (result == -ENOMEM) {
- kaweth->suspend_lowmem_rx = 1;
- schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
- }
+ result = usb_submit_urb(kaweth->rx_urb, mem_flags);
+ switch (result) {
+ case -ENOMEM:
+ kaweth->suspend_lowmem_rx = 1;
+ schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
+ break;
+ default:
kaweth_err("resubmitting rx_urb %d failed", result);
- } else {
+ break;
+ case -EPERM:
+ /* URB blocked by usb_kill_urb(). */
+ break;
+ case 0:
kaweth->suspend_lowmem_rx = 0;
}
@@ -594,14 +604,26 @@ static void kaweth_usb_receive(struct ur
if (kaweth->status & KAWETH_STATUS_CLOSING)
return;
- if(urb->status && urb->status != -EREMOTEIO && count != 1) {
+ switch (urb->status) {
+ case 0:
+ break;
+ case -ENOENT:
+ case -ECONNRESET:
+ case -ESHUTDOWN:
+ kaweth_dbg("%s: RX unlinked, status: %d", net->name,
+ urb->status);
+ return;
+ default:
+ /* What's this check for? */
+ if (count == 1)
+ goto resubmit;
+
kaweth_err("%s RX status: %d count: %d packet_len: %d",
net->name,
urb->status,
count,
(int)pkt_len);
- kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
- return;
+ goto resubmit;
}
if(kaweth->net && (count > 2)) {
@@ -634,6 +656,7 @@ static void kaweth_usb_receive(struct ur
kaweth->stats.rx_bytes += pkt_len;
}
+resubmit:
kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
}
@@ -721,8 +744,18 @@ static void kaweth_usb_transmit_complete
struct sk_buff *skb = kaweth->tx_skb;
if (unlikely(urb->status != 0))
- if (urb->status != -ENOENT)
- kaweth_dbg("%s: TX status %d.", kaweth->net->name,
urb->status);
+ switch (urb->status) {
+ case -ENOENT:
+ case -ECONNRESET:
+ case -ESHUTDOWN:
+ kaweth_dbg("%s: TX unlinked, status %d",
+ kaweth->net->name, urb->status);
+ break;
+ default:
+ kaweth_err("%s: TX status %d",
+ kaweth->net->name, urb->status);
+ break;
+ }
netif_wake_queue(kaweth->net);
dev_kfree_skb_irq(skb);