[U-Boot] [PATCH] mmc: sdhci: don't invert present state bits

Baruch Siach baruch at tkos.co.il
Tue Jul 23 05:25:15 UTC 2019


The MMC_CAP_CD_ACTIVE_HIGH flag describes the physical card-detect
signal logic level. Applying it to bits in SDHCI_PRESENT_STATE makes no
sense.

Fixes: da18c62b6e6a ("mmc: sdhci: Implement SDHCI card detect")
Cc: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Cc: Michal Simek <michal.simek at xilinx.com>
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
This patch applies on top of http://patchwork.ozlabs.org/patch/1135213/.
---
 drivers/mmc/sdhci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 17a28181fcca..654931a82f54 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -664,7 +664,7 @@ int sdhci_get_cd(struct udevice *dev)
 {
 	struct mmc *mmc = mmc_get_mmc_dev(dev);
 	struct sdhci_host *host = mmc->priv;
-	int value;
+	int __maybe_unused value;
 
 	/* If nonremovable, assume that the card is always present. */
 	if (mmc->cfg->host_caps & MMC_CAP_NONREMOVABLE)
@@ -682,12 +682,9 @@ int sdhci_get_cd(struct udevice *dev)
 			return value;
 	}
 #endif
-	value = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
+
+	return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
 		   (SDHCI_CARD_PRESENT | SDHCI_CARD_DETECT_PIN_LEVEL));
-	if (mmc->cfg->host_caps & MMC_CAP_CD_ACTIVE_HIGH)
-		return !value;
-	else
-		return value;
 }
 
 const struct dm_mmc_ops sdhci_ops = {
-- 
2.20.1



More information about the U-Boot mailing list