Don't call sdhci_cleanup_slot() if sdhci_init_slot() never got called.

Also, do callout_init() very early in attach, so that callout_drain()
can be called in detach without worrying about whether it ever got init'd.
This commit is contained in:
Ian Lepore 2018-02-17 23:39:10 +00:00
parent 47d67d2451
commit 02b84ad865
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329480

View File

@ -92,6 +92,7 @@ struct fsl_sdhci_softc {
uint16_t sdclockreg_freq_bits;
uint8_t r1bfix_type;
uint8_t hwtype;
bool slot_init_done;
};
#define R1BFIX_NONE 0 /* No fix needed at next interrupt. */
@ -810,6 +811,9 @@ fsl_sdhci_detach(device_t dev)
callout_drain(&sc->r1bfix_callout);
if (sc->slot_init_done)
sdhci_cleanup_slot(&sc->slot);
if (sc->intr_cookie != NULL)
bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie);
if (sc->irq_res != NULL)
@ -817,7 +821,6 @@ fsl_sdhci_detach(device_t dev)
rman_get_rid(sc->irq_res), sc->irq_res);
if (sc->mem_res != NULL) {
sdhci_cleanup_slot(&sc->slot);
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->mem_res), sc->mem_res);
}
@ -837,6 +840,8 @@ fsl_sdhci_attach(device_t dev)
sc->dev = dev;
callout_init(&sc->r1bfix_callout, 1);
sc->hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
if (sc->hwtype == HWTYPE_NONE)
panic("Impossible: not compatible in fsl_sdhci_attach()");
@ -924,8 +929,8 @@ fsl_sdhci_attach(device_t dev)
WR4(sc, SDHC_PROT_CTRL, protctl);
#endif
callout_init(&sc->r1bfix_callout, 1);
sdhci_init_slot(dev, &sc->slot, 0);
sc->slot_init_done = true;
bus_generic_probe(dev);
bus_generic_attach(dev);