LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles
@ 2015-01-28  6:57 Jisheng Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2015-01-28  6:57 UTC (permalink / raw)
  To: chris, ulf.hansson, sebastian.hesselbarth
  Cc: thomas.petazzoni, linux-mmc, linux-kernel, Jisheng Zhang, stable

Current code checks "clk_delay_cycles > 0" to know whether the optional
"mrvl,clk_delay_cycles" is set or not. But of_property_read_u32() doesn't
touch clk_delay_cycles if the property is not set. And type of
clk_delay_cycles is u32, so we may always set pdata->clk_delay_cycles as a
random value.

This patch fix this problem by check the return value of of_property_read_u32()
to know whether the optional clk-delay-cycles is set or not.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Cc: <stable@vger.kernel.org> # v3.6+
---
 drivers/mmc/host/sdhci-pxav3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index c5db5d2..f1c6362 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -268,8 +268,8 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
 	if (!pdata)
 		return NULL;
 
-	of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
-	if (clk_delay_cycles > 0)
+	if (!of_property_read_u32(np, "mrvl,clk-delay-cycles",
+				  &clk_delay_cycles))
 		pdata->clk_delay_cycles = clk_delay_cycles;
 
 	return pdata;
-- 
2.1.4


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

* Re: [PATCH] mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles
  2015-01-28 11:54 Jisheng Zhang
@ 2015-01-29 10:27 ` Ulf Hansson
  0 siblings, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2015-01-29 10:27 UTC (permalink / raw)
  To: Jisheng Zhang
  Cc: Chris Ball, Sebastian Hesselbarth, Thomas Petazzoni, linux-mmc,
	linux-kernel, linux-arm-kernel, stable

On 28 January 2015 at 12:54, Jisheng Zhang <jszhang@marvell.com> wrote:
> Current code checks "clk_delay_cycles > 0" to know whether the optional
> "mrvl,clk_delay_cycles" is set or not. But of_property_read_u32() doesn't
> touch clk_delay_cycles if the property is not set. And type of
> clk_delay_cycles is u32, so we may always set pdata->clk_delay_cycles as a
> random value.
>
> This patch fix this problem by check the return value of of_property_read_u32()
> to know whether the optional clk-delay-cycles is set or not.
>
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> Cc: <stable@vger.kernel.org> # v3.6+

Thanks! Applied for next.

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-pxav3.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
> index c5db5d2..f1c6362 100644
> --- a/drivers/mmc/host/sdhci-pxav3.c
> +++ b/drivers/mmc/host/sdhci-pxav3.c
> @@ -268,8 +268,8 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
>         if (!pdata)
>                 return NULL;
>
> -       of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
> -       if (clk_delay_cycles > 0)
> +       if (!of_property_read_u32(np, "mrvl,clk-delay-cycles",
> +                                 &clk_delay_cycles))
>                 pdata->clk_delay_cycles = clk_delay_cycles;
>
>         return pdata;
> --
> 2.1.4
>

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

* [PATCH] mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles
@ 2015-01-28 11:54 Jisheng Zhang
  2015-01-29 10:27 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Jisheng Zhang @ 2015-01-28 11:54 UTC (permalink / raw)
  To: chris, ulf.hansson, sebastian.hesselbarth
  Cc: thomas.petazzoni, linux-mmc, linux-kernel, linux-arm-kernel,
	Jisheng Zhang, stable

Current code checks "clk_delay_cycles > 0" to know whether the optional
"mrvl,clk_delay_cycles" is set or not. But of_property_read_u32() doesn't
touch clk_delay_cycles if the property is not set. And type of
clk_delay_cycles is u32, so we may always set pdata->clk_delay_cycles as a
random value.

This patch fix this problem by check the return value of of_property_read_u32()
to know whether the optional clk-delay-cycles is set or not.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Cc: <stable@vger.kernel.org> # v3.6+
---
 drivers/mmc/host/sdhci-pxav3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index c5db5d2..f1c6362 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -268,8 +268,8 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
 	if (!pdata)
 		return NULL;
 
-	of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
-	if (clk_delay_cycles > 0)
+	if (!of_property_read_u32(np, "mrvl,clk-delay-cycles",
+				  &clk_delay_cycles))
 		pdata->clk_delay_cycles = clk_delay_cycles;
 
 	return pdata;
-- 
2.1.4


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

end of thread, other threads:[~2015-01-29 10:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28  6:57 [PATCH] mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles Jisheng Zhang
2015-01-28 11:54 Jisheng Zhang
2015-01-29 10:27 ` 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).