Commit 612f2dc026548466adf55268b9faaea108b15ec8

Authored by Fabio Estevam
Committed by Stefano Babic
1 parent e37197acad

nitrogen6x: 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.

Cc: Eric Nelson <eric.nelson@boundarydevices.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

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

board/boundary/nitrogen6x/nitrogen6x.c
... ... @@ -302,7 +302,7 @@
302 302  
303 303 int board_mmc_init(bd_t *bis)
304 304 {
305   - s32 status = 0;
  305 + int ret;
306 306 u32 index = 0;
307 307  
308 308 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
309 309  
310 310  
... ... @@ -325,13 +325,15 @@
325 325 printf("Warning: you configured more USDHC controllers"
326 326 "(%d) then supported by the board (%d)\n",
327 327 index + 1, CONFIG_SYS_FSL_USDHC_NUM);
328   - return status;
  328 + return -EINVAL;
329 329 }
330 330  
331   - status |= fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
  331 + ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
  332 + if (ret)
  333 + return ret;
332 334 }
333 335  
334   - return status;
  336 + return 0;
335 337 }
336 338 #endif
337 339