summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2014-12-08 10:58:46 +0000
committerBrad Smith <brad@cvs.openbsd.org>2014-12-08 10:58:46 +0000
commit295fd73b0e245ca137ce0b5f2c881b0e5eabaca5 (patch)
tree55a658ba34de6ce1710a9220673b7c47e303e4fe /sys/dev/ic
parent289b5d92df74fa66f52fd6e6c1007523f9e1f37c (diff)
Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant calls to foo_stop() and foo_reset() before foo_init(). Tested with DP83815, 3c905C, 8139 and ST201. Mostly from FreeBSD.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/mtd8xx.c9
-rw-r--r--sys/dev/ic/rtl81x9.c10
-rw-r--r--sys/dev/ic/xl.c21
3 files changed, 18 insertions, 22 deletions
diff --git a/sys/dev/ic/mtd8xx.c b/sys/dev/ic/mtd8xx.c
index 93a14e36c5a..c566b66add4 100644
--- a/sys/dev/ic/mtd8xx.c
+++ b/sys/dev/ic/mtd8xx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mtd8xx.c,v 1.22 2014/09/06 05:41:35 jsg Exp $ */
+/* $OpenBSD: mtd8xx.c,v 1.23 2014/12/08 10:58:45 brad Exp $ */
/*
* Copyright (c) 2003 Oleg Safiullin <form@pdp11.org.ru>
@@ -636,6 +636,11 @@ mtd_init(struct ifnet *ifp)
mtd_stop(ifp);
/*
+ * Reset the chip to a known state.
+ */
+ mtd_reset(sc);
+
+ /*
* Set cache alignment and burst length.
*/
CSR_WRITE_4(MTD_BCR, BCR_PBL8);
@@ -801,8 +806,6 @@ mtd_watchdog(struct ifnet *ifp)
ifp->if_oerrors++;
printf("%s: watchdog timeout\n", sc->sc_dev.dv_xname);
- mtd_stop(ifp);
- mtd_reset(sc);
mtd_init(ifp);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c
index fe4e2654c4f..7c138dc5dc4 100644
--- a/sys/dev/ic/rtl81x9.c
+++ b/sys/dev/ic/rtl81x9.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtl81x9.c,v 1.84 2014/11/24 02:03:37 brad Exp $ */
+/* $OpenBSD: rtl81x9.c,v 1.85 2014/12/08 10:58:45 brad Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -739,7 +739,6 @@ rl_txeof(struct rl_softc *sc)
CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG);
oldthresh = sc->rl_txthresh;
/* error recovery */
- rl_reset(sc);
rl_init(sc);
/* restore original threshold */
sc->rl_txthresh = oldthresh;
@@ -779,10 +778,8 @@ rl_intr(void *arg)
rl_rxeof(sc);
if ((status & RL_ISR_TX_OK) || (status & RL_ISR_TX_ERR))
rl_txeof(sc);
- if (status & RL_ISR_SYSTEM_ERR) {
- rl_reset(sc);
+ if (status & RL_ISR_SYSTEM_ERR)
rl_init(sc);
- }
claimed = 1;
}
@@ -926,6 +923,9 @@ rl_init(void *xsc)
*/
rl_stop(sc);
+ /* Put controller into known state. */
+ rl_reset(sc);
+
/*
* Init our MAC address. Even though the chipset
* documentation doesn't mention it, we need to enter "Config
diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c
index 1d951471f15..be53e83771c 100644
--- a/sys/dev/ic/xl.c
+++ b/sys/dev/ic/xl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xl.c,v 1.118 2014/11/24 10:33:37 brad Exp $ */
+/* $OpenBSD: xl.c,v 1.119 2014/12/08 10:58:45 brad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -201,14 +201,11 @@ xl_activate(struct device *self, int act)
switch (act) {
case DVACT_SUSPEND:
- if (ifp->if_flags & IFF_RUNNING) {
- xl_reset(sc);
+ if (ifp->if_flags & IFF_RUNNING)
xl_stop(sc);
- }
rv = config_activate_children(self, act);
break;
case DVACT_RESUME:
- xl_reset(sc);
if (ifp->if_flags & IFF_UP)
xl_init(sc);
break;
@@ -1506,10 +1503,8 @@ xl_intr(void *arg)
xl_txeoc(sc);
}
- if (status & XL_STAT_ADFAIL) {
- xl_reset(sc);
+ if (status & XL_STAT_ADFAIL)
xl_init(sc);
- }
if (status & XL_STAT_STATSOFLOW) {
sc->xl_stats_no_timeout = 1;
@@ -1917,6 +1912,9 @@ xl_init(void *xsc)
*/
xl_stop(sc);
+ /* Reset the chip to a known state. */
+ xl_reset(sc);
+
if (sc->xl_hasmii)
mii = &sc->sc_mii;
@@ -2285,7 +2283,6 @@ xl_watchdog(struct ifnet *ifp)
xl_txeoc(sc);
xl_txeof(sc);
xl_rxeof(sc);
- xl_reset(sc);
xl_init(sc);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
@@ -2569,12 +2566,8 @@ xl_attach(struct xl_softc *sc)
* a 10/100 card of some kind, we need to force the transceiver
* type to something sane.
*/
- if (sc->xl_xcvr == XL_XCVR_AUTO) {
+ if (sc->xl_xcvr == XL_XCVR_AUTO)
xl_choose_xcvr(sc, 0);
- i = splnet();
- xl_reset(sc);
- splx(i);
- }
if (sc->xl_media & XL_MEDIAOPT_BT) {
ifmedia_add(ifm, IFM_ETHER|IFM_10_T, 0, NULL);