spl: mmc: Fix compiler warning with CONFIG_DM_MMC
authorSimon Glass <sjg@chromium.org>
Wed, 2 Dec 2015 17:59:11 +0000 (10:59 -0700)
committerTom Rini <trini@konsulko.com>
Sat, 5 Dec 2015 23:22:33 +0000 (18:22 -0500)
Since commit 4188ba3 we get the following warning on rockchip boards:

common/spl/spl_mmc.c:31:24: warning: ‘mmc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  count = mmc->block_dev.block_read(0, sector, 1, header);
                        ^
common/spl/spl_mmc.c:251:14: note: ‘mmc’ was declared here
  struct mmc *mmc;

Correct this by move the variable init earlier.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Nikita Kiryanov <nikita@compulab.co.il>
common/spl/spl_mmc.c

index b3c2c642e4ab7f8387ddec80906b103d2ade936d..43748d05b28ee962e310b36b9ab0baa9a732605e 100644 (file)
@@ -248,7 +248,7 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 
 int spl_mmc_load_image(u32 boot_device)
 {
-       struct mmc *mmc;
+       struct mmc *mmc = NULL;
        u32 boot_mode;
        int err = 0;
        __maybe_unused int part;