Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic KNF, misc cosmetics.



details:   https://anonhg.NetBSD.org/src/rev/ec29a6e611b8
branches:  trunk
changeset: 752469:ec29a6e611b8
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Feb 27 05:41:22 2010 +0000

description:
KNF, misc cosmetics.

diffstat:

 sys/dev/ic/dp8390.c |  174 +++++++++++++++++++++++++--------------------------
 1 files changed, 85 insertions(+), 89 deletions(-)

diffs (truncated from 568 to 300 lines):

diff -r d4c1f4b8e407 -r ec29a6e611b8 sys/dev/ic/dp8390.c
--- a/sys/dev/ic/dp8390.c       Sat Feb 27 04:40:11 2010 +0000
+++ b/sys/dev/ic/dp8390.c       Sat Feb 27 05:41:22 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390.c,v 1.76 2010/02/27 04:40:11 tsutsui Exp $      */
+/*     $NetBSD: dp8390.c,v 1.77 2010/02/27 05:41:22 tsutsui Exp $      */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.76 2010/02/27 04:40:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.77 2010/02/27 05:41:22 tsutsui Exp $");
 
 #include "opt_ipkdb.h"
 #include "opt_inet.h"
@@ -64,16 +64,13 @@
 int    dp8390_debug = 0;
 #endif
 
-static void            dp8390_xmit(struct dp8390_softc *);
+static void dp8390_xmit(struct dp8390_softc *);
 
-static void            dp8390_read_hdr(struct dp8390_softc *,
-                           int, struct dp8390_ring *);
-static int             dp8390_ring_copy(struct dp8390_softc *,
-                           int, void *, u_short);
-static int             dp8390_write_mbuf(struct dp8390_softc *,
-                           struct mbuf *, int);
+static void dp8390_read_hdr(struct dp8390_softc *, int, struct dp8390_ring *);
+static int  dp8390_ring_copy(struct dp8390_softc *, int, void *, u_short);
+static int  dp8390_write_mbuf(struct dp8390_softc *, struct mbuf *, int);
 
-static int             dp8390_test_mem(struct dp8390_softc *);
+static int  dp8390_test_mem(struct dp8390_softc *);
 
 /*
  * Standard media init routine for the dp8390.
@@ -137,7 +134,7 @@
        ifp->if_softc = sc;
        ifp->if_start = dp8390_start;
        ifp->if_ioctl = dp8390_ioctl;
-       if (!ifp->if_watchdog)
+       if (ifp->if_watchdog == NULL)
                ifp->if_watchdog = dp8390_watchdog;
        ifp->if_flags =
            IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
@@ -168,8 +165,8 @@
        sc->sc_flags |= DP8390_ATTACHED;
 
        rv = 0;
-out:
-       return (rv);
+ out:
+       return rv;
 }
 
 /*
@@ -181,8 +178,8 @@
        struct dp8390_softc *sc = ifp->if_softc;
 
        if (sc->sc_mediachange)
-               return ((*sc->sc_mediachange)(sc));
-       return (0);
+               return (*sc->sc_mediachange)(sc);
+       return 0;
 }
 
 /*
@@ -209,7 +206,7 @@
 void
 dp8390_reset(struct dp8390_softc *sc)
 {
-       int     s;
+       int s;
 
        s = splnet();
        dp8390_stop(sc);
@@ -238,8 +235,7 @@
         * 'n' (about 5ms).  It shouldn't even take 5us on modern DS8390's, but
         * just in case it's an old one.
         */
-       while (((NIC_GET(regt, regh,
-           ED_P0_ISR) & ED_ISR_RST) == 0) && --n)
+       while (((NIC_GET(regt, regh, ED_P0_ISR) & ED_ISR_RST) == 0) && --n)
                DELAY(1);
 
        if (sc->stop_card != NULL)
@@ -271,7 +267,7 @@
        bus_space_tag_t regt = sc->sc_regt;
        bus_space_handle_t regh = sc->sc_regh;
        struct ifnet *ifp = &sc->sc_ec.ec_if;
-       u_int8_t mcaf[8];
+       uint8_t mcaf[8];
        int i;
 
        /*
@@ -345,9 +341,8 @@
        NIC_BARRIER(regt, regh);
 
        /* Copy out our station address. */
-       for (i = 0; i < ETHER_ADDR_LEN; ++i)
-               NIC_PUT(regt, regh, ED_P1_PAR0 + i,
-                   CLLADDR(ifp->if_sadl)[i]);
+       for (i = 0; i < ETHER_ADDR_LEN; i++)
+               NIC_PUT(regt, regh, ED_P1_PAR0 + i, CLLADDR(ifp->if_sadl)[i]);
 
        /* Set multicast filter on chip. */
        dp8390_getmcaf(&sc->sc_ec, mcaf);
@@ -382,7 +377,7 @@
        NIC_PUT(regt, regh, ED_P0_TCR, 0);
 
        /* Do any card-specific initialization, if applicable. */
-       if (sc->init_card)
+       if (sc->init_card != NULL)
                (*sc->init_card)(sc);
 
        /* Fire up the interface. */
@@ -427,8 +422,8 @@
        NIC_BARRIER(regt, regh);
 
        /* Set TX buffer start page. */
-       NIC_PUT(regt, regh, ED_P0_TPSR, sc->tx_page_start +
-           sc->txb_next_tx * ED_TXBUF_SIZE);
+       NIC_PUT(regt, regh, ED_P0_TPSR,
+           sc->tx_page_start + sc->txb_next_tx * ED_TXBUF_SIZE);
 
        /* Set TX length. */
        NIC_PUT(regt, regh, ED_P0_TBCR0, len);
@@ -467,7 +462,7 @@
        if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
                return;
 
-outloop:
+ outloop:
        /* See if there is room to put another packet in the buffer. */
        if (sc->txb_inuse == sc->txb_cnt) {
                /* No room.  Indicate this to the outside world and exit. */
@@ -475,7 +470,7 @@
                return;
        }
        IFQ_DEQUEUE(&ifp->if_snd, m0);
-       if (m0 == 0)
+       if (m0 == NULL)
                return;
 
        /* We need to use m->m_pkthdr.len, so require the header */
@@ -517,11 +512,11 @@
        bus_space_handle_t regh = sc->sc_regh;
        struct dp8390_ring packet_hdr;
        int packet_ptr;
-       u_short len;
-       u_char boundary, current;
-       u_char nlen;
+       uint16_t len;
+       uint8_t boundary, current;
+       uint8_t nlen;
 
-loop:
+ loop:
        /* Set NIC to page 1 registers to get 'current' pointer. */
        NIC_BARRIER(regt, regh);
        NIC_PUT(regt, regh, ED_P0_CR,
@@ -628,18 +623,18 @@
 int
 dp8390_intr(void *arg)
 {
-       struct dp8390_softc *sc = (struct dp8390_softc *)arg;
+       struct dp8390_softc *sc = arg;
        bus_space_tag_t regt = sc->sc_regt;
        bus_space_handle_t regh = sc->sc_regh;
        struct ifnet *ifp = &sc->sc_ec.ec_if;
-       u_char isr;
+       uint8_t isr;
 #if NRND > 0
-       u_char rndisr;
+       uint8_t rndisr;
 #endif
 
        if (sc->sc_enabled == 0 ||
            !device_is_active(sc->sc_dev))
-               return (0);
+               return 0;
 
        /* Set NIC to page 0 registers. */
        NIC_BARRIER(regt, regh);
@@ -648,8 +643,8 @@
        NIC_BARRIER(regt, regh);
 
        isr = NIC_GET(regt, regh, ED_P0_ISR);
-       if (!isr)
-               return (0);
+       if (isr == 0)
+               return 0;
 
 #if NRND > 0
        rndisr = isr;
@@ -679,9 +674,9 @@
                 * may still deliver a TX interrupt.  In this case, just ignore
                 * the interrupt.
                 */
-               if (isr & (ED_ISR_PTX | ED_ISR_TXE) &&
+               if ((isr & (ED_ISR_PTX | ED_ISR_TXE)) != 0 &&
                    sc->txb_inuse != 0) {
-                       u_char collisions =
+                       uint8_t collisions =
                            NIC_GET(regt, regh, ED_P0_NCR) & 0x0f;
 
                        /*
@@ -693,7 +688,7 @@
                         * course, with UDP we're screwed, but this is expected
                         * when a network is heavily loaded.
                         */
-                       if (isr & ED_ISR_TXE) {
+                       if ((isr & ED_ISR_TXE) != 0) {
                                /*
                                 * Excessive collisions (16).
                                 */
@@ -748,7 +743,7 @@
                }
 
                /* Handle receiver interrupts. */
-               if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
+               if ((isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) != 0) {
                        /*
                         * Overwrite warning.  In order to make sure that a
                         * lockup of the local DMA hasn't occurred, we reset
@@ -758,7 +753,7 @@
                         * only with early rev chips - Methinks this bug was
                         * fixed in later revs.  -DG
                         */
-                       if (isr & ED_ISR_OVW) {
+                       if ((isr & ED_ISR_OVW) != 0) {
                                ++ifp->if_ierrors;
 #ifdef DIAGNOSTIC
                                log(LOG_WARNING, "%s: warning - receiver "
@@ -773,7 +768,7 @@
                                 * frame alignment error FIFO overrun, or
                                 * missed packet.
                                 */
-                               if (isr & ED_ISR_RXE) {
+                               if ((isr & ED_ISR_RXE) != 0) {
                                        ++ifp->if_ierrors;
 #ifdef DEBUG
                                        if (dp8390_debug) {
@@ -819,14 +814,14 @@
                 * them.  It appears that old 8390's won't clear the ISR flag
                 * otherwise - resulting in an infinite loop.
                 */
-               if (isr & ED_ISR_CNT) {
+               if ((isr & ED_ISR_CNT) != 0) {
                        (void)NIC_GET(regt, regh, ED_P0_CNTR0);
                        (void)NIC_GET(regt, regh, ED_P0_CNTR1);
                        (void)NIC_GET(regt, regh, ED_P0_CNTR2);
                }
 
                isr = NIC_GET(regt, regh, ED_P0_ISR);
-               if (!isr)
+               if (isr == 0)
                        goto out;
        }
 
@@ -834,7 +829,7 @@
 #if NRND > 0
        rnd_add_uint32(&sc->rnd_source, rndisr);
 #endif
-       return (1);
+       return 1;
 }
 
 /*
@@ -844,8 +839,8 @@
 dp8390_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
        struct dp8390_softc *sc = ifp->if_softc;
-       struct ifaddr *ifa = (struct ifaddr *) data;
-       struct ifreq *ifr = (struct ifreq *) data;
+       struct ifaddr *ifa = data;
+       struct ifreq *ifr = data;
        int s, error = 0;
 
        s = splnet();
@@ -936,7 +931,7 @@
        }
 
        splx(s);
-       return (error);
+       return error;
 }
 
 /*
@@ -951,7 +946,7 @@
 
        /* Pull packet off interface. */
        m = dp8390_get(sc, buf, len);
-       if (m == 0) {
+       if (m == NULL) {
                ifp->if_ierrors++;



Home | Main Index | Thread Index | Old Index