Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Feb 2018 23:39:10 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329480 - head/sys/dev/sdhci
Message-ID:  <201802172339.w1HNdAB0036367@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat Feb 17 23:39:10 2018
New Revision: 329480
URL: https://svnweb.freebsd.org/changeset/base/329480

Log:
  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.

Modified:
  head/sys/dev/sdhci/fsl_sdhci.c

Modified: head/sys/dev/sdhci/fsl_sdhci.c
==============================================================================
--- head/sys/dev/sdhci/fsl_sdhci.c	Sat Feb 17 23:23:27 2018	(r329479)
+++ head/sys/dev/sdhci/fsl_sdhci.c	Sat Feb 17 23:39:10 2018	(r329480)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802172339.w1HNdAB0036367>