Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic - Use aprint_*.
details: https://anonhg.NetBSD.org/src/rev/5c3a8f0fc9a1
branches: trunk
changeset: 572622:5c3a8f0fc9a1
user: kanaoka <kanaoka%NetBSD.org@localhost>
date: Sun Jan 09 12:15:36 2005 +0000
description:
- Use aprint_*.
- Remove unnecesarry code.
- Changes some cosmetic.
diffstat:
sys/dev/ic/rtl8169.c | 477 +++++++++++++++-----------------------------------
1 files changed, 143 insertions(+), 334 deletions(-)
diffs (truncated from 980 to 300 lines):
diff -r bc6231632bbe -r 5c3a8f0fc9a1 sys/dev/ic/rtl8169.c
--- a/sys/dev/ic/rtl8169.c Sun Jan 09 11:57:34 2005 +0000
+++ b/sys/dev/ic/rtl8169.c Sun Jan 09 12:15:36 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtl8169.c,v 1.3 2004/12/26 07:27:41 kanaoka Exp $ */
+/* $NetBSD: rtl8169.c,v 1.4 2005/01/09 12:15:36 kanaoka Exp $ */
/*
* Copyright (c) 1997, 1998-2003
@@ -154,52 +154,39 @@
#include <dev/ic/rtl8169var.h>
-/*
- * In FreeBSD and OpenBSD's derivative, re_detach is disabled
- * by #if 0/#endif. On NetBSD, we support cardbus attachments,
- * which require if_detach. So re-enable re_detach(). jonathan, 2004-10-08.
- */
+static int re_encap(struct rtk_softc *, struct mbuf *, int *);
-int re_detach(struct rtk_softc *);
-
-static int re_encap (struct rtk_softc *, struct mbuf *, int *);
+static int re_allocmem(struct rtk_softc *);
+static int re_newbuf(struct rtk_softc *, int, struct mbuf *);
+static int re_rx_list_init(struct rtk_softc *);
+static int re_tx_list_init(struct rtk_softc *);
+static void re_rxeof(struct rtk_softc *);
+static void re_txeof(struct rtk_softc *);
+static void re_tick(void *);
+static void re_start(struct ifnet *);
+static int re_ioctl(struct ifnet *, u_long, caddr_t);
+static int re_init(struct ifnet *);
+static void re_stop(struct ifnet *, int);
+static void re_watchdog(struct ifnet *);
-static int re_allocmem (struct rtk_softc *);
-static int re_newbuf (struct rtk_softc *, int, struct mbuf *);
-static int re_rx_list_init (struct rtk_softc *);
-static int re_tx_list_init (struct rtk_softc *);
-static void re_rxeof (struct rtk_softc *);
-static void re_txeof (struct rtk_softc *);
-static void re_tick (void *);
-static void re_start (struct ifnet *);
-static int re_ioctl (struct ifnet *, u_long, caddr_t);
-static int re_init (struct ifnet *);
-static void re_stop (struct ifnet *, int);
-static void re_watchdog (struct ifnet *);
-#if 0
-static int re_suspend (device_t);
-static int re_resume (device_t);
-static void re_shutdown (device_t);
-#endif
+static void re_shutdown(void *);
+static int re_enable(struct rtk_softc *);
+static void re_disable(struct rtk_softc *);
+static void re_power(int, void *);
+
+static int re_ifmedia_upd(struct ifnet *);
+static void re_ifmedia_sts(struct ifnet *, struct ifmediareq *);
-static void re_shutdown (void *);
-static int re_enable (struct rtk_softc *);
-static void re_disable (struct rtk_softc *);
-static void re_power (int, void *);
-
-static int re_ifmedia_upd (struct ifnet *);
-static void re_ifmedia_sts (struct ifnet *, struct ifmediareq *);
+static int re_gmii_readreg(struct device *, int, int);
+static void re_gmii_writereg(struct device *, int, int, int);
-static int re_gmii_readreg (struct device *, int, int);
-static void re_gmii_writereg (struct device *, int, int, int);
+static int re_miibus_readreg(struct device *, int, int);
+static void re_miibus_writereg(struct device *, int, int, int);
+static void re_miibus_statchg(struct device *);
-static int re_miibus_readreg (struct device *, int, int);
-static void re_miibus_writereg (struct device *, int, int, int);
-static void re_miibus_statchg (struct device *);
+static void re_reset(struct rtk_softc *);
-static void re_reset (struct rtk_softc *);
-
-static int re_diag (struct rtk_softc *);
+static int re_diag(struct rtk_softc *);
#ifdef RE_USEIOSPACE
#define RTK_RES SYS_RES_IOPORT
@@ -225,13 +212,13 @@
int i;
if (phy != 7)
- return(0);
+ return 0;
/* Let the rgephy driver read the GMEDIASTAT register */
if (reg == RTK_GMEDIASTAT) {
rval = CSR_READ_1(sc, RTK_GMEDIASTAT);
- return(rval);
+ return rval;
}
CSR_WRITE_4(sc, RTK_PHYAR, reg << 16);
@@ -245,11 +232,11 @@
}
if (i == RTK_TIMEOUT) {
- printf ("%s: PHY read failed\n", sc->sc_dev.dv_xname);
- return (0);
+ aprint_error("%s: PHY read failed\n", sc->sc_dev.dv_xname);
+ return 0;
}
- return (rval & RTK_PHYAR_PHYDATA);
+ return rval & RTK_PHYAR_PHYDATA;
}
static void
@@ -271,8 +258,8 @@
}
if (i == RTK_TIMEOUT) {
- printf ("%s: PHY write reg %x <- %x failed\n",
- sc->sc_dev.dv_xname, reg, data);
+ aprint_error("%s: PHY write reg %x <- %x failed\n",
+ sc->sc_dev.dv_xname, reg, data);
return;
}
@@ -292,15 +279,15 @@
if (sc->rtk_type == RTK_8169) {
rval = re_gmii_readreg(dev, phy, reg);
splx(s);
- return (rval);
+ return rval;
}
/* Pretend the internal PHY is only at address 0 */
if (phy) {
splx(s);
- return(0);
+ return 0;
}
- switch(reg) {
+ switch (reg) {
case MII_BMCR:
re8139_reg = RTK_BMCR;
break;
@@ -319,7 +306,7 @@
case MII_PHYIDR1:
case MII_PHYIDR2:
splx(s);
- return(0);
+ return 0;
/*
* Allow the rlphy driver to read the media status
* register. If we have a link partner which does not
@@ -329,15 +316,15 @@
case RTK_MEDIASTAT:
rval = CSR_READ_1(sc, RTK_MEDIASTAT);
splx(s);
- return(rval);
+ return rval;
default:
- printf("%s: bad phy register\n", sc->sc_dev.dv_xname);
+ aprint_error("%s: bad phy register\n", sc->sc_dev.dv_xname);
splx(s);
- return(0);
+ return 0;
}
rval = CSR_READ_2(sc, re8139_reg);
splx(s);
- return(rval);
+ return rval;
}
static void
@@ -360,7 +347,7 @@
splx(s);
return;
}
- switch(reg) {
+ switch (reg) {
case MII_BMCR:
re8139_reg = RTK_BMCR;
break;
@@ -382,7 +369,7 @@
return;
break;
default:
- printf("%s: bad phy register\n", sc->sc_dev.dv_xname);
+ aprint_error("%s: bad phy register\n", sc->sc_dev.dv_xname);
splx(s);
return;
}
@@ -411,14 +398,15 @@
break;
}
if (i == RTK_TIMEOUT)
- printf("%s: reset never completed!\n", sc->sc_dev.dv_xname);
+ aprint_error("%s: reset never completed!\n",
+ sc->sc_dev.dv_xname);
/*
* NB: Realtek-supplied Linux driver does this only for
* MCFG_METHOD_2, which corresponds to sc->sc_rev == 2.
*/
- if (1) /*XXX check softc flag for 8169s version */
- CSR_WRITE_1(sc, 0x82, 1);
+ if (1) /* XXX check softc flag for 8169s version */
+ CSR_WRITE_1(sc, 0x82, 1);
return;
}
@@ -461,7 +449,7 @@
MGETHDR(m0, M_DONTWAIT, MT_DATA);
if (m0 == NULL)
- return(ENOBUFS);
+ return ENOBUFS;
/*
* Initialize the NIC in test mode. This sets the chip up
@@ -475,15 +463,15 @@
ifp->if_flags |= IFF_PROMISC;
sc->rtk_testmode = 1;
re_init(ifp);
- re_stop(ifp,1);
+ re_stop(ifp, 1);
DELAY(100000);
re_init(ifp);
/* Put some data in the mbuf */
eh = mtod(m0, struct ether_header *);
- bcopy ((char *)&dst, eh->ether_dhost, ETHER_ADDR_LEN);
- bcopy ((char *)&src, eh->ether_shost, ETHER_ADDR_LEN);
+ bcopy((char *)&dst, eh->ether_dhost, ETHER_ADDR_LEN);
+ bcopy((char *)&src, eh->ether_shost, ETHER_ADDR_LEN);
eh->ether_type = htons(ETHERTYPE_IP);
m0->m_pkthdr.len = m0->m_len = ETHER_MIN_LEN - ETHER_CRC_LEN;
@@ -503,13 +491,13 @@
DELAY(100000);
for (i = 0; i < RTK_TIMEOUT; i++) {
status = CSR_READ_2(sc, RTK_ISR);
- if ((status & (RTK_ISR_TIMEOUT_EXPIRED|RTK_ISR_RX_OK)) ==
- (RTK_ISR_TIMEOUT_EXPIRED|RTK_ISR_RX_OK))
+ if ((status & (RTK_ISR_TIMEOUT_EXPIRED | RTK_ISR_RX_OK)) ==
+ (RTK_ISR_TIMEOUT_EXPIRED | RTK_ISR_RX_OK))
break;
DELAY(10);
}
if (i == RTK_TIMEOUT) {
- printf("%s: diagnostic failed, failed to receive packet "
+ aprint_error("%s: diagnostic failed, failed to receive packet "
"in loopback mode\n", sc->sc_dev.dv_xname);
error = EIO;
goto done;
@@ -538,7 +526,7 @@
rxstat = le32toh(cur_rx->rtk_cmdstat);
if (total_len != ETHER_MIN_LEN) {
- printf("%s: diagnostic failed, received short packet\n",
+ aprint_error("%s: diagnostic failed, received short packet\n",
sc->sc_dev.dv_xname);
error = EIO;
goto done;
@@ -549,20 +537,21 @@
if (bcmp((char *)&eh->ether_dhost, (char *)&dst, ETHER_ADDR_LEN) ||
bcmp((char *)&eh->ether_shost, (char *)&src, ETHER_ADDR_LEN) ||
ntohs(eh->ether_type) != ETHERTYPE_IP) {
- printf("%s: WARNING, DMA FAILURE!\n", sc->sc_dev.dv_xname);
- printf("%s: expected TX data: %s",
+ aprint_error("%s: WARNING, DMA FAILURE!\n",
+ sc->sc_dev.dv_xname);
+ aprint_error("%s: expected TX data: %s",
sc->sc_dev.dv_xname, ether_sprintf(dst));
- printf("/%s/0x%x\n", ether_sprintf(src), ETHERTYPE_IP);
- printf("%s: received RX data: %s",
+ aprint_error("/%s/0x%x\n", ether_sprintf(src), ETHERTYPE_IP);
+ aprint_error("%s: received RX data: %s",
sc->sc_dev.dv_xname,
ether_sprintf(eh->ether_dhost));
- printf("/%s/0x%x\n", ether_sprintf(eh->ether_shost),
+ aprint_error("/%s/0x%x\n", ether_sprintf(eh->ether_shost),
ntohs(eh->ether_type));
- printf("%s: You may have a defective 32-bit NIC plugged "
+ aprint_error("%s: You may have a defective 32-bit NIC plugged "
"into a 64-bit PCI slot.\n", sc->sc_dev.dv_xname);
- printf("%s: Please re-install the NIC in a 32-bit slot "
+ aprint_error("%s: Please re-install the NIC in a 32-bit slot "
"for proper operation.\n", sc->sc_dev.dv_xname);
- printf("%s: Read the re(4) man page for more details.\n",
+ aprint_error("%s: Read the re(4) man page for more details.\n",
sc->sc_dev.dv_xname);
error = EIO;
}
Home |
Main Index |
Thread Index |
Old Index