Module Name:    src
Committed By:   jmcneill
Date:           Sat Sep 13 14:46:50 UTC 2014

Modified Files:
        src/sys/dev/usb: motg.c motgvar.h

Log Message:
allow attachment glue to override the number of endpoints


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/motgvar.h

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/motg.c
diff -u src/sys/dev/usb/motg.c:1.8 src/sys/dev/usb/motg.c:1.9
--- src/sys/dev/usb/motg.c:1.8	Tue Aug 12 08:06:46 2014
+++ src/sys/dev/usb/motg.c	Sat Sep 13 14:46:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.8 2014/08/12 08:06:46 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.9 2014/09/13 14:46:50 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.8 2014/08/12 08:06:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.9 2014/09/13 14:46:50 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -296,16 +296,20 @@ motg_init(struct motg_softc *sc)
 
 	UWRITE1(sc, MUSB2_REG_EPINDEX, 0);
 
-	/* read out number of endpoints */
-	nrx = (UREAD1(sc, MUSB2_REG_EPINFO) / 16);
+	if (sc->sc_ep_max == 0) {
+		/* read out number of endpoints */
+		nrx = (UREAD1(sc, MUSB2_REG_EPINFO) / 16);
 
-	ntx = (UREAD1(sc, MUSB2_REG_EPINFO) % 16);
+		ntx = (UREAD1(sc, MUSB2_REG_EPINFO) % 16);
 
-	/* these numbers exclude the control endpoint */
+		/* these numbers exclude the control endpoint */
 
-	DPRINTF(("RX/TX endpoints: %u/%u\n", nrx, ntx));
+		DPRINTF(("RX/TX endpoints: %u/%u\n", nrx, ntx));
 
-	sc->sc_ep_max = MAX(nrx, ntx);
+		sc->sc_ep_max = MAX(nrx, ntx);
+	} else {
+		nrx = ntx = sc->sc_ep_max;
+	}
 	if (sc->sc_ep_max == 0) {
 		aprint_error_dev(sc->sc_dev, " no endpoints\n");
 		return USBD_INVAL;

Index: src/sys/dev/usb/motgvar.h
diff -u src/sys/dev/usb/motgvar.h:1.2 src/sys/dev/usb/motgvar.h:1.3
--- src/sys/dev/usb/motgvar.h:1.2	Thu Jul 17 19:58:18 2014
+++ src/sys/dev/usb/motgvar.h	Sat Sep 13 14:46:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: motgvar.h,v 1.2 2014/07/17 19:58:18 bouyer Exp $	*/
+/*	$NetBSD: motgvar.h,v 1.3 2014/09/13 14:46:50 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -75,12 +75,12 @@ struct motg_softc {
 #define MOTG_MODE_DEVICE 1
 	void (*sc_intr_poll)(void *);
 	void *sc_intr_poll_arg;
+	int sc_ep_max;
 
 	uint16_t sc_intr_tx_ep;
 	uint16_t sc_intr_rx_ep;
 	uint8_t  sc_intr_ctrl;
 
-	int sc_ep_max;
 	struct motg_hw_ep sc_in_ep[MOTG_MAX_HW_EP];
 	struct motg_hw_ep sc_out_ep[MOTG_MAX_HW_EP];
 

Reply via email to