]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles
authorJisheng Zhang <jszhang@marvell.com>
Wed, 28 Jan 2015 11:54:12 +0000 (19:54 +0800)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 24 Feb 2015 10:01:11 +0000 (10:01 +0000)
commit 14460dbaf7a5a0488963fdb8232ad5c8a8cca7b7 upstream.

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>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/mmc/host/sdhci-pxav3.c

index a30f42003fb80a056c4eb113bc64195b69ff2ee8..0c2c12b7149a62ddbcc8d168de51af0f3a1bb382 100644 (file)
@@ -261,8 +261,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;