summaryrefslogtreecommitdiffstats
path: root/sys/dev/ti
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2011-11-04 21:30:46 +0000
committeryongari <yongari@FreeBSD.org>2011-11-04 21:30:46 +0000
commit1aaf09e416ed786a3c7a0134dd2b010d4ddba19f (patch)
tree06ec7450a9bc828b983178a790c72a70039714d2 /sys/dev/ti
parent302be77fb36ed87dfe0c7c5add226542a4f71206 (diff)
downloadFreeBSD-src-1aaf09e416ed786a3c7a0134dd2b010d4ddba19f.zip
FreeBSD-src-1aaf09e416ed786a3c7a0134dd2b010d4ddba19f.tar.gz
Introduce ti_ifmedia_upd_locked() to use in driver initialization
and add missing driver lock for both ti_ifmedia_upd() and ti_ifmedia_sts().
Diffstat (limited to 'sys/dev/ti')
-rw-r--r--sys/dev/ti/if_ti.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index e519c42..323563a 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
OpenPOWER on IntegriCloud