mirror of
https://github.com/opnsense/src.git
synced 2026-02-20 00:11:07 -05:00
Prevent multiple lock initialization in e6000sw probe
r319886 ("Add the initial support for the Marvell 88E6141
and 88E6341 switches.") unveiled a problem with possible
multiple lock creation. Move its initialization
to the driver attach and for obtaining the switch ID
create a temprorary one, which is immediately destroyed
after the check.
Submitted by: Zbigniew Bodek <zbb@semihalf.com>
Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
This commit is contained in:
parent
4be4fd5d5f
commit
eb3ffa577b
1 changed files with 8 additions and 3 deletions
|
|
@ -217,11 +217,15 @@ e6000sw_probe(device_t dev)
|
|||
if (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0)
|
||||
sc->multi_chip = true;
|
||||
|
||||
/* Lock is necessary due to assertions. */
|
||||
sx_init(&sc->sx, "e6000sw");
|
||||
/*
|
||||
* Create temporary lock, just to satisfy assertions,
|
||||
* when obtaining the switch ID. Destroy immediately afterwards.
|
||||
*/
|
||||
sx_init(&sc->sx, "e6000sw_tmp");
|
||||
E6000SW_LOCK(sc);
|
||||
id = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID);
|
||||
E6000SW_UNLOCK(sc);
|
||||
sx_destroy(&sc->sx);
|
||||
|
||||
switch (id & 0xfff0) {
|
||||
case 0x3400:
|
||||
|
|
@ -247,7 +251,6 @@ e6000sw_probe(device_t dev)
|
|||
sc->num_ports = 7;
|
||||
break;
|
||||
default:
|
||||
sx_destroy(&sc->sx);
|
||||
device_printf(dev, "Unrecognized device, id 0x%x.\n", id);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
|
@ -355,6 +358,8 @@ e6000sw_attach(device_t dev)
|
|||
else
|
||||
device_printf(dev, "single-chip addressing mode\n");
|
||||
|
||||
sx_init(&sc->sx, "e6000sw");
|
||||
|
||||
E6000SW_LOCK(sc);
|
||||
e6000sw_setup(dev, sc);
|
||||
bzero(member_ports, sizeof(member_ports));
|
||||
|
|
|
|||
Loading…
Reference in a new issue