Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb General code cleanup.



details:   https://anonhg.NetBSD.org/src/rev/479b48038787
branches:  trunk
changeset: 484057:479b48038787
user:      augustss <augustss%NetBSD.org@localhost>
date:      Fri Mar 24 13:08:28 2000 +0000

description:
General code cleanup.

diffstat:

 sys/dev/usb/if_cue.c |  277 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 183 insertions(+), 94 deletions(-)

diffs (truncated from 693 to 300 lines):

diff -r cb2fb2dbd1bd -r 479b48038787 sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Fri Mar 24 13:03:21 2000 +0000
+++ b/sys/dev/usb/if_cue.c      Fri Mar 24 13:08:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.14 2000/03/23 07:01:45 thorpej Exp $      */
+/*     $NetBSD: if_cue.c,v 1.15 2000/03/24 13:08:28 augustss Exp $     */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 /*
- * CATC USB-EL1201A USB to ethernet driver. Used in the CATC Netmate
+ * CATC USB-EL1210A USB to ethernet driver. Used in the CATC Netmate
  * adapters and others.
  *
  * Written by Bill Paul <wpaul%ee.columbia.edu@localhost>
@@ -43,7 +43,7 @@
  */
 
 /*
- * The CATC USB-EL1201A provides USB ethernet support at 10Mbps. The
+ * The CATC USB-EL1210A provides USB ethernet support at 10Mbps. The
  * RX filter uses a 512-bit multicast hash table, single perfect entry
  * for the station address, and promiscuous mode. Unlike the ADMtek
  * and KLSI chips, the CATC ASIC supports read and write combining
@@ -143,12 +143,15 @@
 static struct cue_type cue_devs[] = {
        { USB_VENDOR_CATC, USB_PRODUCT_CATC_NETMATE },
        { USB_VENDOR_CATC, USB_PRODUCT_CATC_NETMATE2 },
-       /*{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U111 },*/
+       /* Belkin F5U111 adapter covered by NETMATE entry */
        { 0, 0 }
 };
 
 USB_DECLARE_DRIVER(cue);
 
+#define static
+
+static int cue_open_pipes      __P((struct cue_softc *));
 static int cue_tx_list_init    __P((struct cue_softc *));
 static int cue_rx_list_init    __P((struct cue_softc *));
 static int cue_newbuf          __P((struct cue_softc *, struct cue_chain *,
@@ -169,11 +172,11 @@
 static u_int32_t cue_crc       __P((caddr_t));
 static void cue_reset          __P((struct cue_softc *));
 
-static int csr_read_1          __P((struct cue_softc *, int));
-static int csr_write_1         __P((struct cue_softc *, int, int));
-static int csr_read_2          __P((struct cue_softc *, int));
+static int cue_csr_read_1      __P((struct cue_softc *, int));
+static int cue_csr_write_1     __P((struct cue_softc *, int, int));
+static int cue_csr_read_2      __P((struct cue_softc *, int));
 #ifdef notdef
-static int csr_write_2         __P((struct cue_softc *, int, int));
+static int cue_csr_write_2     __P((struct cue_softc *, int, int));
 #endif
 static int cue_mem             __P((struct cue_softc *, int,
                                    int, void *, int));
@@ -186,7 +189,7 @@
 #endif
 
 static void cue_rxstart                __P((struct ifnet *));
-static void cue_shutdown               __P((device_t));
+static void cue_shutdown       __P((device_t));
 
 static struct usb_qdat cue_qdat;
 
@@ -212,16 +215,17 @@
 
 #endif /* defined(__FreeBSD__) */
 
+#define CUE_DO_REQUEST(dev, req, data)                 \
+       usbd_do_request_flags(dev, req, data, USBD_NO_TSLEEP, NULL)
+
 #define CUE_SETBIT(sc, reg, x)                         \
-       csr_write_1(sc, reg, csr_read_1(sc, reg) | (x))
+       cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) | (x))
 
 #define CUE_CLRBIT(sc, reg, x)                         \
-       csr_write_1(sc, reg, csr_read_1(sc, reg) & ~(x))
-
-#define CUE_DO_REQUEST(dev, req, data) usbd_do_request_flags(dev, req, data, USBD_NO_TSLEEP, NULL)
+       cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) & ~(x))
 
 static int
-csr_read_1(sc, reg)
+cue_csr_read_1(sc, reg)
        struct cue_softc        *sc;
        int                     reg;
 {
@@ -230,7 +234,8 @@
        u_int8_t                val = 0;
        int                     s;
 
-       s = splusb();
+       if (sc->cue_dying)
+               return (0);
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
        req.bRequest = CUE_CMD_READREG;
@@ -238,27 +243,34 @@
        USETW(req.wIndex, reg);
        USETW(req.wLength, 1);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, &val);
-
        splx(s);
 
-       if (err)
+       if (err) {
+               DPRINTF(("%s: cue_csr_read_1: reg=0x%x err=%s\n",
+                        USBDEVNAME(sc->cue_dev), reg, usbd_errstr(err)));
                return (0);
+       }
+
+       DPRINTFN(10,("%s: cue_csr_read_1 reg=0x%x val=0x%x\n", 
+                    USBDEVNAME(sc->cue_dev), reg, val));
 
        return (val);
 }
 
 static int
-csr_read_2(sc, reg)
+cue_csr_read_2(sc, reg)
        struct cue_softc        *sc;
        int                     reg;
 {
        usb_device_request_t    req;
        usbd_status             err;
-       u_int16_t               val = 0;
+       uWord                   val;
        int                     s;
 
-       s = splusb();
+       if (sc->cue_dying)
+               return (0);
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
        req.bRequest = CUE_CMD_READREG;
@@ -266,18 +278,24 @@
        USETW(req.wIndex, reg);
        USETW(req.wLength, 2);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, &val);
-
        splx(s);
 
-       if (err)
+       DPRINTFN(10,("%s: cue_csr_read_2 reg=0x%x val=0x%x\n", 
+                    USBDEVNAME(sc->cue_dev), reg, UGETW(val)));
+
+       if (err) {
+               DPRINTF(("%s: cue_csr_read_2: reg=0x%x err=%s\n",
+                        USBDEVNAME(sc->cue_dev), reg, usbd_errstr(err)));
                return (0);
+       }
 
-       return (val);
+       return (UGETW(val));
 }
 
 static int
-csr_write_1(sc, reg, val)
+cue_csr_write_1(sc, reg, val)
        struct cue_softc        *sc;
        int                     reg, val;
 {
@@ -285,7 +303,11 @@
        usbd_status             err;
        int                     s;
 
-       s = splusb();
+       if (sc->cue_dying)
+               return (0);
+
+       DPRINTFN(10,("%s: cue_csr_write_1 reg=0x%x val=0x%x\n", 
+                    USBDEVNAME(sc->cue_dev), reg, val));
 
        req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
        req.bRequest = CUE_CMD_WRITEREG;
@@ -293,40 +315,55 @@
        USETW(req.wIndex, reg);
        USETW(req.wLength, 0);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, NULL);
-
        splx(s);
 
-       if (err)
+       if (err) {
+               DPRINTF(("%s: cue_csr_write_1: reg=0x%x err=%s\n",
+                        USBDEVNAME(sc->cue_dev), reg, usbd_errstr(err)));
                return (-1);
+       }
+
+       DPRINTFN(20,("%s: cue_csr_write_1, after reg=0x%x val=0x%x\n", 
+                    USBDEVNAME(sc->cue_dev), reg, cue_csr_read_1(sc, reg)));
 
        return (0);
 }
 
 #ifdef notdef
 static int
-csr_write_2(sc, reg, val)
+cue_csr_write_2(sc, reg, val)
        struct cue_softc        *sc;
-       int                     reg, val;
+       int                     reg, aval;
 {
        usb_device_request_t    req;
        usbd_status             err;
+       uWord                   val;
        int                     s;
 
-       s = splusb();
+       if (sc->cue_dying)
+               return (0);
 
+       DPRINTFN(10,("%s: cue_csr_write_2 reg=0x%x val=0x%x\n", 
+                    USBDEVNAME(sc->cue_dev), reg, aval));
+
+       USETW(val, aval);
        req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
        req.bRequest = CUE_CMD_WRITEREG;
        USETW(req.wValue, val);
        USETW(req.wIndex, reg);
        USETW(req.wLength, 0);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, NULL);
-
        splx(s);
 
-       if (err)
+       if (err) {
+               DPRINTF(("%s: cue_csr_write_2: reg=0x%x err=%s\n",
+                        USBDEVNAME(sc->cue_dev), reg, usbd_errstr(err)));
                return (-1);
+       }
 
        return (0);
 }
@@ -344,7 +381,8 @@
        usbd_status             err;
        int                     s;
 
-       s = splusb();
+       DPRINTFN(10,("%s: cue_mem cmd=0x%x addr=0x%x len=%d\n",
+                    USBDEVNAME(sc->cue_dev), cmd, addr, len));
 
        if (cmd == CUE_CMD_READSRAM)
                req.bmRequestType = UT_READ_VENDOR_DEVICE;
@@ -355,12 +393,15 @@
        USETW(req.wIndex, addr);
        USETW(req.wLength, len);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, buf);
-
        splx(s);
 
-       if (err)
+       if (err) {
+               DPRINTF(("%s: cue_csr_mem: addr=0x%x err=%s\n",
+                        USBDEVNAME(sc->cue_dev), addr, usbd_errstr(err)));
                return (-1);
+       }
 
        return (0);
 }
@@ -374,7 +415,7 @@
        usbd_status             err;
        int                     s;
 
-       s = splusb();
+       DPRINTFN(10,("%s: cue_getmac\n", USBDEVNAME(sc->cue_dev)));
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
        req.bRequest = CUE_CMD_GET_MACADDR;
@@ -382,8 +423,8 @@
        USETW(req.wIndex, 0);
        USETW(req.wLength, ETHER_ADDR_LEN);
 
+       s = splusb();
        err = CUE_DO_REQUEST(sc->cue_udev, &req, buf);
-
        splx(s);
 
        if (err) {
@@ -419,16 +460,24 @@
        struct cue_softc        *sc;
 {
        struct ifnet            *ifp;
-       //struct ifmultiaddr    *ifma;
-       u_int32_t               h = 0, i;



Home | Main Index | Thread Index | Old Index