Skip to contentSkip to conversation

mmc: host: Use dev_err_probe instead of dev_err

PATCH Superseded Wang Ming 2 participants 2 messages Jul 26, 2023 – Aug 7, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH v2 1/1 mmc: host: Use dev_err_probe instead of dev_err

It is possible that dma_request_chan will return EPROBE_DEFER, which means that host->dev is not ready yet. In this case, dev_err(host->dev), there will be no output. This patch fixes the bug.

---
 drivers/mmc/host/dw_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +2 -2
index 829af2c98a44..5a3eefd86931 100644
@@ -841,9 +841,9 @@ static int dw_mci_edmac_init(struct dw_mci *host)
 
 	host->dms->ch = dma_request_chan(host->dev, "rx-tx");
 	if (IS_ERR(host->dms->ch)) {
-		int ret = PTR_ERR(host->dms->ch);
+		int ret = dev_err_probe(host->dev, PTR_ERR(host->dms->ch),
+			"Failed to get external DMA channel.\n");
 
-		dev_err(host->dev, "Failed to get external DMA channel.\n");
 		kfree(host->dms);
 		host->dms = NULL;
 		return ret;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Wang Ming

It is possible that dma_request_chan will return EPROBE_DEFER, which means that host->dev is not ready yet. In this case, dev_err(host->dev), there will be no output. This patch fixes the bug.

More exactly, what do you mean by "host->dev is not ready yet"?

Did you really test this?

Kind regards
Uffe

Quoted 25 lines
---
 drivers/mmc/host/dw_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +2 -3
index 829af2c98a44..5a3eefd86931 100644
@@ -841,9 +841,9 @@ static int dw_mci_edmac_init(struct dw_mci *host)
 
        host->dms->ch = dma_request_chan(host->dev, "rx-tx");
        if (IS_ERR(host->dms->ch)) {
-               int ret = PTR_ERR(host->dms->ch);
+               int ret = dev_err_probe(host->dev, PTR_ERR(host->dms->ch),
+                       "Failed to get external DMA channel.\n");
 
-               dev_err(host->dev, "Failed to get external DMA channel.\n");
                kfree(host->dms);
                host->dms = NULL;
                return ret;
--

2.25.1