From 645c48f50eab307a9879a82c4d066e74114ec78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 29 May 2015 16:55:41 +0200 Subject: sunxi: Create helper function veryfing valid boot signature on MMC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch extracts checking for valid SD card "eGON.BT0" signature from `board_mmc_init` into function `sunxi_mmc_has_egon_boot_signature`. Buffer for mmc sector is allocated and freed at runtime. `panic` is triggered on malloc failure. Signed-off-by: Daniel KochmaƄski CC: Roy Spliet Cc: Ian Campbell [hdegoede@redhat.com: Small bugfix to make it work for devs other then mmc0] Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- board/sunxi/board.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'board') diff --git a/board/sunxi/board.c b/board/sunxi/board.c index ed60e74808..76e4b9bcc1 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -299,12 +299,8 @@ int board_mmc_init(bd_t *bis) * Both mmc0 and mmc2 are bootable, figure out where we're booting * from. Try mmc0 first, just like the brom does. */ - if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 && - mmc0->block_dev.block_read(0, 16, 1, buf) == 1) { - buf[12] = 0; - if (strcmp(&buf[4], "eGON.BT0") == 0) - return 0; - } + if (sunxi_mmc_has_egon_boot_signature(mmc0)) + return 0; /* no bootable card in mmc0, so we must be booting from mmc2, swap */ mmc0->block_dev.dev = 1; -- cgit v1.2.1