diff options
author | Pyun YongHyeon <yongari@FreeBSD.org> | 2011-11-04 21:30:46 +0000 |
---|---|---|
committer | Pyun YongHyeon <yongari@FreeBSD.org> | 2011-11-04 21:30:46 +0000 |
commit | 148386d9aa27cd89c0d30bdb911e25951b717551 (patch) | |
tree | 06ec7450a9bc828b983178a790c72a70039714d2 /sys/dev/ti | |
parent | 945c2126591d0f9f1e4604ca856f077a79313cd1 (diff) |
Introduce ti_ifmedia_upd_locked() to use in driver initialization
and add missing driver lock for both ti_ifmedia_upd() and
ti_ifmedia_sts().
Notes
Notes:
svn path=/head/; revision=227093
Diffstat (limited to 'sys/dev/ti')
-rw-r--r-- | sys/dev/ti/if_ti.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index e519c42306de..323563af8984 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -196,6 +196,7 @@ static void ti_stop(struct ti_softc *); static void ti_watchdog(void *); static int ti_shutdown(device_t); static int ti_ifmedia_upd(struct ifnet *); +static int ti_ifmedia_upd_locked(struct ti_softc *); static void ti_ifmedia_sts(struct ifnet *, struct ifmediareq *); static uint32_t ti_eeprom_putbyte(struct ti_softc *, int); @@ -3170,7 +3171,7 @@ static void ti_init2(struct ti_softc *sc) ifm = &sc->ifmedia; tmp = ifm->ifm_media; ifm->ifm_media = ifm->ifm_cur->ifm_media; - ti_ifmedia_upd(ifp); + ti_ifmedia_upd_locked(sc); ifm->ifm_media = tmp; } @@ -3181,11 +3182,23 @@ static int ti_ifmedia_upd(struct ifnet *ifp) { struct ti_softc *sc; + int error; + + sc = ifp->if_softc; + TI_LOCK(sc); + error = ti_ifmedia_upd(ifp); + TI_UNLOCK(sc); + + return (error); +} + +static int +ti_ifmedia_upd_locked(struct ti_softc *sc) +{ struct ifmedia *ifm; struct ti_cmd_desc cmd; uint32_t flowctl; - sc = ifp->if_softc; ifm = &sc->ifmedia; if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) @@ -3286,11 +3299,15 @@ ti_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) sc = ifp->if_softc; + TI_LOCK(sc); + ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; - if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN) + if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN) { + TI_UNLOCK(sc); return; + } ifmr->ifm_status |= IFM_ACTIVE; @@ -3322,6 +3339,7 @@ ti_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) if (media & TI_LNK_HALF_DUPLEX) ifmr->ifm_active |= IFM_HDX; } + TI_UNLOCK(sc); } static int |