In detach(), check for failure of bus_generic_detach(), only release

resources if they got allocated (because detach() gets called from attach()
to handle various failures), and delete the pwmbus child if it got created.
This commit is contained in:
Ian Lepore 2019-06-15 16:36:29 +00:00
parent dd47326c82
commit 5ef9c1079e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349058

View File

@ -192,12 +192,20 @@ static int
aw_pwm_detach(device_t dev)
{
struct aw_pwm_softc *sc;
int error;
sc = device_get_softc(dev);
bus_generic_detach(sc->dev);
if (((error = bus_generic_detach(sc->dev)) != 0) {
device_printf(sc->dev, "cannot detach child devices\n");
return (error);
}
bus_release_resources(dev, aw_pwm_spec, &sc->res);
if (sc->busdev != NULL)
device_delete_child(dev, sc->busdev);
if (sc->res != NULL)
bus_release_resources(dev, aw_pwm_spec, &sc->res);
return (0);
}