diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2009-12-21 18:14:52 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2009-12-21 18:14:52 +0000 |
commit | ce717090df1851e94423b84799454c2427d60fd8 (patch) | |
tree | bd206bff1b23d640cac2ca3d769daf53f114acb3 /sys | |
parent | 29176bc365b15fc05267eb92c8c04aacc9905079 (diff) |
Some cleaning for the rl(4) driver:
- ANSI
- KNF
- remove the use of register
from Brad
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/cardbus/if_rl_cardbus.c | 55 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9.c | 252 | ||||
-rw-r--r-- | sys/dev/pci/if_rl_pci.c | 29 |
3 files changed, 143 insertions, 193 deletions
diff --git a/sys/dev/cardbus/if_rl_cardbus.c b/sys/dev/cardbus/if_rl_cardbus.c index 7fa6adb6b00..fe9c673a6c4 100644 --- a/sys/dev/cardbus/if_rl_cardbus.c +++ b/sys/dev/cardbus/if_rl_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rl_cardbus.c,v 1.17 2009/06/02 17:27:39 jsg Exp $ */ +/* $OpenBSD: if_rl_cardbus.c,v 1.18 2009/12/21 18:14:51 naddy Exp $ */ /* $NetBSD: if_rl_cardbus.c,v 1.3.8.3 2001/11/14 19:14:02 nathanw Exp $ */ /* @@ -132,10 +132,7 @@ struct cfattach rl_cardbus_ca = { }; int -rl_cardbus_match(parent, match, aux) - struct device *parent; - void *match; - void *aux; +rl_cardbus_match(struct device *parent, void *match, void *aux) { return (cardbus_matchbyid((struct cardbus_attach_args *)aux, rl_cardbus_devices, @@ -144,19 +141,18 @@ rl_cardbus_match(parent, match, aux) void -rl_cardbus_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +rl_cardbus_attach(struct device *parent, struct device *self, void *aux) { - struct rl_cardbus_softc *csc = (struct rl_cardbus_softc *)self; - struct rl_softc *sc = &csc->sc_rl; - struct cardbus_attach_args *ca = aux; - struct cardbus_softc *psc = + struct rl_cardbus_softc *csc = + (struct rl_cardbus_softc *)self; + struct rl_softc *sc = &csc->sc_rl; + struct cardbus_attach_args *ca = aux; + struct cardbus_softc *psc = (struct cardbus_softc *)sc->sc_dev.dv_parent; - cardbus_chipset_tag_t cc = psc->sc_cc; - cardbus_function_tag_t cf = psc->sc_cf; - cardbus_devfunc_t ct = ca->ca_ct; - bus_addr_t adr; + cardbus_chipset_tag_t cc = psc->sc_cc; + cardbus_function_tag_t cf = psc->sc_cf; + cardbus_devfunc_t ct = ca->ca_ct; + bus_addr_t adr; sc->sc_dmat = ca->ca_dmat; csc->sc_ct = ct; @@ -213,14 +209,12 @@ rl_cardbus_attach(parent, self, aux) } int -rl_cardbus_detach(self, flags) - struct device *self; - int flags; +rl_cardbus_detach(struct device *self, int flags) { - struct rl_cardbus_softc *csc = (void *) self; - struct rl_softc *sc = &csc->sc_rl; - struct cardbus_devfunc *ct = csc->sc_ct; - int rv; + struct rl_cardbus_softc *csc = (void *) self; + struct rl_softc *sc = &csc->sc_rl; + struct cardbus_devfunc *ct = csc->sc_ct; + int rv; #ifdef DIAGNOSTIC if (ct == NULL) @@ -246,15 +240,14 @@ rl_cardbus_detach(self, flags) } void -rl_cardbus_setup(csc) - struct rl_cardbus_softc *csc; +rl_cardbus_setup(struct rl_cardbus_softc *csc) { - struct rl_softc *sc = &csc->sc_rl; - cardbus_devfunc_t ct = csc->sc_ct; - cardbus_chipset_tag_t cc = ct->ct_cc; - cardbus_function_tag_t cf = ct->ct_cf; - pcireg_t reg, command; - int pmreg; + struct rl_softc *sc = &csc->sc_rl; + cardbus_devfunc_t ct = csc->sc_ct; + cardbus_chipset_tag_t cc = ct->ct_cc; + cardbus_function_tag_t cf = ct->ct_cf; + pcireg_t reg, command; + int pmreg; /* * Handle power management nonsense. diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c index a1ec817781f..071e99c24a2 100644 --- a/sys/dev/ic/rtl81x9.c +++ b/sys/dev/ic/rtl81x9.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9.c,v 1.68 2009/11/23 23:49:45 deraadt Exp $ */ +/* $OpenBSD: rtl81x9.c,v 1.69 2009/12/21 18:14:51 naddy Exp $ */ /* * Copyright (c) 1997, 1998 @@ -172,11 +172,10 @@ int rl_list_tx_init(struct rl_softc *); /* * Send a read command and address to the EEPROM, check for ACK. */ -void rl_eeprom_putbyte(sc, addr, addr_len) - struct rl_softc *sc; - int addr, addr_len; +void +rl_eeprom_putbyte(struct rl_softc *sc, int addr, int addr_len) { - register int d, i; + int d, i; d = (RL_EECMD_READ << addr_len) | addr; @@ -200,13 +199,12 @@ void rl_eeprom_putbyte(sc, addr, addr_len) /* * Read a word of data stored in the EEPROM at address 'addr.' */ -void rl_eeprom_getword(sc, addr, addr_len, dest) - struct rl_softc *sc; - int addr, addr_len; - u_int16_t *dest; +void +rl_eeprom_getword(struct rl_softc *sc, int addr, int addr_len, + u_int16_t *dest) { - register int i; - u_int16_t word = 0; + int i; + u_int16_t word = 0; /* Enter EEPROM access mode. */ CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_PROGRAM|RL_EE_SEL); @@ -239,16 +237,12 @@ void rl_eeprom_getword(sc, addr, addr_len, dest) /* * Read a sequence of words from the EEPROM. */ -void rl_read_eeprom(sc, dest, off, addr_len, cnt, swap) - struct rl_softc *sc; - caddr_t dest; - int off; - int addr_len; - int cnt; - int swap; +void +rl_read_eeprom(struct rl_softc *sc, caddr_t dest, int off, int addr_len, + int cnt, int swap) { - int i; - u_int16_t word = 0, *ptr; + int i; + u_int16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { rl_eeprom_getword(sc, off + i, addr_len, &word); @@ -277,10 +271,10 @@ void rl_read_eeprom(sc, dest, off, addr_len, cnt, swap) /* * Sync the PHYs by setting data bit and strobing the clock 32 times. */ -void rl_mii_sync(sc) - struct rl_softc *sc; +void +rl_mii_sync(struct rl_softc *sc) { - register int i; + int i; MII_SET(RL_MII_DIR|RL_MII_DATAOUT); @@ -295,12 +289,10 @@ void rl_mii_sync(sc) /* * Clock a series of bits through the MII. */ -void rl_mii_send(sc, bits, cnt) - struct rl_softc *sc; - u_int32_t bits; - int cnt; +void +rl_mii_send(struct rl_softc *sc, u_int32_t bits, int cnt) { - int i; + int i; MII_CLR(RL_MII_CLK); @@ -319,11 +311,10 @@ void rl_mii_send(sc, bits, cnt) /* * Read an PHY register through the MII. */ -int rl_mii_readreg(sc, frame) - struct rl_softc *sc; - struct rl_mii_frame *frame; +int +rl_mii_readreg(struct rl_softc *sc, struct rl_mii_frame *frame) { - int i, ack, s; + int i, ack, s; s = splnet(); @@ -411,11 +402,10 @@ fail: /* * Write to a PHY register through the MII. */ -int rl_mii_writereg(sc, frame) - struct rl_softc *sc; - struct rl_mii_frame *frame; +int +rl_mii_writereg(struct rl_softc *sc, struct rl_mii_frame *frame) { - int s; + int s; s = splnet(); /* @@ -456,8 +446,8 @@ int rl_mii_writereg(sc, frame) return(0); } -void rl_iff(sc) - struct rl_softc *sc; +void +rl_iff(struct rl_softc *sc) { struct ifnet *ifp = &sc->sc_arpcom.ac_if; int h = 0; @@ -509,10 +499,9 @@ void rl_iff(sc) } void -rl_reset(sc) - struct rl_softc *sc; +rl_reset(struct rl_softc *sc) { - register int i; + int i; CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_RESET); @@ -530,13 +519,11 @@ rl_reset(sc) * Initialize the transmit descriptors. */ int -rl_list_tx_init(sc) - struct rl_softc *sc; +rl_list_tx_init(struct rl_softc *sc) { - struct rl_chain_data *cd; + struct rl_chain_data *cd = &sc->rl_cdata; int i; - cd = &sc->rl_cdata; for (i = 0; i < RL_TX_LIST_CNT; i++) { cd->rl_tx_chain[i] = NULL; CSR_WRITE_4(sc, @@ -577,20 +564,17 @@ rl_list_tx_init(sc) * 2-byte backstep even if reading from the ring at offset 0. */ void -rl_rxeof(sc) - struct rl_softc *sc; +rl_rxeof(struct rl_softc *sc) { - struct mbuf *m; - struct ifnet *ifp; - int total_len; - u_int32_t rxstat; - caddr_t rxbufpos; - int wrap = 0; - u_int16_t cur_rx; - u_int16_t limit; - u_int16_t rx_bytes = 0, max_bytes; - - ifp = &sc->sc_arpcom.ac_if; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct mbuf *m; + int total_len; + u_int32_t rxstat; + caddr_t rxbufpos; + int wrap = 0; + u_int16_t cur_rx; + u_int16_t limit; + u_int16_t rx_bytes = 0, max_bytes; cur_rx = (CSR_READ_2(sc, RL_CURRXADDR) + 16) % RL_RXBUFLEN; @@ -602,7 +586,7 @@ rl_rxeof(sc) else max_bytes = limit - cur_rx; - while((CSR_READ_1(sc, RL_COMMAND) & RL_CMD_EMPTY_RXBUF) == 0) { + while ((CSR_READ_1(sc, RL_COMMAND) & RL_CMD_EMPTY_RXBUF) == 0) { bus_dmamap_sync(sc->sc_dmat, sc->sc_rx_dmamap, 0, sc->sc_rx_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); rxbufpos = sc->rl_cdata.rl_rx_buf + cur_rx; @@ -718,13 +702,11 @@ rl_rxeof(sc) * A frame was downloaded to the chip. It's safe for us to clean up * the list buffers. */ -void rl_txeof(sc) - struct rl_softc *sc; +void +rl_txeof(struct rl_softc *sc) { - struct ifnet *ifp; - u_int32_t txstat; - - ifp = &sc->sc_arpcom.ac_if; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + u_int32_t txstat; /* * Go through our tx list and free mbufs for those @@ -781,16 +763,13 @@ void rl_txeof(sc) ifp->if_timer = 5; } -int rl_intr(arg) - void *arg; +int +rl_intr(void *arg) { - struct rl_softc *sc; - struct ifnet *ifp; - int claimed = 0; - u_int16_t status; - - sc = arg; - ifp = &sc->sc_arpcom.ac_if; + struct rl_softc *sc = arg; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + int claimed = 0; + u_int16_t status; /* Disable interrupts. */ CSR_WRITE_2(sc, RL_IMR, 0x0000); @@ -828,11 +807,10 @@ int rl_intr(arg) * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data * pointers to the fragment pointers. */ -int rl_encap(sc, m_head) - struct rl_softc *sc; - struct mbuf *m_head; +int +rl_encap(struct rl_softc *sc, struct mbuf *m_head) { - struct mbuf *m_new; + struct mbuf *m_new; /* * The RealTek is brain damaged and wants longword-aligned @@ -887,17 +865,14 @@ int rl_encap(sc, m_head) /* * Main transmit routine. */ - -void rl_start(ifp) - struct ifnet *ifp; +void +rl_start(struct ifnet *ifp) { - struct rl_softc *sc; - struct mbuf *m_head = NULL; - int pkts = 0; + struct rl_softc *sc = ifp->if_softc; + struct mbuf *m_head = NULL; + int pkts = 0; - sc = ifp->if_softc; - - while(RL_CUR_TXMBUF(sc) == NULL) { + while (RL_CUR_TXMBUF(sc) == NULL) { IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -932,6 +907,7 @@ void rl_start(ifp) */ ifp->if_timer = 5; } + if (pkts == 0) return; @@ -944,12 +920,12 @@ void rl_start(ifp) ifp->if_flags |= IFF_OACTIVE; } -void rl_init(xsc) - void *xsc; +void +rl_init(void *xsc) { - struct rl_softc *sc = xsc; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int s; + struct rl_softc *sc = xsc; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + int s; s = splnet(); @@ -1021,8 +997,8 @@ void rl_init(xsc) /* * Set media options. */ -int rl_ifmedia_upd(ifp) - struct ifnet *ifp; +int +rl_ifmedia_upd(struct ifnet *ifp) { struct rl_softc *sc = (struct rl_softc *)ifp->if_softc; @@ -1033,9 +1009,8 @@ int rl_ifmedia_upd(ifp) /* * Report current media status. */ -void rl_ifmedia_sts(ifp, ifmr) - struct ifnet *ifp; - struct ifmediareq *ifmr; +void +rl_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) { struct rl_softc *sc = ifp->if_softc; @@ -1044,15 +1019,13 @@ void rl_ifmedia_sts(ifp, ifmr) ifmr->ifm_active = sc->sc_mii.mii_media_active; } -int rl_ioctl(ifp, command, data) - struct ifnet *ifp; - u_long command; - caddr_t data; +int +rl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { - struct rl_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *) data; - struct ifaddr *ifa = (struct ifaddr *) data; - int s, error = 0; + struct rl_softc *sc = ifp->if_softc; + struct ifreq *ifr = (struct ifreq *) data; + struct ifaddr *ifa = (struct ifaddr *) data; + int s, error = 0; s = splnet(); @@ -1064,7 +1037,7 @@ int rl_ioctl(ifp, command, data) #ifdef INET if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); -#endif /* INET */ +#endif break; case SIOCSIFFLAGS: @@ -1098,12 +1071,10 @@ int rl_ioctl(ifp, command, data) return(error); } -void rl_watchdog(ifp) - struct ifnet *ifp; +void +rl_watchdog(struct ifnet *ifp) { - struct rl_softc *sc; - - sc = ifp->if_softc; + struct rl_softc *sc = ifp->if_softc; printf("%s: watchdog timeout\n", sc->sc_dev.dv_xname); ifp->if_oerrors++; @@ -1116,13 +1087,12 @@ void rl_watchdog(ifp) * Stop the adapter and free any mbufs allocated to the * RX and TX lists. */ -void rl_stop(sc) - struct rl_softc *sc; +void +rl_stop(struct rl_softc *sc) { - register int i; - struct ifnet *ifp; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + int i; - ifp = &sc->sc_arpcom.ac_if; ifp->if_timer = 0; timeout_del(&sc->sc_tick_tmo); @@ -1152,14 +1122,13 @@ void rl_stop(sc) } int -rl_attach(sc) - struct rl_softc *sc; +rl_attach(struct rl_softc *sc) { - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int rseg, i; - u_int16_t rl_id, rl_did; - caddr_t kva; - int addr_len; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + int rseg, i; + u_int16_t rl_id, rl_did; + caddr_t kva; + int addr_len; rl_reset(sc); @@ -1284,22 +1253,18 @@ rl_attach(sc) } void -rl_powerhook(why, arg) - int why; - void *arg; +rl_powerhook(int why, void *arg) { if (why == PWR_RESUME) rl_init(arg); } int -rl_miibus_readreg(self, phy, reg) - struct device *self; - int phy, reg; +rl_miibus_readreg(struct device *self, int phy, int reg) { - struct rl_softc *sc = (struct rl_softc *)self; - struct rl_mii_frame frame; - u_int16_t rl8139_reg; + struct rl_softc *sc = (struct rl_softc *)self; + struct rl_mii_frame frame; + u_int16_t rl8139_reg; if (sc->rl_type == RL_8139) { /* @@ -1345,13 +1310,11 @@ rl_miibus_readreg(self, phy, reg) } void -rl_miibus_writereg(self, phy, reg, val) - struct device *self; - int phy, reg, val; +rl_miibus_writereg(struct device *self, int phy, int reg, int val) { - struct rl_softc *sc = (struct rl_softc *)self; - struct rl_mii_frame frame; - u_int16_t rl8139_reg = 0; + struct rl_softc *sc = (struct rl_softc *)self; + struct rl_mii_frame frame; + u_int16_t rl8139_reg = 0; if (sc->rl_type == RL_8139) { if (phy) @@ -1389,28 +1352,27 @@ rl_miibus_writereg(self, phy, reg, val) } void -rl_miibus_statchg(self) - struct device *self; +rl_miibus_statchg(struct device *self) { } void -rl_tick(v) - void *v; +rl_tick(void *v) { - struct rl_softc *sc = v; - int s; + struct rl_softc *sc = v; + int s; s = splnet(); mii_tick(&sc->sc_mii); splx(s); + timeout_add_sec(&sc->sc_tick_tmo, 1); } int rl_detach(struct rl_softc *sc) { - struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; /* Unhook our tick handler. */ timeout_del(&sc->sc_tick_tmo); diff --git a/sys/dev/pci/if_rl_pci.c b/sys/dev/pci/if_rl_pci.c index 69aa2d6a2c9..fb7180e9094 100644 --- a/sys/dev/pci/if_rl_pci.c +++ b/sys/dev/pci/if_rl_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rl_pci.c,v 1.17 2009/06/02 17:27:39 jsg Exp $ */ +/* $OpenBSD: if_rl_pci.c,v 1.18 2009/12/21 18:14:51 naddy Exp $ */ /* * Copyright (c) 1997, 1998 @@ -114,10 +114,7 @@ const struct pci_matchid rl_pci_devices[] = { }; int -rl_pci_match(parent, match, aux) - struct device *parent; - void *match; - void *aux; +rl_pci_match(struct device *parent, void *match, void *aux) { struct pci_attach_args *pa = aux; @@ -131,16 +128,14 @@ rl_pci_match(parent, match, aux) } void -rl_pci_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +rl_pci_attach(struct device *parent, struct device *self, void *aux) { - struct rl_pci_softc *psc = (void *)self; - struct rl_softc *sc = &psc->psc_softc; - struct pci_attach_args *pa = aux; - pci_chipset_tag_t pc = pa->pa_pc; - pci_intr_handle_t ih; - const char *intrstr = NULL; + struct rl_pci_softc *psc = (void *)self; + struct rl_softc *sc = &psc->psc_softc; + struct pci_attach_args *pa = aux; + pci_chipset_tag_t pc = pa->pa_pc; + pci_intr_handle_t ih; + const char *intrstr = NULL; /* * Map control/status registers. @@ -191,9 +186,9 @@ rl_pci_attach(parent, self, aux) int rl_pci_detach(struct device *self, int flags) { - struct rl_pci_softc *psc = (void *)self; - struct rl_softc *sc = &psc->psc_softc; - int rv; + struct rl_pci_softc *psc = (void *)self; + struct rl_softc *sc = &psc->psc_softc; + int rv; rv = rl_detach(sc); if (rv) |