Check for errors from bus_generic_detach in various drivers
In some cases, move the call to bus_generic_detach earlier so that any detach failures from child devices do not leave the parent device partially detached. Differential Revision: https://reviews.freebsd.org/D47966
This commit is contained in:
@@ -417,8 +417,12 @@ tegra_sdhci_detach(device_t dev)
|
||||
{
|
||||
struct tegra_sdhci_softc *sc = device_get_softc(dev);
|
||||
struct sdhci_slot *slot = &sc->slot;
|
||||
int error;
|
||||
|
||||
error = bus_detach_children(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
bus_detach_children(dev);
|
||||
sdhci_fdt_gpio_teardown(sc->gpio);
|
||||
clk_release(sc->clk);
|
||||
bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie);
|
||||
|
||||
@@ -1085,6 +1085,11 @@ static int
|
||||
cpswp_detach(device_t dev)
|
||||
{
|
||||
struct cpswp_softc *sc;
|
||||
int error;
|
||||
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
CPSW_DEBUGF(sc->swsc, (""));
|
||||
@@ -1096,8 +1101,6 @@ cpswp_detach(device_t dev)
|
||||
callout_drain(&sc->mii_callout);
|
||||
}
|
||||
|
||||
bus_generic_detach(dev);
|
||||
|
||||
if_free(sc->ifp);
|
||||
mtx_destroy(&sc->lock);
|
||||
|
||||
|
||||
+5
-2
@@ -273,6 +273,11 @@ static int
|
||||
ti_spi_detach(device_t dev)
|
||||
{
|
||||
struct ti_spi_softc *sc;
|
||||
int error;
|
||||
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
@@ -283,8 +288,6 @@ ti_spi_detach(device_t dev)
|
||||
/* Reset controller. */
|
||||
TI_SPI_WRITE(sc, MCSPI_SYSCONFIG, MCSPI_SYSCONFIG_SOFTRESET);
|
||||
|
||||
bus_generic_detach(dev);
|
||||
|
||||
mtx_destroy(&sc->sc_mtx);
|
||||
if (sc->sc_intrhand)
|
||||
bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
|
||||
|
||||
@@ -791,15 +791,17 @@ static int
|
||||
zy7_devcfg_detach(device_t dev)
|
||||
{
|
||||
struct zy7_devcfg_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
if (sc->sysctl_tree_top != NULL) {
|
||||
sysctl_ctx_free(&sc->sysctl_tree);
|
||||
sc->sysctl_tree_top = NULL;
|
||||
}
|
||||
|
||||
if (device_is_attached(dev))
|
||||
bus_generic_detach(dev);
|
||||
|
||||
/* Get rid of /dev/devcfg0. */
|
||||
if (sc->sc_ctl_dev != NULL)
|
||||
destroy_dev(sc->sc_ctl_dev);
|
||||
|
||||
@@ -612,9 +612,11 @@ static int
|
||||
zy7_qspi_detach(device_t dev)
|
||||
{
|
||||
struct zy7_qspi_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
|
||||
if (device_is_attached(dev))
|
||||
bus_generic_detach(dev);
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/* Disable hardware. */
|
||||
if (sc->mem_res != NULL) {
|
||||
|
||||
@@ -673,8 +673,11 @@ static int
|
||||
zy7_slcr_detach(device_t dev)
|
||||
{
|
||||
struct zy7_slcr_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
|
||||
bus_generic_detach(dev);
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/* Release memory resource. */
|
||||
if (sc->mem_res != NULL)
|
||||
|
||||
@@ -448,9 +448,11 @@ static int
|
||||
zy7_spi_detach(device_t dev)
|
||||
{
|
||||
struct zy7_spi_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
|
||||
if (device_is_attached(dev))
|
||||
bus_generic_detach(dev);
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/* Disable hardware. */
|
||||
if (sc->mem_res != NULL) {
|
||||
|
||||
@@ -480,9 +480,10 @@ felix_detach(device_t dev)
|
||||
int error;
|
||||
int i;
|
||||
|
||||
error = 0;
|
||||
sc = device_get_softc(dev);
|
||||
bus_generic_detach(dev);
|
||||
error = bus_generic_detach(dev);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
mtx_lock(&sc->mtx);
|
||||
callout_stop(&sc->tick_callout);
|
||||
|
||||
Reference in New Issue
Block a user