Module Name:    src
Committed By:   riastradh
Date:           Thu Mar  3 05:56:58 UTC 2022

Modified Files:
        src/sys/dev/usb: if_urndis.c

Log Message:
urndis(4): Simplify circuitous initialization logic.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/usb/if_urndis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.46 src/sys/dev/usb/if_urndis.c:1.47
--- src/sys/dev/usb/if_urndis.c:1.46	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_urndis.c	Thu Mar  3 05:56:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.46 2022/03/03 05:56:28 riastradh Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.47 2022/03/03 05:56:58 riastradh Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.46 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.47 2022/03/03 05:56:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -72,8 +72,6 @@ static void urndis_uno_rx_loop(struct us
 static unsigned urndis_uno_tx_prepare(struct usbnet *, struct mbuf *,
 				      struct usbnet_chain *);
 
-static int urndis_init_un(struct ifnet *, struct usbnet *);
-
 static uint32_t urndis_ctrl_handle_init(struct usbnet *,
     const struct rndis_comp_hdr *);
 static uint32_t urndis_ctrl_handle_query(struct usbnet *,
@@ -855,28 +853,14 @@ urndis_watchdog(struct ifnet *ifp)
 #endif
 
 static int
-urndis_init_un(struct ifnet *ifp, struct usbnet *un)
-{
-	int 			 err;
-
-	err = urndis_ctrl_init(un);
-	if (err != RNDIS_STATUS_SUCCESS)
-		return EIO;
-
-	return err;
-}
-
-static int
 urndis_uno_init(struct ifnet *ifp)
 {
 	struct usbnet *un = ifp->if_softc;
-	int error;
 
 	KASSERT(IFNET_LOCKED(ifp));
 
-	error = urndis_init_un(ifp, un);
-	if (error)
-		return EIO;	/* XXX */
+	if (urndis_ctrl_init(un) != RNDIS_STATUS_SUCCESS)
+		return EIO;
 
 	return 0;
 }
@@ -1044,8 +1028,11 @@ urndis_attach(device_t parent, device_t 
 
 	usbnet_attach(un);
 
-	struct ifnet *ifp = usbnet_ifp(un);
-	urndis_init_un(ifp, un);
+	if (urndis_ctrl_init(un) != RNDIS_STATUS_SUCCESS) {
+		aprint_error("%s: unable to initialize hardware\n",
+		    DEVNAME(un));
+		return;
+	}
 
 	if (urndis_ctrl_query(un, OID_802_3_PERMANENT_ADDRESS, NULL, 0,
 	    &buf, &bufsz) != RNDIS_STATUS_SUCCESS) {

Reply via email to