Commit d6af507d5a568289a90984541e1b5971ede5cc9c

Authored by Fabio Estevam
Committed by Stefano Babic
1 parent 6c920ee910

mx51evk: Fix error handling in board_mmc_init()

When an invalid USDHC port is passed we should return -EINVAL instead of 0.

Also, return the error immediately on fsl_esdhc_initialize() failure.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

board/freescale/mx51evk/mx51evk.c
... ... @@ -320,7 +320,7 @@
320 320 };
321 321  
322 322 u32 index;
323   - s32 status = 0;
  323 + int ret;
324 324  
325 325 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
326 326 esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
327 327  
328 328  
... ... @@ -340,11 +340,13 @@
340 340 printf("Warning: you configured more ESDHC controller"
341 341 "(%d) as supported by the board(2)\n",
342 342 CONFIG_SYS_FSL_ESDHC_NUM);
343   - return status;
  343 + return -EINVAL;
344 344 }
345   - status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
  345 + ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
  346 + if (ret)
  347 + return ret;
346 348 }
347   - return status;
  349 + return 0;
348 350 }
349 351 #endif
350 352