X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fflash.c;h=781cb9c4a2e0edef319de5506ee4546214b4c5df;hb=2b21ec92afd8f1809d55beb6044d9faabb4acae1;hp=eb4b2f5ff1cb8a7a841c9758d078dd8810847207;hpb=50bd0057ba8fceeb48533f8b1a652ccd0e170838;p=u-boot diff --git a/common/flash.c b/common/flash.c index eb4b2f5ff1..781cb9c4a2 100644 --- a/common/flash.c +++ b/common/flash.c @@ -27,6 +27,7 @@ #include #if !defined(CONFIG_SYS_NO_FLASH) +#include extern flash_info_t flash_info[]; /* info for FLASH chips */ @@ -43,15 +44,18 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ void flash_protect (int flag, ulong from, ulong to, flash_info_t *info) { - ulong b_end = info->start[0] + info->size - 1; /* bank end address */ - short s_end = info->sector_count - 1; /* index of last sector */ + ulong b_end; + short s_end; int i; /* Do nothing if input data is bad. */ - if (info->sector_count == 0 || info->size == 0 || to < from) { + if (!info || info->sector_count == 0 || info->size == 0 || to < from) { return; } + s_end = info->sector_count - 1; /* index of last sector */ + b_end = info->start[0] + info->size - 1; /* bank end address */ + debug ("flash_protect %s: from 0x%08lX to 0x%08lX\n", (flag & FLAG_PROTECT_SET) ? "ON" : (flag & FLAG_PROTECT_CLEAR) ? "OFF" : "???",