Skip to contentSkip to conversation

mmc: moxart: remove unneeded check for drvdata

PATCH In review Krzysztof Kozlowski 2 participants 4 messages Sep 23, 2020 – Sep 24, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mmc: moxart: remove unneeded check for drvdata

The 'struct mmc_host *mmc' comes from drvdata set at the end of probe, so it cannot be NULL. The code already dereferences it few lines before the check with mmc_priv(). This also fixes smatch warning:

drivers/mmc/host/moxart-mmc.c:692 moxart_remove() warn: variable dereferenced before check 'mmc' (see line 688)

---
 drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/mmc/host/moxart-mmc.c +11 -12
index 2bfb376fddc4..f25079ba3bca 100644
@@ -689,19 +689,18 @@ static int moxart_remove(struct platform_device *pdev)
 
 	dev_set_drvdata(&pdev->dev, NULL);
 
-	if (mmc) {
-		if (!IS_ERR(host->dma_chan_tx))
-			dma_release_channel(host->dma_chan_tx);
-		if (!IS_ERR(host->dma_chan_rx))
-			dma_release_channel(host->dma_chan_rx);
-		mmc_remove_host(mmc);
-		mmc_free_host(mmc);
+	if (!IS_ERR(host->dma_chan_tx))
+		dma_release_channel(host->dma_chan_tx);
+	if (!IS_ERR(host->dma_chan_rx))
+		dma_release_channel(host->dma_chan_rx);
+	mmc_remove_host(mmc);
+	mmc_free_host(mmc);
+
+	writel(0, host->base + REG_INTERRUPT_MASK);
+	writel(0, host->base + REG_POWER_CONTROL);
+	writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
+	       host->base + REG_CLOCK_CONTROL);
 
-		writel(0, host->base + REG_INTERRUPT_MASK);
-		writel(0, host->base + REG_POWER_CONTROL);
-		writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
-		       host->base + REG_CLOCK_CONTROL);
-	}
 	return 0;
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 mmc: sdhci: fix indentation mistakes

Fix inconsistent indenting, reported by Smatch:

drivers/mmc/host/sdhci-esdhc-imx.c:1380 sdhci_esdhc_imx_hwinit() warn: inconsistent indenting drivers/mmc/host/sdhci-sprd.c:390 sdhci_sprd_request_done() warn: inconsistent indenting

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 drivers/mmc/host/sdhci-sprd.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 62b3d4767916..fce8fa7e6b30 100644
@@ -1377,7 +1377,7 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
 			 * response, block the tuning procedure or the first command
 			 * after the whole tuning procedure always can't get any response.
 			 */
-			 tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
+			tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
 			writel(tmp, host->ioaddr + ESDHC_TUNING_CTRL);
 		} else if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
 			/*
drivers/mmc/host/sdhci-sprd.c +2 -2
index 1efaf602c206..58109c5b53e2 100644
@@ -387,7 +387,7 @@ static void sdhci_sprd_request_done(struct sdhci_host *host,
 	if (mmc_hsq_finalize_request(host->mmc, mrq))
 		return;
 
-	 mmc_request_done(host->mmc, mrq);
+	mmc_request_done(host->mmc, mrq);
 }
 
 static struct sdhci_ops sdhci_sprd_ops = {
@@ -433,7 +433,7 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
 }
 
 static int sdhci_sprd_request_atomic(struct mmc_host *mmc,
-				      struct mmc_request *mrq)
+				     struct mmc_request *mrq)
 {
 	sdhci_sprd_check_auto_cmd23(mmc, mrq);
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/2] mmc: sdhci: fix indentation mistakes

Quoted 9 lines · Krzysztof Kozlowski

Fix inconsistent indenting, reported by Smatch:

drivers/mmc/host/sdhci-esdhc-imx.c:1380 sdhci_esdhc_imx_hwinit() warn: inconsistent indenting drivers/mmc/host/sdhci-sprd.c:390 sdhci_sprd_request_done() warn: inconsistent indenting

Applied for next, thanks!

Kind regards
Uffe

Quoted 43 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 drivers/mmc/host/sdhci-sprd.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 62b3d4767916..fce8fa7e6b30 100644
@@ -1377,7 +1377,7 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
                         * response, block the tuning procedure or the first command
                         * after the whole tuning procedure always can't get any response.
                         */
-                        tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
+                       tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
                        writel(tmp, host->ioaddr + ESDHC_TUNING_CTRL);
                } else if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
                        /*
drivers/mmc/host/sdhci-sprd.c +2 -3
index 1efaf602c206..58109c5b53e2 100644
@@ -387,7 +387,7 @@ static void sdhci_sprd_request_done(struct sdhci_host *host,
        if (mmc_hsq_finalize_request(host->mmc, mrq))
                return;
 
-        mmc_request_done(host->mmc, mrq);
+       mmc_request_done(host->mmc, mrq);
 }
 
 static struct sdhci_ops sdhci_sprd_ops = {
@@ -433,7 +433,7 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
 }
 
 static int sdhci_sprd_request_atomic(struct mmc_host *mmc,
-                                     struct mmc_request *mrq)
+                                    struct mmc_request *mrq)
 {
        sdhci_sprd_check_auto_cmd23(mmc, mrq);
 
--

2.17.1

#3 lore raw
In reply to Krzysztof Kozlowski
Quoted 10 lines · Krzysztof Kozlowski

The 'struct mmc_host *mmc' comes from drvdata set at the end of probe, so it cannot be NULL. The code already dereferences it few lines before the check with mmc_priv(). This also fixes smatch warning:

drivers/mmc/host/moxart-mmc.c:692 moxart_remove() warn: variable dereferenced before check 'mmc' (see line 688)

Applied for next, thanks!

Kind regards
Uffe

Quoted 42 lines
---
 drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/mmc/host/moxart-mmc.c +11 -13
index 2bfb376fddc4..f25079ba3bca 100644
@@ -689,19 +689,18 @@ static int moxart_remove(struct platform_device *pdev)
 
        dev_set_drvdata(&pdev->dev, NULL);
 
-       if (mmc) {
-               if (!IS_ERR(host->dma_chan_tx))
-                       dma_release_channel(host->dma_chan_tx);
-               if (!IS_ERR(host->dma_chan_rx))
-                       dma_release_channel(host->dma_chan_rx);
-               mmc_remove_host(mmc);
-               mmc_free_host(mmc);
+       if (!IS_ERR(host->dma_chan_tx))
+               dma_release_channel(host->dma_chan_tx);
+       if (!IS_ERR(host->dma_chan_rx))
+               dma_release_channel(host->dma_chan_rx);
+       mmc_remove_host(mmc);
+       mmc_free_host(mmc);
+
+       writel(0, host->base + REG_INTERRUPT_MASK);
+       writel(0, host->base + REG_POWER_CONTROL);
+       writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
+              host->base + REG_CLOCK_CONTROL);
 
-               writel(0, host->base + REG_INTERRUPT_MASK);
-               writel(0, host->base + REG_POWER_CONTROL);
-               writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
-                      host->base + REG_CLOCK_CONTROL);
-       }
        return 0;
 }
 
--

2.17.1