1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Initialize/grab the mutex earlier in the attach phase, so that

bailing out to the fail: label where we release/destroy the mutex
will work without exploding.
This commit is contained in:
Bill Paul 2000-12-04 22:46:50 +00:00
parent b884490bc0
commit 031fc810ab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69583
17 changed files with 50 additions and 43 deletions

View File

@ -1770,6 +1770,9 @@ static int dc_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct dc_softc));
mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF);
DC_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -1833,8 +1836,6 @@ static int dc_attach(dev)
goto fail;
}
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);
revision = pci_read_config(dev, DC_PCI_CFRV, 4) & 0x000000FF;

View File

@ -679,6 +679,8 @@ static int sf_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct sf_softc));
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -765,8 +767,6 @@ static int sf_attach(dev)
}
callout_handle_init(&sc->sf_stat_ch);
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/* Reset the adapter. */
sf_reset(sc);

View File

@ -1194,6 +1194,9 @@ static int sk_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct sk_softc));
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -1279,8 +1282,6 @@ static int sk_attach(dev)
goto fail;
}
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/* Reset the adapter. */
sk_reset(sc);

View File

@ -1476,6 +1476,9 @@ static int ti_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct ti_softc));
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
/*
* Map control/status registers.
*/
@ -1527,9 +1530,6 @@ static int ti_attach(dev)
goto fail;
}
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
sc->ti_unit = unit;
if (ti_chipinit(sc)) {

View File

@ -643,6 +643,9 @@ static int vr_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct vr_softc *));
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -728,8 +731,6 @@ static int vr_attach(dev)
goto fail;
}
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/* Reset the adapter. */
vr_reset(sc);

View File

@ -1770,6 +1770,9 @@ static int dc_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct dc_softc));
mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF);
DC_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -1833,8 +1836,6 @@ static int dc_attach(dev)
goto fail;
}
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);
revision = pci_read_config(dev, DC_PCI_CFRV, 4) & 0x000000FF;

View File

@ -496,6 +496,10 @@ static int pcn_attach(dev)
sc = device_get_softc(dev);
unit = device_get_unit(dev);
/* Initialize our mutex. */
mtx_init(&sc->pcn_mtx, device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -582,10 +586,6 @@ static int pcn_attach(dev)
goto fail;
}
/* Initialize our mutex. */
mtx_init(&sc->pcn_mtx, device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
/* Reset the adapter. */
pcn_reset(sc);

View File

@ -802,6 +802,9 @@ static int rl_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct rl_softc));
mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_DEF);
RL_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -899,9 +902,6 @@ static int rl_attach(dev)
callout_handle_init(&sc->rl_stat_ch);
mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_DEF);
RL_LOCK(sc);
/* Reset the adapter. */
rl_reset(sc);
sc->rl_eecmd_read = RL_EECMD_READ_6BIT;

View File

@ -679,6 +679,8 @@ static int sf_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct sf_softc));
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -765,8 +767,6 @@ static int sf_attach(dev)
}
callout_handle_init(&sc->sf_stat_ch);
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF);
SF_LOCK(sc);
/* Reset the adapter. */
sf_reset(sc);

View File

@ -638,6 +638,9 @@ static int sis_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct sis_softc));
mtx_init(&sc->sis_mtx, device_get_nameunit(dev), MTX_DEF);
SIS_LOCK(sc);
if (pci_get_device(dev) == SIS_DEVICEID_900)
sc->sis_type = SIS_TYPE_900;
if (pci_get_device(dev) == SIS_DEVICEID_7016)
@ -731,9 +734,6 @@ static int sis_attach(dev)
goto fail;
}
mtx_init(&sc->sis_mtx, device_get_nameunit(dev), MTX_DEF);
SIS_LOCK(sc);
/* Reset the adapter. */
sis_reset(sc);

View File

@ -1194,6 +1194,9 @@ static int sk_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct sk_softc));
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -1279,8 +1282,6 @@ static int sk_attach(dev)
goto fail;
}
mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF);
SK_LOCK(sc);
/* Reset the adapter. */
sk_reset(sc);

View File

@ -917,6 +917,9 @@ static int ste_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct ste_softc));
mtx_init(&sc->ste_mtx, device_get_nameunit(dev), MTX_DEF);
STE_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -1002,8 +1005,6 @@ 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);

View File

@ -1476,6 +1476,9 @@ static int ti_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct ti_softc));
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
/*
* Map control/status registers.
*/
@ -1527,9 +1530,6 @@ static int ti_attach(dev)
goto fail;
}
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF);
TI_LOCK(sc);
sc->ti_unit = unit;
if (ti_chipinit(sc)) {

View File

@ -1132,6 +1132,9 @@ static int tl_attach(dev)
goto fail;
}
mtx_init(&sc->tl_mtx, device_get_nameunit(dev), MTX_DEF);
TL_LOCK(sc);
/*
* Map control/status registers.
*/
@ -1244,9 +1247,6 @@ static int tl_attach(dev)
if (t->tl_vid == OLICOM_VENDORID)
sc->tl_eeaddr = TL_EEPROM_EADDR_OC;
mtx_init(&sc->tl_mtx, device_get_nameunit(dev), MTX_DEF);
TL_LOCK(sc);
/* Reset the adapter. */
tl_softreset(sc, 1);
tl_hardreset(dev);

View File

@ -643,6 +643,9 @@ static int vr_attach(dev)
unit = device_get_unit(dev);
bzero(sc, sizeof(struct vr_softc *));
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -728,8 +731,6 @@ static int vr_attach(dev)
goto fail;
}
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF);
VR_LOCK(sc);
/* Reset the adapter. */
vr_reset(sc);

View File

@ -817,6 +817,9 @@ static int wb_attach(dev)
sc = device_get_softc(dev);
unit = device_get_unit(dev);
mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_DEF);
WB_LOCK(sc);
/*
* Handle power management nonsense.
*/
@ -906,9 +909,6 @@ 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, device_get_nameunit(dev), MTX_DEF);
WB_LOCK(sc);
/* Reset the adapter. */
wb_reset(sc);

View File

@ -1239,6 +1239,9 @@ static int xl_attach(dev)
sc = device_get_softc(dev);
unit = device_get_unit(dev);
mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_DEF);
XL_LOCK(sc);
sc->xl_flags = 0;
if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_556 ||
pci_get_device(dev) == TC_DEVICEID_HURRICANE_556B)
@ -1382,9 +1385,6 @@ static int xl_attach(dev)
goto fail;
}
mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_DEF);
XL_LOCK(sc);
/* Reset the adapter. */
xl_reset(sc);