Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb More converstion from usbd_status to int for fun...



details:   https://anonhg.NetBSD.org/src/rev/0ad5101ff44b
branches:  trunk
changeset: 949222:0ad5101ff44b
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Jan 05 18:00:21 2021 +0000

description:
More converstion from usbd_status to int for function error reporting.
This time it's the turn of usb_allocmem.

diffstat:

 sys/dev/usb/ehci.c    |  19 ++++++++-----------
 sys/dev/usb/ohci.c    |  25 +++++++++++--------------
 sys/dev/usb/uhci.c    |  16 ++++++----------
 sys/dev/usb/usb_mem.c |  20 ++++++++++----------
 sys/dev/usb/usb_mem.h |   4 ++--
 sys/dev/usb/xhci.c    |  20 ++++++++------------
 6 files changed, 45 insertions(+), 59 deletions(-)

diffs (truncated from 441 to 300 lines):

diff -r 8e20f833030d -r 0ad5101ff44b sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Tue Jan 05 17:37:57 2021 +0000
+++ b/sys/dev/usb/ehci.c        Tue Jan 05 18:00:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.284 2020/12/22 01:07:23 riastradh Exp $ */
+/*     $NetBSD: ehci.c,v 1.285 2021/01/05 18:00:21 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.284 2020/12/22 01:07:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.285 2021/01/05 18:00:21 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2845,7 +2845,6 @@
 ehci_alloc_sqtd(ehci_softc_t *sc)
 {
        ehci_soft_qtd_t *sqtd = NULL;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -2856,8 +2855,10 @@
                DPRINTF("allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK,
-                   EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
+               int err = usb_allocmem(&sc->sc_bus,
+                   EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK,
+                   EHCI_PAGE_SIZE, USBMALLOC_COHERENT,
+                   &dma);
 #ifdef EHCI_DEBUG
                if (err)
                        printf("ehci_alloc_sqtd: usb_allocmem()=%d\n", err);
@@ -3102,7 +3103,6 @@
 ehci_alloc_itd(ehci_softc_t *sc)
 {
        struct ehci_soft_itd *itd, *freeitd;
-       usbd_status err;
        usb_dma_t dma;
 
        EHCIHIST_FUNC(); EHCIHIST_CALLED();
@@ -3113,8 +3113,7 @@
        if (freeitd == NULL) {
                DPRINTF("allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
-
-               err = usb_allocmem(&sc->sc_bus, EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
+               int err = usb_allocmem(&sc->sc_bus, EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
                if (err) {
@@ -3151,7 +3150,6 @@
 ehci_alloc_sitd(ehci_softc_t *sc)
 {
        struct ehci_soft_sitd *sitd, *freesitd;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -3162,8 +3160,7 @@
        if (freesitd == NULL) {
                DPRINTF("allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
-
-               err = usb_allocmem(&sc->sc_bus, EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
+               int err = usb_allocmem(&sc->sc_bus, EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
                if (err) {
diff -r 8e20f833030d -r 0ad5101ff44b sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Tue Jan 05 17:37:57 2021 +0000
+++ b/sys/dev/usb/ohci.c        Tue Jan 05 18:00:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.314 2020/12/22 01:07:23 riastradh Exp $     */
+/*     $NetBSD: ohci.c,v 1.315 2021/01/05 18:00:21 skrll Exp $ */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.314 2020/12/22 01:07:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.315 2021/01/05 18:00:21 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -399,7 +399,6 @@
 ohci_alloc_sed(ohci_softc_t *sc)
 {
        ohci_soft_ed_t *sed;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -410,8 +409,8 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
-                   OHCI_ED_ALIGN, USBMALLOC_COHERENT, &dma);
+               int err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
+                   OHCI_ED_ALIGN, 0 /*!USBMALLOC_COHERENT*/, &dma);
                if (err)
                        return NULL;
 
@@ -458,7 +457,6 @@
 ohci_alloc_std(ohci_softc_t *sc)
 {
        ohci_soft_td_t *std;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -469,8 +467,8 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
-                   OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
+               int err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
+                  OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
 
@@ -711,7 +709,6 @@
 ohci_alloc_sitd(ohci_softc_t *sc)
 {
        ohci_soft_itd_t *sitd;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -722,7 +719,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK,
+               int err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK,
                    OHCI_ITD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -829,8 +826,8 @@
 
        /* XXX determine alignment by R/W */
        /* Allocate the HCCA area. */
-       err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE,
-           OHCI_HCCA_ALIGN, USBMALLOC_COHERENT, &sc->sc_hccadma);
+       err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE, OHCI_HCCA_ALIGN,
+           USBMALLOC_COHERENT, &sc->sc_hccadma);
        if (err) {
                sc->sc_hcca = NULL;
                return err;
@@ -2143,10 +2140,10 @@
                switch (xfertype) {
                case UE_CONTROL:
                        pipe->up_methods = &ohci_device_ctrl_methods;
-                       err = usb_allocmem(&sc->sc_bus,
+                       int error = usb_allocmem(&sc->sc_bus,
                            sizeof(usb_device_request_t), 0,
                            USBMALLOC_COHERENT, &opipe->ctrl.reqdma);
-                       if (err)
+                       if (error)
                                goto bad;
                        mutex_enter(&sc->sc_lock);
                        ohci_add_ed(sc, sed, sc->sc_ctrl_head);
diff -r 8e20f833030d -r 0ad5101ff44b sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Tue Jan 05 17:37:57 2021 +0000
+++ b/sys/dev/usb/uhci.c        Tue Jan 05 18:00:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.305 2020/12/22 01:07:23 riastradh Exp $     */
+/*     $NetBSD: uhci.c,v 1.306 2021/01/05 18:00:21 skrll Exp $ */
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.305 2020/12/22 01:07:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.306 2021/01/05 18:00:21 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -433,7 +433,6 @@
 int
 uhci_init(uhci_softc_t *sc)
 {
-       usbd_status err;
        int i, j;
        uhci_soft_qh_t *clsqh, *chsqh, *bsqh, *sqh, *lsqh;
        uhci_soft_td_t *std;
@@ -454,7 +453,7 @@
        uhci_reset(sc);
 
        /* Allocate and initialize real frame array. */
-       err = usb_allocmem(&sc->sc_bus,
+       int err = usb_allocmem(&sc->sc_bus,
            UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t),
            UHCI_FRAMELIST_ALIGN, USBMALLOC_COHERENT, &sc->sc_dma);
        if (err)
@@ -1835,7 +1834,6 @@
 uhci_alloc_std(uhci_softc_t *sc)
 {
        uhci_soft_td_t *std;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -1846,7 +1844,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK,
+               int err = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK,
                    UHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -1902,7 +1900,6 @@
 uhci_alloc_sqh(uhci_softc_t *sc)
 {
        uhci_soft_qh_t *sqh;
-       usbd_status err;
        int i, offs;
        usb_dma_t dma;
 
@@ -1913,7 +1910,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               err = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
+               int err = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
                    UHCI_QH_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -3465,7 +3462,6 @@
        struct usbd_bus *bus = pipe->up_dev->ud_bus;
        struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(pipe);
        usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
-       usbd_status err = USBD_NOMEM;
        int ival;
 
        UHCIHIST_FUNC(); UHCIHIST_CALLED();
@@ -3509,7 +3505,7 @@
                                uhci_free_std(sc, upipe->ctrl.setup);
                                goto bad;
                        }
-                       err = usb_allocmem(&sc->sc_bus,
+                       int err = usb_allocmem(&sc->sc_bus,
                            sizeof(usb_device_request_t), 0,
                            USBMALLOC_COHERENT, &upipe->ctrl.reqdma);
                        if (err) {
diff -r 8e20f833030d -r 0ad5101ff44b sys/dev/usb/usb_mem.c
--- a/sys/dev/usb/usb_mem.c     Tue Jan 05 17:37:57 2021 +0000
+++ b/sys/dev/usb/usb_mem.c     Tue Jan 05 18:00:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.c,v 1.79 2021/01/05 16:15:09 skrll Exp $       */
+/*     $NetBSD: usb_mem.c,v 1.80 2021/01/05 18:00:21 skrll Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.79 2021/01/05 16:15:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.80 2021/01/05 18:00:21 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -74,9 +74,9 @@
        LIST_ENTRY(usb_frag_dma) ufd_next;
 };
 
-Static usbd_status     usb_block_allocmem(bus_dma_tag_t, size_t, size_t,
-                           u_int, usb_dma_block_t **);
-Static void            usb_block_freemem(usb_dma_block_t *);
+Static int     usb_block_allocmem(bus_dma_tag_t, size_t, size_t,
+                   u_int, usb_dma_block_t **);
+Static void    usb_block_freemem(usb_dma_block_t *);
 
 LIST_HEAD(usb_dma_block_qh, usb_dma_block);
 Static struct usb_dma_block_qh usb_blk_freelist =
@@ -104,7 +104,7 @@
        return 0;
 }
 
-Static usbd_status
+Static int
 usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
     u_int flags, usb_dma_block_t **dmap)
 {
@@ -135,7 +135,7 @@
                        usb_blk_nfree--;



Home | Main Index | Thread Index | Old Index