Thu Mar 3 06:05:38 2022 UTC ()
usb: usbd_abort_pipe never fails.  Make it return void.

Prune dead branches as a result of this change.


(riastradh)
diff -r1.73 -r1.74 src/sys/dev/usb/if_atu.c
diff -r1.13 -r1.14 src/sys/dev/usb/ualea.c
diff -r1.223 -r1.224 src/sys/dev/usb/usbdi.c
diff -r1.104 -r1.105 src/sys/dev/usb/usbdi.h
diff -r1.91 -r1.92 src/sys/dev/usb/usbnet.c
diff -r1.35 -r1.36 src/sys/dev/usb/utoppy.c

cvs diff -r1.73 -r1.74 src/sys/dev/usb/if_atu.c (expand / switch to context diff)
--- src/sys/dev/usb/if_atu.c 2020/08/28 19:02:19 1.73
+++ src/sys/dev/usb/if_atu.c 2022/03/03 06:05:38 1.74
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_atu.c,v 1.73 2020/08/28 19:02:19 riastradh Exp $ */
+/*	$NetBSD: if_atu.c,v 1.74 2022/03/03 06:05:38 riastradh Exp $ */
 /*	$OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
 /*
  * Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.73 2020/08/28 19:02:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.74 2022/03/03 06:05:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2235,19 +2235,11 @@
 
 	/* Stop transfers. */
 	if (sc->atu_ep[ATU_ENDPT_RX] != NULL) {
-		err = usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_RX]);
-		if (err) {
-			DPRINTF(("%s: abort rx pipe failed: %s\n",
-			    device_xname(sc->atu_dev), usbd_errstr(err)));
-		}
+		usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_RX]);
 	}
 
 	if (sc->atu_ep[ATU_ENDPT_TX] != NULL) {
-		err = usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_TX]);
-		if (err) {
-			DPRINTF(("%s: abort tx pipe failed: %s\n",
-			    device_xname(sc->atu_dev), usbd_errstr(err)));
-		}
+		usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_TX]);
 	}
 
 	/* Free RX/TX/MGMT list resources. */

cvs diff -r1.13 -r1.14 src/sys/dev/usb/ualea.c (expand / switch to context diff)
--- src/sys/dev/usb/ualea.c 2021/05/29 08:45:19 1.13
+++ src/sys/dev/usb/ualea.c 2022/03/03 06:05:38 1.14
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.13 2021/05/29 08:45:19 riastradh Exp $	*/
+/*	$NetBSD: ualea.c,v 1.14 2022/03/03 06:05:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.13 2021/05/29 08:45:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.14 2022/03/03 06:05:38 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -161,7 +161,7 @@
 
 	/* Cancel pending xfer.  */
 	if (sc->sc_pipe)
-		(void)usbd_abort_pipe(sc->sc_pipe);
+		usbd_abort_pipe(sc->sc_pipe);
 	KASSERT(!sc->sc_inflight);
 
 	/* All users have drained.  Tear it all down.  */

cvs diff -r1.223 -r1.224 src/sys/dev/usb/usbdi.c (expand / switch to context diff)
--- src/sys/dev/usb/usbdi.c 2022/03/03 06:04:31 1.223
+++ src/sys/dev/usb/usbdi.c 2022/03/03 06:05:38 1.224
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.223 2022/03/03 06:04:31 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.224 2022/03/03 06:05:38 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.223 2022/03/03 06:04:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.224 2022/03/03 06:05:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -113,7 +113,7 @@
     "usbd_status"/*status*/);
 SDT_PROBE_DEFINE1(usb, device, xfer, destroy,  "struct usbd_xfer *"/*xfer*/);
 
-Static usbd_status usbd_ar_pipe(struct usbd_pipe *);
+Static void usbd_ar_pipe(struct usbd_pipe *);
 static usbd_status usb_insert_transfer(struct usbd_xfer *);
 Static void usbd_start_next(struct usbd_pipe *);
 Static usbd_status usbd_open_pipe_ival
@@ -769,23 +769,21 @@
 
 /* Some drivers may wish to abort requests on the default pipe, *
  * but there is no mechanism for getting a handle on it.        */
-usbd_status
+void
 usbd_abort_default_pipe(struct usbd_device *device)
 {
-	return usbd_abort_pipe(device->ud_pipe0);
+	usbd_abort_pipe(device->ud_pipe0);
 }
 
-usbd_status
+void
 usbd_abort_pipe(struct usbd_pipe *pipe)
 {
-	usbd_status err;
 
 	KASSERT(pipe != NULL);
 
 	usbd_lock_pipe(pipe);
-	err = usbd_ar_pipe(pipe);
+	usbd_ar_pipe(pipe);
 	usbd_unlock_pipe(pipe);
-	return err;
 }
 
 usbd_status
@@ -966,7 +964,7 @@
 /*** Internal routines ***/
 
 /* Dequeue all pipe operations, called with bus lock held. */
-Static usbd_status
+Static void
 usbd_ar_pipe(struct usbd_pipe *pipe)
 {
 	struct usbd_xfer *xfer;
@@ -1010,7 +1008,6 @@
 	}
 	pipe->up_aborting = 0;
 	SDT_PROBE1(usb, device, pipe, abort__done,  pipe);
-	return USBD_NORMAL_COMPLETION;
 }
 
 /* Called with USB lock held. */

cvs diff -r1.104 -r1.105 src/sys/dev/usb/usbdi.h (expand / switch to context diff)
--- src/sys/dev/usb/usbdi.h 2022/02/14 09:22:30 1.104
+++ src/sys/dev/usb/usbdi.h 2022/03/03 06:05:38 1.105
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.h,v 1.104 2022/02/14 09:22:30 riastradh Exp $	*/
+/*	$NetBSD: usbdi.h,v 1.105 2022/03/03 06:05:38 riastradh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -122,8 +122,8 @@
 usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor
     (struct usbd_interface *, uint8_t);
 
-usbd_status usbd_abort_pipe(struct usbd_pipe *);
-usbd_status usbd_abort_default_pipe(struct usbd_device *);
+void usbd_abort_pipe(struct usbd_pipe *);
+void usbd_abort_default_pipe(struct usbd_device *);
 
 usbd_status usbd_clear_endpoint_stall(struct usbd_pipe *);
 void usbd_clear_endpoint_stall_async(struct usbd_pipe *);

cvs diff -r1.91 -r1.92 src/sys/dev/usb/usbnet.c (expand / switch to context diff)
--- src/sys/dev/usb/usbnet.c 2022/03/03 05:56:44 1.91
+++ src/sys/dev/usb/usbnet.c 2022/03/03 06:05:38 1.92
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.91 2022/03/03 05:56:44 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.92 2022/03/03 06:05:38 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.91 2022/03/03 05:56:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.92 2022/03/03 06:05:38 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -817,21 +817,16 @@
 	return USBD_NORMAL_COMPLETION;
 }
 
-static usbd_status
+static void
 usbnet_ep_stop_pipes(struct usbnet * const un)
 {
 	struct usbnet_private * const unp = un->un_pri;
-	usbd_status err = USBD_NORMAL_COMPLETION;
 
 	for (size_t i = 0; i < __arraycount(unp->unp_ep); i++) {
 		if (unp->unp_ep[i] == NULL)
 			continue;
-		usbd_status err2 = usbd_abort_pipe(unp->unp_ep[i]);
-		if (err == USBD_NORMAL_COMPLETION && err2)
-			err = err2;
+		usbd_abort_pipe(unp->unp_ep[i]);
 	}
-
-	return err;
 }
 
 static int
@@ -1208,17 +1203,13 @@
 	struct usbnet * const un = ifp->if_softc;
 	struct usbnet_private * const unp = un->un_pri;
 	struct usbnet_cdata * const cd = un_cdata(un);
-	usbd_status err;
 
 	if_statinc(ifp, if_oerrors);
 	device_printf(un->un_dev, "watchdog timeout\n");
 
 	if (cd->uncd_tx_cnt > 0) {
 		DPRINTF("uncd_tx_cnt=%ju non zero, aborting pipe", 0, 0, 0, 0);
-		err = usbd_abort_pipe(unp->unp_ep[USBNET_ENDPT_TX]);
-		if (err)
-			device_printf(un->un_dev, "pipe abort failed: %s\n",
-			    usbd_errstr(err));
+		usbd_abort_pipe(unp->unp_ep[USBNET_ENDPT_TX]);
 		if (cd->uncd_tx_cnt != 0)
 			DPRINTF("uncd_tx_cnt now %ju", cd->uncd_tx_cnt, 0, 0, 0);
 	}

cvs diff -r1.35 -r1.36 src/sys/dev/usb/utoppy.c (expand / switch to context diff)
--- src/sys/dev/usb/utoppy.c 2020/03/14 02:35:34 1.35
+++ src/sys/dev/usb/utoppy.c 2022/03/03 06:05:38 1.36
@@ -1,4 +1,4 @@
-/*	$NetBSD: utoppy.c,v 1.35 2020/03/14 02:35:34 christos Exp $	*/
+/*	$NetBSD: utoppy.c,v 1.36 2022/03/03 06:05:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: utoppy.c,v 1.35 2020/03/14 02:35:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: utoppy.c,v 1.36 2022/03/03 06:05:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1365,7 +1365,6 @@
 utoppyclose(dev_t dev, int flag, int mode, struct lwp *l)
 {
 	struct utoppy_softc *sc;
-	usbd_status err;
 
 	sc = device_lookup_private(&utoppy_cd, UTOPPYUNIT(dev));
 
@@ -1384,14 +1383,12 @@
 		(void) utoppy_cancel(sc);
 
 	if (sc->sc_out_pipe != NULL) {
-		if ((err = usbd_abort_pipe(sc->sc_out_pipe)) != 0)
-			printf("usbd_abort_pipe(OUT) returned %d\n", err);
+		usbd_abort_pipe(sc->sc_out_pipe);
 		sc->sc_out_pipe = NULL;
 	}
 
 	if (sc->sc_in_pipe != NULL) {
-		if ((err = usbd_abort_pipe(sc->sc_in_pipe)) != 0)
-			printf("usbd_abort_pipe(IN) returned %d\n", err);
+		usbd_abort_pipe(sc->sc_in_pipe);
 		sc->sc_in_pipe = NULL;
 	}