Tue Jan 5 18:00:21 2021 UTC ()
More converstion from usbd_status to int for function error reporting.
This time it's the turn of usb_allocmem.


(skrll)
diff -r1.284 -r1.285 src/sys/dev/usb/ehci.c
diff -r1.314 -r1.315 src/sys/dev/usb/ohci.c
diff -r1.305 -r1.306 src/sys/dev/usb/uhci.c
diff -r1.79 -r1.80 src/sys/dev/usb/usb_mem.c
diff -r1.33 -r1.34 src/sys/dev/usb/usb_mem.h
diff -r1.137 -r1.138 src/sys/dev/usb/xhci.c

cvs diff -r1.284 -r1.285 src/sys/dev/usb/ehci.c (expand / switch to context diff)
--- src/sys/dev/usb/ehci.c 2020/12/22 01:07:23 1.284
+++ src/sys/dev/usb/ehci.c 2021/01/05 18:00:21 1.285
@@ -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) {

cvs diff -r1.314 -r1.315 src/sys/dev/usb/ohci.c (expand / switch to context diff)
--- src/sys/dev/usb/ohci.c 2020/12/22 01:07:23 1.314
+++ src/sys/dev/usb/ohci.c 2021/01/05 18:00:21 1.315
@@ -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);

cvs diff -r1.305 -r1.306 src/sys/dev/usb/uhci.c (expand / switch to context diff)
--- src/sys/dev/usb/uhci.c 2020/12/22 01:07:23 1.305
+++ src/sys/dev/usb/uhci.c 2021/01/05 18:00:21 1.306
@@ -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) {

cvs diff -r1.79 -r1.80 src/sys/dev/usb/usb_mem.c (expand / switch to context diff)
--- src/sys/dev/usb/usb_mem.c 2021/01/05 16:15:09 1.79
+++ src/sys/dev/usb/usb_mem.c 2021/01/05 18:00:21 1.80
@@ -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--;
 			*dmap = b;
 			DPRINTFN(6, "free list size=%ju", b->size, 0, 0, 0);
-			return USBD_NORMAL_COMPLETION;
+			return 0;
 		}
 	}
 
@@ -191,7 +191,7 @@
 
 	mutex_enter(&usb_blk_lock);
 
-	return USBD_NORMAL_COMPLETION;
+	return 0;
 
  destroy:
 	bus_dmamap_destroy(tag, b->map);
@@ -255,7 +255,7 @@
 	usb_blk_nfree++;
 }
 
-usbd_status
+int
 usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, u_int flags,
     usb_dma_t *p)
 {
@@ -335,7 +335,7 @@
 	mutex_exit(&usb_blk_lock);
 	DPRINTFN(5, "use frag=%#jx size=%jd", (uintptr_t)f, size, 0, 0);
 
-	return USBD_NORMAL_COMPLETION;
+	return 0;
 }
 
 void

cvs diff -r1.33 -r1.34 src/sys/dev/usb/usb_mem.h (expand / switch to context diff)
--- src/sys/dev/usb/usb_mem.h 2021/01/02 12:39:03 1.33
+++ src/sys/dev/usb/usb_mem.h 2021/01/05 18:00:21 1.34
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_mem.h,v 1.33 2021/01/02 12:39:03 jmcneill Exp $	*/
+/*	$NetBSD: usb_mem.h,v 1.34 2021/01/05 18:00:21 skrll Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -51,7 +51,7 @@
 #define USBMALLOC_COHERENT	__BIT(1)
 #define USBMALLOC_ZERO		__BIT(2)
 
-usbd_status	usb_allocmem(struct usbd_bus *, size_t, size_t, u_int, usb_dma_t *);
+int		usb_allocmem(struct usbd_bus *, size_t, size_t, u_int, usb_dma_t *);
 void		usb_freemem(struct usbd_bus *, usb_dma_t *);
 void		usb_syncmem(usb_dma_t *, bus_addr_t, bus_size_t, int);
 

cvs diff -r1.137 -r1.138 src/sys/dev/usb/xhci.c (expand / switch to context diff)
--- src/sys/dev/usb/xhci.c 2021/01/02 12:39:33 1.137
+++ src/sys/dev/usb/xhci.c 2021/01/05 18:00:21 1.138
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.137 2021/01/02 12:39:33 jmcneill Exp $	*/
+/*	$NetBSD: xhci.c,v 1.138 2021/01/05 18:00:21 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.137 2021/01/02 12:39:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.138 2021/01/05 18:00:21 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1080,8 +1080,7 @@
 	    (uint32_t)sc->sc_maxslots);
 	aprint_debug_dev(sc->sc_dev, "sc_maxports %d\n", sc->sc_maxports);
 
-	usbd_status err;
-
+	int err;
 	sc->sc_maxspbuf = XHCI_HCS2_MAXSPBUF(hcs2);
 	aprint_debug_dev(sc->sc_dev, "sc_maxspbuf %d\n", sc->sc_maxspbuf);
 	if (sc->sc_maxspbuf != 0) {
@@ -2570,7 +2569,6 @@
 xhci_ring_init(struct xhci_softc * const sc, struct xhci_ring **xrp,
     size_t ntrb, size_t align)
 {
-	usbd_status err;
 	size_t size = ntrb * XHCI_TRB_SIZE;
 	struct xhci_ring *xr;
 
@@ -2581,7 +2579,7 @@
 	xr = kmem_zalloc(sizeof(struct xhci_ring), KM_SLEEP);
 	DPRINTFN(1, "ring %#jx", (uintptr_t)xr, 0, 0, 0);
 
-	err = usb_allocmem(&sc->sc_bus, size, align,
+	int err = usb_allocmem(&sc->sc_bus, size, align,
 	    USBMALLOC_COHERENT | USBMALLOC_ZERO, &xr->xr_dma);
 	if (err) {
 		kmem_free(xr, sizeof(struct xhci_ring));
@@ -3012,7 +3010,6 @@
 {
 	struct xhci_softc * const sc = XHCI_BUS2SC(dev->ud_bus);
 	struct xhci_slot *xs;
-	usbd_status err;
 
 	XHCIHIST_FUNC();
 	XHCIHIST_CALLARGS("slot %ju", slot, 0, 0, 0);
@@ -3020,12 +3017,12 @@
 	xs = &sc->sc_slots[slot];
 
 	/* allocate contexts */
-	err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,
+	int err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,
 	    USBMALLOC_COHERENT | USBMALLOC_ZERO, &xs->xs_dc_dma);
 	if (err) {
 		DPRINTFN(1, "failed to allocmem output device context %jd",
 		    err, 0, 0, 0);
-		return err;
+		return USBD_NOMEM;
 	}
 
 	err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,
@@ -3033,7 +3030,7 @@
 	if (err) {
 		DPRINTFN(1, "failed to allocmem input device context %jd",
 		    err, 0, 0, 0);
-		goto bad1;
+		return USBD_NOMEM;
 	}
 
 	memset(&xs->xs_xr[0], 0, sizeof(xs->xs_xr));
@@ -3041,10 +3038,9 @@
 
 	return USBD_NORMAL_COMPLETION;
 
- bad1:
 	usb_freemem(&sc->sc_bus, &xs->xs_dc_dma);
 	xs->xs_idx = 0;
-	return err;
+	return USBD_NOMEM;
 }
 
 static void