psm: use make_dev_s instead of make_dev
This most importantly reduces duplication, but it also removes any potential race with usage of dev->si_drv1 since it's now set prior to the device being constructed enough to be accessible.
This commit is contained in:
parent
151905758f
commit
d6c7492676
@ -1948,6 +1948,7 @@ psm_register_elantech(device_t dev)
|
||||
static int
|
||||
psmattach(device_t dev)
|
||||
{
|
||||
struct make_dev_args mda;
|
||||
int unit = device_get_unit(dev);
|
||||
struct psm_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
@ -1969,10 +1970,15 @@ psmattach(device_t dev)
|
||||
goto out;
|
||||
|
||||
/* Done */
|
||||
sc->dev = make_dev(&psm_cdevsw, 0, 0, 0, 0666, "psm%d", unit);
|
||||
sc->dev->si_drv1 = sc;
|
||||
sc->bdev = make_dev(&psm_cdevsw, 0, 0, 0, 0666, "bpsm%d", unit);
|
||||
sc->bdev->si_drv1 = sc;
|
||||
make_dev_args_init(&mda);
|
||||
mda.mda_devsw = &psm_cdevsw;
|
||||
mda.mda_mode = 0666;
|
||||
mda.mda_si_drv1 = sc;
|
||||
|
||||
if ((error = make_dev_s(&mda, &sc->dev, "psm%d", unit)) != 0)
|
||||
goto out;
|
||||
if ((error = make_dev_s(&mda, &sc->bdev, "bpsm%d", unit)) != 0)
|
||||
goto out;
|
||||
|
||||
#ifdef EVDEV_SUPPORT
|
||||
switch (sc->hw.model) {
|
||||
@ -2031,8 +2037,13 @@ psmattach(device_t dev)
|
||||
--verbose;
|
||||
|
||||
out:
|
||||
if (error != 0)
|
||||
if (error != 0) {
|
||||
bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr);
|
||||
if (sc->dev != NULL)
|
||||
destroy_dev(sc->dev);
|
||||
if (sc->bdev != NULL)
|
||||
destroy_dev(sc->bdev);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user