diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2014-12-08 10:58:46 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2014-12-08 10:58:46 +0000 |
commit | 295fd73b0e245ca137ce0b5f2c881b0e5eabaca5 (patch) | |
tree | 55a658ba34de6ce1710a9220673b7c47e303e4fe /sys/dev | |
parent | 289b5d92df74fa66f52fd6e6c1007523f9e1f37c (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')
-rw-r--r-- | sys/dev/ic/mtd8xx.c | 9 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9.c | 10 | ||||
-rw-r--r-- | sys/dev/ic/xl.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_sis.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/if_ste.c | 10 |
5 files changed, 29 insertions, 34 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); diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c index 87ecf789e3b..2524b9d8bea 100644 --- a/sys/dev/pci/if_sis.c +++ b/sys/dev/pci/if_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sis.c,v 1.118 2014/11/24 10:33:37 brad Exp $ */ +/* $OpenBSD: if_sis.c,v 1.119 2014/12/08 10:58:45 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -1552,10 +1552,8 @@ sis_intr(void *arg) sis_rx_list[sc->sis_cdata.sis_rx_cons])); } - if (status & SIS_ISR_SYSERR) { - sis_reset(sc); + if (status & SIS_ISR_SYSERR) sis_init(sc); - } /* * XXX: Re-enable RX engine every time otherwise it occasionally @@ -1697,6 +1695,11 @@ sis_init(void *xsc) */ sis_stop(sc); + /* + * Reset the chip to a known state. + */ + sis_reset(sc); + #if NS_IHR_DELAY > 0 /* Configure interrupt holdoff register. */ if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr == NS_SRR_16A) @@ -1926,8 +1929,6 @@ sis_watchdog(struct ifnet *ifp) printf("%s: watchdog timeout\n", sc->sc_dev.dv_xname); s = splnet(); - sis_stop(sc); - sis_reset(sc); sis_init(sc); if (!IFQ_IS_EMPTY(&ifp->if_snd)) diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c index 9b741d370b0..c0b47bd05c6 100644 --- a/sys/dev/pci/if_ste.c +++ b/sys/dev/pci/if_ste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ste.c,v 1.55 2014/07/22 13:12:11 mpi Exp $ */ +/* $OpenBSD: if_ste.c,v 1.56 2014/12/08 10:58:45 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -589,10 +589,8 @@ ste_intr(void *xsc) if (status & STE_ISR_LINKEVENT) mii_pollstat(&sc->sc_mii); - if (status & STE_ISR_HOSTERR) { - ste_reset(sc); + if (status & STE_ISR_HOSTERR) ste_init(sc); - } } /* Re-enable interrupts */ @@ -724,7 +722,6 @@ ste_txeoc(struct ste_softc *sc) printf("%s: transmission error: %x\n", sc->sc_dev.dv_xname, txstat); - ste_reset(sc); ste_init(sc); if (txstat & STE_TXSTATUS_UNDERRUN && @@ -1049,6 +1046,8 @@ ste_init(void *xsc) s = splnet(); ste_stop(sc); + /* Reset the chip to a known state. */ + ste_reset(sc); mii = &sc->sc_mii; @@ -1405,7 +1404,6 @@ ste_watchdog(struct ifnet *ifp) ste_txeof(sc); ste_rxeoc(sc); ste_rxeof(sc); - ste_reset(sc); ste_init(sc); if (!IFQ_IS_EMPTY(&ifp->if_snd)) |