Patchwork [U-Boot,1/2] esdhc: memset mmc struct before putting into use

login
register
mail settings
Submitter Haijun.Zhang
Date Oct. 25, 2013, 1:54 a.m.
Message ID <1382666083-2287-1-git-send-email-Haijun.Zhang@freescale.com>
Download mbox | patch
Permalink /patch/286065/
State Superseded
Delegated to: York Sun
Headers show

Comments

Haijun.Zhang - Oct. 25, 2013, 1:54 a.m.
struct mmc should be clear to all '0' after malloc to avoid
unexpect variable value.

Like mmc->has_init = xxx.
In this case mmcinfo will believe the card had been initialized before
and skip the initialization.

Test on P5040 and T4240,
Error Log:

=> mmcinfo
Device: FSL_SDHC
Manufacturer ID: 0
OEM: 0
Name: Tran Speed: 0
Rd Block Len: 0
MMC version 0.0
High Capacity: No
Capacity: 0 Bytes
Bus Width: 0-bit
=>

Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
Signed-off-by: Xie Shaohui-B21989 <B21989@freescale.com>
---
 drivers/mmc/fsl_esdhc.c | 1 +
 1 file changed, 1 insertion(+)
Ryan Barnett - Oct. 25, 2013, 4:28 p.m.
Haijun Zhang <Haijun.Zhang@freescale.com> wrote on 10/24/2013 08:54:42 PM:

> struct mmc should be clear to all '0' after malloc to avoid
> unexpect variable value.
> 
> Like mmc->has_init = xxx.
> In this case mmcinfo will believe the card had been initialized before
> and skip the initialization.
> 
> Test on P5040 and T4240,
> Error Log:
> 
> => mmcinfo
> Device: FSL_SDHC
> Manufacturer ID: 0
> OEM: 0
> Name: Tran Speed: 0
> Rd Block Len: 0
> MMC version 0.0
> High Capacity: No
> Capacity: 0 Bytes
> Bus Width: 0-bit
> =>
> 
> Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
> Signed-off-by: Xie Shaohui-B21989 <B21989@freescale.com>

Tested-by: Ryan Barnett <rjbarnet@rockwellcollins.com>

Verified that this patch fixes issues related to booting from eSDHC 
interface on the P2041RDB with U-Boot 2013.10.

> ---
>  drivers/mmc/fsl_esdhc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
> index a7170b4..d4c1eef 100644
> --- a/drivers/mmc/fsl_esdhc.c
> +++ b/drivers/mmc/fsl_esdhc.c
> @@ -521,6 +521,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct 
fsl_esdhc_cfg *cfg)
>     if (!mmc)
>        return -ENOMEM;
> 
> +   memset(mmc, 0, sizeof(struct mmc));
>     sprintf(mmc->name, "FSL_SDHC");
>     regs = (struct fsl_esdhc *)cfg->esdhc_base;
> 
> -- 
> 1.8.4
> 
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Patch

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index a7170b4..d4c1eef 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -521,6 +521,7 @@  int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 	if (!mmc)
 		return -ENOMEM;
 
+	memset(mmc, 0, sizeof(struct mmc));
 	sprintf(mmc->name, "FSL_SDHC");
 	regs = (struct fsl_esdhc *)cfg->esdhc_base;