Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/emips/ebus - misc KNF



details:   https://anonhg.NetBSD.org/src/rev/0bdf76d6c80a
branches:  trunk
changeset: 765991:0bdf76d6c80a
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Jun 12 14:31:31 2011 +0000

description:
- misc KNF
- use device_t and cfdata_t

diffstat:

 sys/arch/emips/ebus/if_le_ebus.c |  898 ++++++++++++++++++++------------------
 1 files changed, 470 insertions(+), 428 deletions(-)

diffs (truncated from 1268 to 300 lines):

diff -r 3f1fb260382f -r 0bdf76d6c80a sys/arch/emips/ebus/if_le_ebus.c
--- a/sys/arch/emips/ebus/if_le_ebus.c  Sun Jun 12 13:40:14 2011 +0000
+++ b/sys/arch/emips/ebus/if_le_ebus.c  Sun Jun 12 14:31:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_le_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $     */
+/*     $NetBSD: if_le_ebus.c,v 1.2 2011/06/12 14:31:31 tsutsui Exp $   */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.2 2011/06/12 14:31:31 tsutsui Exp $");
 
 #include "opt_inet.h"
 
@@ -71,8 +71,8 @@
 extern paddr_t kvtophys(vaddr_t);
 
 struct bufmap {
-    struct mbuf *mbuf;
-    paddr_t phys;
+       struct mbuf *mbuf;
+       paddr_t phys;
 };
 
 struct enic_softc {
@@ -80,40 +80,40 @@
        struct  ethercom sc_ethercom;   /* Ethernet common part */
        struct  ifmedia sc_media;       /* our supported media */
 
-    struct _Enic *sc_regs;      /* hw registers */
+       struct _Enic *sc_regs;          /* hw registers */
 
-       int     sc_havecarrier; /* carrier status */
-       void    *sc_sh;         /* shutdownhook cookie */
-    int inited;
+       int     sc_havecarrier;         /* carrier status */
+       void    *sc_sh;                 /* shutdownhook cookie */
+       int inited;
 
-    int sc_no_rd;
-    int sc_n_recv;
-    int sc_recv_h;
-    /* BUGBUG really should be malloc-ed */
+       int sc_no_rd;
+       int sc_n_recv;
+       int sc_recv_h;
+       /* BUGBUG really should be malloc-ed */
 #define SC_MAX_N_RECV 64
-    struct bufmap sc_recv[SC_MAX_N_RECV];
+       struct bufmap sc_recv[SC_MAX_N_RECV];
 
-    int sc_no_td;
-    int sc_n_xmit;
-    int sc_xmit_h;
-    /* BUGBUG really should be malloc-ed */
+       int sc_no_td;
+       int sc_n_xmit;
+       int sc_xmit_h;
+       /* BUGBUG really should be malloc-ed */
 #define SC_MAX_N_XMIT 16
-    struct bufmap sc_xmit[SC_MAX_N_XMIT];
+       struct bufmap sc_xmit[SC_MAX_N_XMIT];
 
 #if DEBUG
-    int xhit;
-    int xmiss;
-    int tfull;
-    int tfull2;
-    int brh;
-    int rf;
-    int bxh;
+       int xhit;
+       int xmiss;
+       int tfull;
+       int tfull2;
+       int brh;
+       int rf;
+       int bxh;
 
-    int it;
+       int it;
 #endif
 
-       u_int8_t sc_enaddr[ETHER_ADDR_LEN];
-       u_int8_t sc_pad[2];
+       uint8_t sc_enaddr[ETHER_ADDR_LEN];
+       uint8_t sc_pad[2];
 #if NRND > 0
        rndsource_element_t     rnd_source;
 #endif
@@ -121,44 +121,44 @@
 
 void enic_reset(struct ifnet *);
 int enic_init(struct ifnet *);
-void enic_stop(struct ifnet *ifp, int suspend);
-void enic_start(struct ifnet *ifp);
+void enic_stop(struct ifnet *, int);
+void enic_start(struct ifnet *);
 void enic_shutdown(void *);
-void enic_watchdog(struct ifnet *ifp);
-int enic_mediachange(struct ifnet *ifp);
-void enic_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr);
-int enic_ioctl(struct ifnet *ifp, u_long cmd, void *data);
-int enic_intr(void *cookie, void *f);
+void enic_watchdog(struct ifnet *);
+int enic_mediachange(struct ifnet *);
+void enic_mediastatus(struct ifnet *, struct ifmediareq *);
+int enic_ioctl(struct ifnet *, u_long, void *);
+int enic_intr(void *, void *);
 void enic_rint(struct enic_softc *, uint32_t, paddr_t);
 void enic_tint(struct enic_softc *, uint32_t, paddr_t);
-void enic_kill_xmit(struct enic_softc *sc);
-void enic_post_recv(struct enic_softc *sc, struct mbuf *m);
-void enic_refill(struct enic_softc *sc);
-static int enic_gethwinfo(struct enic_softc *sc);
-int enic_put(struct enic_softc *sc, struct mbuf **pm);
+void enic_kill_xmit(struct enic_softc *);
+void enic_post_recv(struct enic_softc *, struct mbuf *);
+void enic_refill(struct enic_softc *);
+static int enic_gethwinfo(struct enic_softc *);
+int enic_put(struct enic_softc *, struct mbuf **);
 
-static int enic_match(struct device *, struct cfdata *, void *);
-static void enic_attach(struct device *, struct device *, void *);
+static int enic_match(device_t, cfdata_t, void *);
+static void enic_attach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(enic_emips, sizeof(struct enic_softc),
     enic_match, enic_attach, NULL, NULL);
 
 int
-enic_match(struct device *parent, struct cfdata *match, void *aux)
+enic_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct ebus_attach_args *d = aux;
        /* donno yet */
        struct _Enic *et = (struct _Enic *)d->ia_vaddr;
 
        if (strcmp("enic", d->ia_name) != 0)
-               return (0);
+               return 0;
        if ((et == NULL) || (et->Tag != PMTTAG_ETHERNET))
                return 0;
-       return (1);
+       return 1;
 }
 
 void
-enic_attach(struct device *parent, struct device *self, void *aux)
+enic_attach(device_t parent, device_t self, void *aux)
 {
        struct enic_softc *sc = device_private(self);
        struct ebus_attach_args *ia = aux;
@@ -166,7 +166,7 @@
 
        sc->sc_regs = (struct _Enic *)(ia->ia_vaddr);
 #if DEBUG
-       printf(" virt=%p ", (void*)sc->sc_regs);
+       printf(" virt=%p ", (void *)sc->sc_regs);
 #endif
 
        /* Get the MAC and the depth of the FIFOs */
@@ -185,8 +185,8 @@
        sc->sc_recv_h = 0;
        sc->sc_xmit_h = 0;
        /* uhmm do I need to do this? */
-       memset(sc->sc_recv,0, sizeof sc->sc_recv );
-       memset(sc->sc_xmit,0, sizeof sc->sc_xmit );
+       memset(sc->sc_recv, 0, sizeof sc->sc_recv);
+       memset(sc->sc_xmit, 0, sizeof sc->sc_xmit);
 
        /* Initialize ifnet structure. */
        strcpy(ifp->if_xname, device_xname(sc->sc_dev));
@@ -214,7 +214,9 @@
            sc->sc_n_recv, sc->sc_n_xmit, ether_sprintf(sc->sc_enaddr));
 
        /* claim 802.1q capability */
-//     sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
+#if 0
+       sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
+#endif
 
        /* Attach the interface. */
        if_attach(ifp);
@@ -229,83 +231,92 @@
                          RND_TYPE_NET, 0);
 #endif
 
-       ebus_intr_establish(parent, (void*)ia->ia_cookie, IPL_NET,
+       ebus_intr_establish(parent, (void *)ia->ia_cookie, IPL_NET,
            enic_intr, sc);
 }
 
-/* Beware: does not work while the nic is running
+/*
+ * Beware: does not work while the nic is running
  */
 static int enic_gethwinfo(struct enic_softc *sc)
 {
-    uint8_t buffer[8];/* 64bits max */
-    PENIC_INFO hw = (PENIC_INFO)buffer;
-    paddr_t phys = kvtophys((vaddr_t)&buffer[0]), phys2;
-    int i;
+       uint8_t buffer[8];      /* 64bits max */
+       PENIC_INFO hw = (PENIC_INFO)buffer;
+       paddr_t phys = kvtophys((vaddr_t)&buffer[0]), phys2;
+       int i;
 
-    /* First thing first, get the MAC address
-     */
-    memset(buffer,0,sizeof buffer);
-    buffer[0] = ENIC_CMD_GET_ADDRESS;
-    buffer[3] = ENIC_CMD_GET_ADDRESS;/* bswap bug */
-    sc->sc_regs->SizeAndFlags = (sizeof buffer) | ES_F_CMD;
-    sc->sc_regs->BufferAddressHi32 = 0;
-    sc->sc_regs->BufferAddressLo32 = phys; /* go! */
+       /*
+        * First thing first, get the MAC address
+        */
+       memset(buffer,0,sizeof buffer);
+       buffer[0] = ENIC_CMD_GET_ADDRESS;
+       buffer[3] = ENIC_CMD_GET_ADDRESS;       /* bswap bug */
+       sc->sc_regs->SizeAndFlags = (sizeof buffer) | ES_F_CMD;
+       sc->sc_regs->BufferAddressHi32 = 0;
+       sc->sc_regs->BufferAddressLo32 = phys; /* go! */
 
-    for (i = 0; i < 100; i++) {
-        DELAY(100);
-        if (0 == (sc->sc_regs->Control & EC_OF_EMPTY))
-            break;
-    }
-    if (i == 100)
-        return 0;
+       for (i = 0; i < 100; i++) {
+               DELAY(100);
+               if ((sc->sc_regs->Control & EC_OF_EMPTY) == 0)
+                       break;
+       }
+       if (i == 100)
+               return 0;
 
-    phys2 = sc->sc_regs->BufferAddressLo32;
-    if (phys2 != phys) {
-        printf("enic uhu? %llx != %llx?\n",(long long)phys,(long long)phys2);
-        return 0;
-    }
-    memcpy(sc->sc_enaddr,buffer,ETHER_ADDR_LEN);
+       phys2 = sc->sc_regs->BufferAddressLo32;
+       if (phys2 != phys) {
+               printf("enic uhu? %llx != %llx?\n",
+                   (long long)phys, (long long)phys2);
+               return 0;
+       }
+       memcpy(sc->sc_enaddr, buffer, ETHER_ADDR_LEN);
 
-    /* Next get the HW parameters
-     */
-    memset(buffer,0,sizeof buffer);
-    buffer[0] = ENIC_CMD_GET_INFO;
-    buffer[3] = ENIC_CMD_GET_INFO;/* bswap bug */
-    sc->sc_regs->SizeAndFlags = (sizeof buffer) | ES_F_CMD;
-    sc->sc_regs->BufferAddressHi32 = 0;
-    sc->sc_regs->BufferAddressLo32 = phys; /* go! */
+       /*
+        * Next get the HW parameters
+        */
+       memset(buffer,0,sizeof buffer);
+       buffer[0] = ENIC_CMD_GET_INFO;
+       buffer[3] = ENIC_CMD_GET_INFO;  /* bswap bug */
+       sc->sc_regs->SizeAndFlags = (sizeof buffer) | ES_F_CMD;
+       sc->sc_regs->BufferAddressHi32 = 0;
+       sc->sc_regs->BufferAddressLo32 = phys; /* go! */
 
-    for (i = 0; i < 100; i++) {
-        DELAY(100);
-        if (0 == (sc->sc_regs->Control & EC_OF_EMPTY))
-            break;
-    }
-    if (i == 100)
-        return 0;
+       for (i = 0; i < 100; i++) {
+               DELAY(100);
+               if ((sc->sc_regs->Control & EC_OF_EMPTY) == 0)
+                       break;
+       }
+       if (i == 100)
+               return 0;
 
-    phys2 = sc->sc_regs->BufferAddressLo32;
-    if (phys2 != phys) {
-        printf("enic uhu2? %llx != %llx?\n",(long long)phys,(long long)phys2);
-        return 0;
-    }
-    //printf("enic: hwinfo: %x %x %x %x %x %x \n", hw->InputFifoSize, hw->OutputFifoSize, hw->CompletionFifoSize,
-    //           hw->ErrorCount, hw->FramesDropped, hw->Reserved);
+       phys2 = sc->sc_regs->BufferAddressLo32;



Home | Main Index | Thread Index | Old Index