Use device_get_nameunit(dev) as the mutex string when calling

mtx_init() instead of hard-coded string constant. Also remember to do
the mutex changes to the ste driver, which I forgot in the first commit.
This commit is contained in:
Bill Paul 2000-10-13 18:35:49 +00:00
parent 36fa62c01b
commit 1e856a7b34
18 changed files with 70 additions and 49 deletions

View File

@ -1699,7 +1699,7 @@ static int dc_attach(dev)
goto fail;
}
mtx_init(&sc->dc_mtx, "dc", MTX_DEF);
mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF);
DC_LOCK(sc);
/* Need this info to decide on a chip type. */
sc->dc_info = dc_devtype(dev);

View File

@ -766,7 +766,7 @@ static int sf_attach(dev)
}
callout_handle_init(&sc->sf_stat_ch);
mtx_init(&sc->sf_mtx, "sf", MTX_DEF);
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/* Reset the adapter. */
sf_reset(sc);

View File

@ -1277,7 +1277,7 @@ static int sk_attach(dev)
goto fail;
}
mtx_init(&sc->sk_mtx, "skc", MTX_DEF);
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/* Reset the adapter. */
sk_reset(sc);

View File

@ -1537,7 +1537,7 @@ static int ti_attach(dev)
goto fail;
}
mtx_init(&sc->ti_mtx, "ti", MTX_DEF);
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
sc->ti_unit = unit;

View File

@ -729,7 +729,7 @@ static int vr_attach(dev)
goto fail;
}
mtx_init(&sc->vr_mtx, "vr", MTX_DEF);
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/* Reset the adapter. */
vr_reset(sc);

View File

@ -1699,7 +1699,7 @@ static int dc_attach(dev)
goto fail;
}
mtx_init(&sc->dc_mtx, "dc", MTX_DEF);
mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF);
DC_LOCK(sc);
/* Need this info to decide on a chip type. */
sc->dc_info = dc_devtype(dev);

View File

@ -398,7 +398,8 @@ static int pcn_probe(dev)
}
sc->pcn_btag = rman_get_bustag(sc->pcn_res);
sc->pcn_bhandle = rman_get_bushandle(sc->pcn_res);
mtx_init(&sc->pcn_mtx, "pcn", MTX_DEF);
mtx_init(&sc->pcn_mtx,
device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
pcn_reset(sc);
chip_id = pcn_csr_read(sc, PCN_CSR_CHIPID1);
@ -534,7 +535,7 @@ static int pcn_attach(dev)
}
/* Initialize our mutex. */
mtx_init(&sc->pcn_mtx, "pcn", MTX_DEF);
mtx_init(&sc->pcn_mtx, device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
/* Reset the adapter. */

View File

@ -887,7 +887,7 @@ static int rl_attach(dev)
callout_handle_init(&sc->rl_stat_ch);
mtx_init(&sc->rl_mtx, "rl", MTX_DEF);
mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_DEF);
RL_LOCK(sc);
/* Reset the adapter. */

View File

@ -766,7 +766,7 @@ static int sf_attach(dev)
}
callout_handle_init(&sc->sf_stat_ch);
mtx_init(&sc->sf_mtx, "sf", MTX_DEF);
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/* Reset the adapter. */
sf_reset(sc);

View File

@ -732,7 +732,7 @@ static int sis_attach(dev)
goto fail;
}
mtx_init(&sc->sis_mtx, "sis", MTX_DEF);
mtx_init(&sc->sis_mtx, device_get_nameunit(dev), MTX_DEF);
SIS_LOCK(sc);
/* Reset the adapter. */

View File

@ -1277,7 +1277,7 @@ static int sk_attach(dev)
goto fail;
}
mtx_init(&sc->sk_mtx, "skc", MTX_DEF);
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/* Reset the adapter. */
sk_reset(sc);

View File

@ -242,9 +242,9 @@ static int ste_mii_readreg(sc, frame)
struct ste_mii_frame *frame;
{
int i, ack, s;
int i, ack;
s = splimp();
STE_LOCK(sc);
/*
* Set up frame for RX.
@ -319,7 +319,7 @@ static int ste_mii_readreg(sc, frame)
MII_SET(STE_PHYCTL_MCLK);
DELAY(1);
splx(s);
STE_UNLOCK(sc);
if (ack)
return(1);
@ -334,9 +334,8 @@ static int ste_mii_writereg(sc, frame)
struct ste_mii_frame *frame;
{
int s;
STE_LOCK(sc);
s = splimp();
/*
* Set up frame for TX.
*/
@ -370,7 +369,7 @@ static int ste_mii_writereg(sc, frame)
*/
MII_CLR(STE_PHYCTL_MDIR);
splx(s);
STE_UNLOCK(sc);
return(0);
}
@ -419,6 +418,7 @@ static void ste_miibus_statchg(dev)
struct mii_data *mii;
sc = device_get_softc(dev);
STE_LOCK(sc);
mii = device_get_softc(sc->ste_miibus);
if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
@ -426,6 +426,7 @@ static void ste_miibus_statchg(dev)
} else {
STE_CLRBIT2(sc, STE_MACCTL0, STE_MACCTL0_FULLDUPLEX);
}
STE_UNLOCK(sc);
return;
}
@ -615,11 +616,14 @@ static void ste_intr(xsc)
u_int16_t status;
sc = xsc;
STE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
/* See if this is really our interrupt. */
if (!(CSR_READ_2(sc, STE_ISR) & STE_ISR_INTLATCH))
if (!(CSR_READ_2(sc, STE_ISR) & STE_ISR_INTLATCH)) {
STE_UNLOCK(sc);
return;
}
for (;;) {
status = CSR_READ_2(sc, STE_ISR_ACK);
@ -653,6 +657,8 @@ static void ste_intr(xsc)
if (ifp->if_snd.ifq_head != NULL)
ste_start(ifp);
STE_UNLOCK(sc);
return;
}
@ -837,12 +843,12 @@ static void ste_stats_update(xsc)
struct ste_stats stats;
struct ifnet *ifp;
struct mii_data *mii;
int i, s;
int i;
u_int8_t *p;
s = splimp();
sc = xsc;
STE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
mii = device_get_softc(sc->ste_miibus);
@ -867,7 +873,7 @@ static void ste_stats_update(xsc)
}
sc->ste_stat_ch = timeout(ste_stats_update, sc, hz);
splx(s);
STE_UNLOCK(sc);
return;
}
@ -903,14 +909,11 @@ static int ste_probe(dev)
static int ste_attach(dev)
device_t dev;
{
int s;
u_int32_t command;
struct ste_softc *sc;
struct ifnet *ifp;
int unit, error = 0, rid;
s = splimp();
sc = device_get_softc(dev);
unit = device_get_unit(dev);
bzero(sc, sizeof(struct ste_softc));
@ -1000,6 +1003,8 @@ static int ste_attach(dev)
}
callout_handle_init(&sc->ste_stat_ch);
mtx_init(&sc->ste_mtx, device_get_nameunit(dev), MTX_DEF);
STE_LOCK(sc);
/* Reset the adapter. */
ste_reset(sc);
@ -1071,9 +1076,12 @@ static int ste_attach(dev)
* Call MI attach routine.
*/
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
STE_UNLOCK(sc);
return(0);
fail:
splx(s);
STE_UNLOCK(sc);
mtx_destroy(&sc->ste_mtx);
return(error);
}
@ -1082,11 +1090,9 @@ static int ste_detach(dev)
{
struct ste_softc *sc;
struct ifnet *ifp;
int s;
s = splimp();
sc = device_get_softc(dev);
STE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ste_stop(sc);
@ -1101,7 +1107,8 @@ static int ste_detach(dev)
contigfree(sc->ste_ldata, sizeof(struct ste_list_data), M_DEVBUF);
splx(s);
STE_UNLOCK(sc);
mtx_destroy(&sc->ste_mtx);
return(0);
}
@ -1218,13 +1225,12 @@ static void ste_init(xsc)
void *xsc;
{
struct ste_softc *sc;
int i, s;
int i;
struct ifnet *ifp;
struct mii_data *mii;
s = splimp();
sc = xsc;
STE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
mii = device_get_softc(sc->ste_miibus);
@ -1240,7 +1246,7 @@ static void ste_init(xsc)
printf("ste%d: initialization failed: no "
"memory for RX buffers\n", sc->ste_unit);
ste_stop(sc);
splx(s);
STE_UNLOCK(sc);
return;
}
@ -1312,9 +1318,8 @@ static void ste_init(xsc)
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
splx(s);
sc->ste_stat_ch = timeout(ste_stats_update, sc, hz);
STE_UNLOCK(sc);
return;
}
@ -1325,6 +1330,7 @@ static void ste_stop(sc)
int i;
struct ifnet *ifp;
STE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
untimeout(ste_stats_update, sc, sc->ste_stat_ch);
@ -1354,6 +1360,7 @@ static void ste_stop(sc)
}
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
STE_UNLOCK(sc);
return;
}
@ -1391,11 +1398,10 @@ static int ste_ioctl(ifp, command, data)
struct ste_softc *sc;
struct ifreq *ifr;
struct mii_data *mii;
int error = 0, s;
s = splimp();
int error = 0;
sc = ifp->if_softc;
STE_LOCK(sc);
ifr = (struct ifreq *)data;
switch(command) {
@ -1442,7 +1448,7 @@ static int ste_ioctl(ifp, command, data)
break;
}
splx(s);
STE_UNLOCK(sc);
return(error);
}
@ -1490,12 +1496,17 @@ static void ste_start(ifp)
int idx;
sc = ifp->if_softc;
STE_LOCK(sc);
if (!sc->ste_link)
if (!sc->ste_link) {
STE_UNLOCK(sc);
return;
}
if (ifp->if_flags & IFF_OACTIVE)
if (ifp->if_flags & IFF_OACTIVE) {
STE_UNLOCK(sc);
return;
}
idx = sc->ste_cdata.ste_tx_prod;
start_tx = &sc->ste_cdata.ste_tx_chain[idx];
@ -1530,8 +1541,10 @@ static void ste_start(ifp)
sc->ste_cdata.ste_tx_cnt++;
}
if (cur_tx == NULL)
if (cur_tx == NULL) {
STE_UNLOCK(sc);
return;
}
cur_tx->ste_ptr->ste_ctl |= STE_TXCTL_DMAINTR;
@ -1540,6 +1553,7 @@ static void ste_start(ifp)
start_tx->ste_prev->ste_ptr->ste_next = start_tx->ste_phys;
ifp->if_timer = 5;
STE_UNLOCK(sc);
return;
}
@ -1550,6 +1564,7 @@ static void ste_watchdog(ifp)
struct ste_softc *sc;
sc = ifp->if_softc;
STE_LOCK(sc);
ifp->if_oerrors++;
printf("ste%d: watchdog timeout\n", sc->ste_unit);
@ -1562,6 +1577,7 @@ static void ste_watchdog(ifp)
if (ifp->if_snd.ifq_head != NULL)
ste_start(ifp);
STE_UNLOCK(sc);
return;
}

View File

@ -514,8 +514,12 @@ struct ste_softc {
struct ste_list_data *ste_ldata;
struct ste_chain_data ste_cdata;
struct callout_handle ste_stat_ch;
struct mtx ste_mtx;
};
#define STE_LOCK(_sc) mtx_enter(&(_sc)->ste_mtx, MTX_DEF)
#define STE_UNLOCK(_sc) mtx_exit(&(_sc)->ste_mtx, MTX_DEF)
struct ste_mii_frame {
u_int8_t mii_stdelim;
u_int8_t mii_opcode;

View File

@ -1537,7 +1537,7 @@ static int ti_attach(dev)
goto fail;
}
mtx_init(&sc->ti_mtx, "ti", MTX_DEF);
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
sc->ti_unit = unit;

View File

@ -1245,7 +1245,7 @@ static int tl_attach(dev)
if (t->tl_vid == OLICOM_VENDORID)
sc->tl_eeaddr = TL_EEPROM_EADDR_OC;
mtx_init(&sc->tl_mtx, "tl", MTX_DEF);
mtx_init(&sc->tl_mtx, device_get_nameunit(dev), MTX_DEF);
TL_LOCK(sc);
/* Reset the adapter. */

View File

@ -729,7 +729,7 @@ static int vr_attach(dev)
goto fail;
}
mtx_init(&sc->vr_mtx, "vr", MTX_DEF);
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/* Reset the adapter. */
vr_reset(sc);

View File

@ -907,7 +907,7 @@ static int wb_attach(dev)
/* Save the cache line size. */
sc->wb_cachesize = pci_read_config(dev, WB_PCI_CACHELEN, 4) & 0xFF;
mtx_init(&sc->wb_mtx, "wb", MTX_DEF);
mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_DEF);
WB_LOCK(sc);
/* Reset the adapter. */

View File

@ -1348,7 +1348,7 @@ static int xl_attach(dev)
goto fail;
}
mtx_init(&sc->xl_mtx, "xl", MTX_DEF);
mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_DEF);
XL_LOCK(sc);
/* Reset the adapter. */