Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sbus Misc KNF.



details:   https://anonhg.NetBSD.org/src/rev/1ca402216bc3
branches:  trunk
changeset: 747513:1ca402216bc3
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Sep 18 14:35:11 2009 +0000

description:
Misc KNF.

diffstat:

 sys/dev/sbus/be.c |  281 +++++++++++++++++++++++++----------------------------
 1 files changed, 135 insertions(+), 146 deletions(-)

diffs (truncated from 748 to 300 lines):

diff -r a0813fb66c2e -r 1ca402216bc3 sys/dev/sbus/be.c
--- a/sys/dev/sbus/be.c Fri Sep 18 14:14:06 2009 +0000
+++ b/sys/dev/sbus/be.c Fri Sep 18 14:35:11 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: be.c,v 1.72 2009/09/18 14:14:06 tsutsui Exp $  */
+/*     $NetBSD: be.c,v 1.73 2009/09/18 14:35:11 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.72 2009/09/18 14:14:06 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.73 2009/09/18 14:35:11 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -152,7 +152,7 @@
        struct  qec_ring        sc_rb;  /* Packet Ring Buffer */
 
        /* MAC address */
-       u_int8_t sc_enaddr[6];
+       uint8_t sc_enaddr[ETHER_ADDR_LEN];
 #ifdef BEDEBUG
        int     sc_debug;
 #endif
@@ -172,8 +172,8 @@
 static int     beintr(void *);
 static int     berint(struct be_softc *);
 static int     betint(struct be_softc *);
-static int     beqint(struct be_softc *, u_int32_t);
-static int     beeint(struct be_softc *, u_int32_t);
+static int     beqint(struct be_softc *, uint32_t);
+static int     beeint(struct be_softc *, uint32_t);
 
 static void    be_read(struct be_softc *, int, int);
 static int     be_put(struct be_softc *, int, struct mbuf *);
@@ -194,7 +194,7 @@
 
 /* MII helpers */
 static void    be_mii_sync(struct be_softc *);
-static void    be_mii_sendbits(struct be_softc *, int, u_int32_t, int);
+static void    be_mii_sendbits(struct be_softc *, int, uint32_t, int);
 static int     be_mii_reset(struct be_softc *, int);
 static int     be_tcvr_read_bit(struct be_softc *, int);
 static void    be_tcvr_write_bit(struct be_softc *, int, int);
@@ -215,7 +215,7 @@
 {
        struct sbus_attach_args *sa = aux;
 
-       return (strcmp(cf->cf_name, sa->sa_name) == 0);
+       return strcmp(cf->cf_name, sa->sa_name) == 0;
 }
 
 void
@@ -233,7 +233,7 @@
        bus_size_t size;
        int instance;
        int rseg, error;
-       u_int32_t v;
+       uint32_t v;
 
        sc->sc_dev = self;
 
@@ -243,31 +243,25 @@
        }
 
        if (bus_space_map(sa->sa_bustag,
-                         (bus_addr_t)BUS_ADDR(
-                               sa->sa_reg[0].oa_space,
-                               sa->sa_reg[0].oa_base),
-                         (bus_size_t)sa->sa_reg[0].oa_size,
-                         0, &sc->sc_cr) != 0) {
+           (bus_addr_t)BUS_ADDR(sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base),
+           (bus_size_t)sa->sa_reg[0].oa_size,
+           0, &sc->sc_cr) != 0) {
                printf(": cannot map registers\n");
                return;
        }
 
        if (bus_space_map(sa->sa_bustag,
-                         (bus_addr_t)BUS_ADDR(
-                               sa->sa_reg[1].oa_space,
-                               sa->sa_reg[1].oa_base),
-                         (bus_size_t)sa->sa_reg[1].oa_size,
-                         0, &sc->sc_br) != 0) {
+           (bus_addr_t)BUS_ADDR(sa->sa_reg[1].oa_space, sa->sa_reg[1].oa_base),
+           (bus_size_t)sa->sa_reg[1].oa_size,
+           0, &sc->sc_br) != 0) {
                printf(": cannot map registers\n");
                return;
        }
 
        if (bus_space_map(sa->sa_bustag,
-                         (bus_addr_t)BUS_ADDR(
-                               sa->sa_reg[2].oa_space,
-                               sa->sa_reg[2].oa_base),
-                         (bus_size_t)sa->sa_reg[2].oa_size,
-                         0, &sc->sc_tr) != 0) {
+           (bus_addr_t)BUS_ADDR(sa->sa_reg[2].oa_space, sa->sa_reg[2].oa_base),
+           (bus_size_t)sa->sa_reg[2].oa_size,
+           0, &sc->sc_tr) != 0) {
                printf(": cannot map registers\n");
                return;
        }
@@ -295,7 +289,7 @@
        /* Establish interrupt handler */
        if (sa->sa_nintr)
                (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET,
-                                        beintr, sc);
+                   beintr, sc);
 
        prom_getether(node, sc->sc_enaddr);
        printf(" address %s\n", ether_sprintf(sc->sc_enaddr));
@@ -308,42 +302,38 @@
        sc->sc_rb.rb_ntbuf = QEC_XD_RING_MAXSIZE;
        sc->sc_rb.rb_nrbuf = QEC_XD_RING_MAXSIZE;
 
-       size =  QEC_XD_RING_MAXSIZE * sizeof(struct qec_xd) +
-               QEC_XD_RING_MAXSIZE * sizeof(struct qec_xd) +
-               sc->sc_rb.rb_ntbuf * BE_PKT_BUF_SZ +
-               sc->sc_rb.rb_nrbuf * BE_PKT_BUF_SZ;
+       size =
+           QEC_XD_RING_MAXSIZE * sizeof(struct qec_xd) +
+           QEC_XD_RING_MAXSIZE * sizeof(struct qec_xd) +
+           sc->sc_rb.rb_ntbuf * BE_PKT_BUF_SZ +
+           sc->sc_rb.rb_nrbuf * BE_PKT_BUF_SZ;
 
        /* Get a DMA handle */
        if ((error = bus_dmamap_create(dmatag, size, 1, size, 0,
-                                   BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
+           BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
                aprint_error_dev(self, "DMA map create error %d\n", error);
                return;
        }
 
        /* Allocate DMA buffer */
        if ((error = bus_dmamem_alloc(sa->sa_dmatag, size, 0, 0,
-                                     &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
-               aprint_error_dev(self, "DMA buffer alloc error %d\n",
-                       error);
+           &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
+               aprint_error_dev(self, "DMA buffer alloc error %d\n", error);
                return;
        }
 
        /* Map DMA memory in CPU addressable space */
        if ((error = bus_dmamem_map(sa->sa_dmatag, &seg, rseg, size,
-                                   &sc->sc_rb.rb_membase,
-                                   BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
-               aprint_error_dev(self, "DMA buffer map error %d\n",
-                       error);
+           &sc->sc_rb.rb_membase, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+               aprint_error_dev(self, "DMA buffer map error %d\n", error);
                bus_dmamem_free(sa->sa_dmatag, &seg, rseg);
                return;
        }
 
        /* Load the buffer */
        if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap,
-                                    sc->sc_rb.rb_membase, size, NULL,
-                                    BUS_DMA_NOWAIT)) != 0) {
-               aprint_error_dev(self, "DMA buffer map load error %d\n",
-                       error);
+           sc->sc_rb.rb_membase, size, NULL, BUS_DMA_NOWAIT)) != 0) {
+               aprint_error_dev(self, "DMA buffer map load error %d\n", error);
                bus_dmamem_unmap(dmatag, sc->sc_rb.rb_membase, size);
                bus_dmamem_free(dmatag, &seg, rseg);
                return;
@@ -377,10 +367,10 @@
                if (child == NULL) {
                        /* No PHY attached */
                        ifmedia_add(&sc->sc_media,
-                                   IFM_MAKEWORD(IFM_ETHER,IFM_NONE,0,instance),
-                                   0, NULL);
+                           IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, instance),
+                           0, NULL);
                        ifmedia_set(&sc->sc_media,
-                                  IFM_MAKEWORD(IFM_ETHER,IFM_NONE,0,instance));
+                           IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, instance));
                } else {
                        /*
                         * Note: we support just one PHY on the external
@@ -409,7 +399,7 @@
                         * phy indeed has the auto negotiation capability!!
                         */
                        ifmedia_set(&sc->sc_media,
-                                  IFM_MAKEWORD(IFM_ETHER,IFM_AUTO,0,instance));
+                           IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, instance));
 
                        /* Mark our current media setting */
                        be_pal_gate(sc, BE_PHY_EXTERNAL);
@@ -431,27 +421,27 @@
 
                /* Use `ifm_data' to store BMCR bits */
                ifmedia_add(&sc->sc_media,
-                           IFM_MAKEWORD(IFM_ETHER,IFM_10_T,0,instance),
-                           0, NULL);
+                   IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, instance),
+                   0, NULL);
                ifmedia_add(&sc->sc_media,
-                           IFM_MAKEWORD(IFM_ETHER,IFM_100_TX,0,instance),
-                           BMCR_S100, NULL);
+                   IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, instance),
+                   BMCR_S100, NULL);
                ifmedia_add(&sc->sc_media,
-                           IFM_MAKEWORD(IFM_ETHER,IFM_AUTO,0,instance),
-                           0, NULL);
+                   IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, instance),
+                   0, NULL);
 
                printf("on-board transceiver at %s: 10baseT, 100baseTX, auto\n",
-                       device_xname(self));
+                   device_xname(self));
 
                be_mii_reset(sc, BE_PHY_INTERNAL);
                /* Only set default medium here if there's no external PHY */
                if (instance == 0) {
                        be_pal_gate(sc, BE_PHY_INTERNAL);
                        ifmedia_set(&sc->sc_media,
-                                  IFM_MAKEWORD(IFM_ETHER,IFM_AUTO,0,instance));
+                           IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, instance));
                } else
                        be_mii_writereg(self,
-                               BE_PHY_INTERNAL, MII_BMCR, BMCR_ISO);
+                           BE_PHY_INTERNAL, MII_BMCR, BMCR_ISO);
        }
 
        memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
@@ -462,7 +452,7 @@
        ifp->if_init = beinit;
        ifp->if_stop = bestop;
        ifp->if_flags =
-               IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
+           IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
        IFQ_SET_READY(&ifp->if_snd);
 
        /* claim 802.1q capability */
@@ -498,7 +488,7 @@
                tlen += len;
                MFREE(m, n);
        }
-       return (tlen);
+       return tlen;
 }
 
 /*
@@ -552,7 +542,7 @@
                mp = &m->m_next;
        }
 
-       return (top);
+       return top;
 }
 
 /*
@@ -569,7 +559,7 @@
 #ifdef BEDEBUG
                if (sc->sc_debug)
                        printf("%s: invalid packet size %d; dropping\n",
-                               ifp->if_xname, len);
+                           ifp->if_xname, len);
 #endif
                ifp->if_ierrors++;
                return;
@@ -643,9 +633,9 @@
                 * Initialize transmit registers and start transmission
                 */
                txd[bix].xd_flags = QEC_XD_OWN | QEC_XD_SOP | QEC_XD_EOP |
-                                   (len & QEC_XD_LENGTH);
-               bus_space_write_4(sc->sc_bustag, sc->sc_cr, BE_CRI_CTRL,
-                                 BE_CR_CTRL_TWAKEUP);
+                   (len & QEC_XD_LENGTH);
+               bus_space_write_4(sc->sc_bustag, sc->sc_cr,
+                   BE_CRI_CTRL, BE_CR_CTRL_TWAKEUP);
 
                if (++bix == QEC_XD_RING_MAXSIZE)
                        bix = 0;
@@ -729,7 +719,7 @@
 {
        struct be_softc *sc = arg;
        bus_space_tag_t t = sc->sc_bustag;
-       u_int32_t whyq, whyb, whyc;
+       uint32_t whyq, whyb, whyc;
        int r = 0;
 
        /* Read QEC status, channel status and BE status */
@@ -749,14 +739,14 @@
        if (whyq & QEC_STAT_RX && whyc & BE_CR_STAT_RXIRQ)
                r |= berint(sc);
 
-       return (r);
+       return r;
 }
 
 /*
  * QEC Interrupt.
  */
 int



Home | Main Index | Thread Index | Old Index