Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Debug



details:   https://anonhg.NetBSD.org/src/rev/b87873fc8e93
branches:  trunk
changeset: 344895:b87873fc8e93
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Apr 26 12:58:48 2016 +0000

description:
Debug

diffstat:

 sys/dev/usb/usb.c |  61 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 21 deletions(-)

diffs (121 lines):

diff -r e6c05823a738 -r b87873fc8e93 sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Tue Apr 26 11:02:57 2016 +0000
+++ b/sys/dev/usb/usb.c Tue Apr 26 12:58:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.162 2016/04/23 10:15:32 skrll Exp $  */
+/*     $NetBSD: usb.c,v 1.163 2016/04/26 12:58:48 skrll Exp $  */
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.162 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.163 2016/04/26 12:58:48 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -697,6 +697,8 @@
        if (sc->sc_dying)
                return EIO;
 
+       int error = 0;
+       DPRINTF("cmd %#x", cmd, 0, 0, 0);
        switch (cmd) {
 #ifdef USB_DEBUG
        case USB_SETDEBUG:
@@ -714,17 +716,22 @@
                void *ptr = 0;
                int addr = ur->ucr_addr;
                usbd_status err;
-               int error = 0;
 
-               if (!(flag & FWRITE))
-                       return EBADF;
+               if (!(flag & FWRITE)) {
+                       error = EBADF;
+                       goto fail;
+               }
 
-               DPRINTF("USB_REQUEST addr=%d len=%d\n", addr, len, 0, 0);
-               if (len < 0 || len > 32768)
-                       return EINVAL;
+               DPRINTF("USB_REQUEST addr=%d len=%d", addr, len, 0, 0);
+               if (len < 0 || len > 32768) {
+                       error = EINVAL;
+                       goto fail;
+               }
                if (addr < 0 || addr >= USB_MAX_DEVICES ||
-                   sc->sc_bus->ub_devices[addr] == NULL)
-                       return EINVAL;
+                   sc->sc_bus->ub_devices[addr] == NULL) {
+                       error = EINVAL;
+                       goto fail;
+               }
                if (len != 0) {
                        iov.iov_base = (void *)ur->ucr_data;
                        iov.iov_len = len;
@@ -764,7 +771,6 @@
                        len = UGETW(ur->ucr_request.wLength);
                        kmem_free(ptr, len);
                }
-               return error;
        }
 
        case USB_DEVICEINFO:
@@ -773,10 +779,14 @@
                struct usb_device_info *di = (void *)data;
                int addr = di->udi_addr;
 
-               if (addr < 0 || addr >= USB_MAX_DEVICES)
-                       return EINVAL;
-               if ((dev = sc->sc_bus->ub_devices[addr]) == NULL)
-                       return ENXIO;
+               if (addr < 0 || addr >= USB_MAX_DEVICES) {
+                       error = EINVAL;
+                       goto fail;
+               }
+               if ((dev = sc->sc_bus->ub_devices[addr]) == NULL) {
+                       error = ENXIO;
+                       goto fail;
+               }
                usbd_fill_deviceinfo(dev, di, 1);
                break;
        }
@@ -788,10 +798,14 @@
                struct usb_device_info_old *di = (void *)data;
                int addr = di->udi_addr;
 
-               if (addr < 1 || addr >= USB_MAX_DEVICES)
-                       return EINVAL;
-               if ((dev = sc->sc_bus->ub_devices[addr]) == NULL)
-                       return ENXIO;
+               if (addr < 1 || addr >= USB_MAX_DEVICES) {
+                       error = EINVAL;
+                       goto fail;
+               }
+               if ((dev = sc->sc_bus->ub_devices[addr]) == NULL) {
+                       error = ENXIO;
+                       goto fail;
+               }
                usbd_fill_deviceinfo_old(dev, di, 1);
                break;
        }
@@ -802,9 +816,14 @@
                break;
 
        default:
-               return EINVAL;
+               error = EINVAL;
        }
-       return 0;
+
+fail:
+
+       DPRINTF("... done (error = %d)", error, 0, 0, 0);
+
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index