mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-of-esdhc: Check for error num after setting mask
@ 2022-01-06  2:16 Jiasheng Jiang
  2022-01-12  7:06 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-06  2:16 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson; +Cc: linux-mmc, linux-kernel, Jiasheng Jiang

Because of the possible failure of the dma_supported(), the
dma_set_mask_and_coherent() may return error num.
Therefore, it should be better to check it and return the error if
fails.
Also, the caller, esdhc_of_resume(), should deal with the return value.
Moreover, as the sdhci_esdhc_driver has not been used, it does not need to
be considered.

Fixes: 5552d7ad596c ("mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/mmc/host/sdhci-of-esdhc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index a593b1fbd69e..bedfc7bb5174 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -524,12 +524,16 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
 
 static int esdhc_of_enable_dma(struct sdhci_host *host)
 {
+	int ret;
 	u32 value;
 	struct device *dev = mmc_dev(host->mmc);
 
 	if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
-	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
-		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+		if (ret)
+			return ret;
+	}
 
 	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
 
@@ -1245,7 +1249,10 @@ static int esdhc_of_resume(struct device *dev)
 
 	if (ret == 0) {
 		/* Isn't this already done by sdhci_resume_host() ? --rmk */
-		esdhc_of_enable_dma(host);
+		ret = esdhc_of_enable_dma(host);
+		if (ret)
+			return ret;
+
 		sdhci_writel(host, esdhc_proctl, SDHCI_HOST_CONTROL);
 	}
 	return ret;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-12  7:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  2:16 [PATCH] mmc: sdhci-of-esdhc: Check for error num after setting mask Jiasheng Jiang
2022-01-12  7:06 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®