Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb allow attachment glue to override the number of ...



details:   https://anonhg.NetBSD.org/src/rev/484d3c3dc0ad
branches:  trunk
changeset: 332265:484d3c3dc0ad
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Sep 13 14:46:50 2014 +0000

description:
allow attachment glue to override the number of endpoints

diffstat:

 sys/dev/usb/motg.c    |  22 +++++++++++++---------
 sys/dev/usb/motgvar.h |   4 ++--
 2 files changed, 15 insertions(+), 11 deletions(-)

diffs (69 lines):

diff -r aff5ab57bb2a -r 484d3c3dc0ad sys/dev/usb/motg.c
--- a/sys/dev/usb/motg.c        Sat Sep 13 13:20:38 2014 +0000
+++ b/sys/dev/usb/motg.c        Sat Sep 13 14:46:50 2014 +0000
@@ -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 @@
 
        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;
diff -r aff5ab57bb2a -r 484d3c3dc0ad sys/dev/usb/motgvar.h
--- a/sys/dev/usb/motgvar.h     Sat Sep 13 13:20:38 2014 +0000
+++ b/sys/dev/usb/motgvar.h     Sat Sep 13 14:46:50 2014 +0000
@@ -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 @@
 #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];
 



Home | Main Index | Thread Index | Old Index