linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata
@ 2020-09-23 15:37 Krzysztof Kozlowski
  2020-09-23 15:37 ` [PATCH 2/2] mmc: sdhci: fix indentation mistakes Krzysztof Kozlowski
  2020-09-24 12:49 ` [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-23 15:37 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	Orson Zhai, Baolin Wang, Chunyan Zhang, linux-mmc, linux-kernel,
	linux-arm-kernel
  Cc: 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)

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index 2bfb376fddc4..f25079ba3bca 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] mmc: sdhci: fix indentation mistakes
  2020-09-23 15:37 [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Krzysztof Kozlowski
@ 2020-09-23 15:37 ` Krzysztof Kozlowski
  2020-09-24 12:49   ` Ulf Hansson
  2020-09-24 12:49 ` [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-23 15:37 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	Orson Zhai, Baolin Wang, Chunyan Zhang, linux-mmc, linux-kernel,
	linux-arm-kernel
  Cc: 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

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 drivers/mmc/host/sdhci-sprd.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 62b3d4767916..fce8fa7e6b30 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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) {
 			/*
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 1efaf602c206..58109c5b53e2 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata
  2020-09-23 15:37 [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Krzysztof Kozlowski
  2020-09-23 15:37 ` [PATCH 2/2] mmc: sdhci: fix indentation mistakes Krzysztof Kozlowski
@ 2020-09-24 12:49 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-09-24 12:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Shawn Guo, Sascha Hauer, linux-mmc, Adrian Hunter,
	Linux Kernel Mailing List, NXP Linux Team,
	Pengutronix Kernel Team, Chunyan Zhang, Baolin Wang, Orson Zhai,
	Fabio Estevam, Linux ARM

On Wed, 23 Sep 2020 at 17:37, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> 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)
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
> index 2bfb376fddc4..f25079ba3bca 100644
> --- a/drivers/mmc/host/moxart-mmc.c
> +++ b/drivers/mmc/host/moxart-mmc.c
> @@ -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
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] mmc: sdhci: fix indentation mistakes
  2020-09-23 15:37 ` [PATCH 2/2] mmc: sdhci: fix indentation mistakes Krzysztof Kozlowski
@ 2020-09-24 12:49   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-09-24 12:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Shawn Guo, Sascha Hauer, linux-mmc, Adrian Hunter,
	Linux Kernel Mailing List, NXP Linux Team,
	Pengutronix Kernel Team, Chunyan Zhang, Baolin Wang, Orson Zhai,
	Fabio Estevam, Linux ARM

On Wed, 23 Sep 2020 at 17:38, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> 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
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
>  drivers/mmc/host/sdhci-sprd.c      | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 62b3d4767916..fce8fa7e6b30 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -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) {
>                         /*
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index 1efaf602c206..58109c5b53e2 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -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
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-09-24 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 15:37 [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Krzysztof Kozlowski
2020-09-23 15:37 ` [PATCH 2/2] mmc: sdhci: fix indentation mistakes Krzysztof Kozlowski
2020-09-24 12:49   ` Ulf Hansson
2020-09-24 12:49 ` [PATCH 1/2] mmc: moxart: remove unneeded check for drvdata Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).