On Thu, Nov 10, 2005 at 08:38:16PM +1100, herbert wrote:
> 
> In fact even now it is possible to get those printks from the resubmit
> function if usb_kill_urb() fails to kill it using unlink.
> 
> I'll send you a patch for that tomorrow.

Here is the patch that I promised:


[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]>


Cheers,
-- 
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)
+               /* fall through */
+       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);
+               /* fall through */
+       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);
 }
 
@@ -720,9 +743,19 @@ static void kaweth_usb_transmit_complete
        struct kaweth_device *kaweth = urb->context;
        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 != 0) {
+       case 0:
+               break;
+       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);

Reply via email to