UPSTREAM: ifdtool: promote max_regions as global
max_regions is set to the maximal regions based on the ifd version BUG=None BRANCH=None TEST=None Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-on: https://review.coreboot.org/16934 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@googlemail.com> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Change-Id: I9fa5a4565f4dbd67b5c6df97756311560e2a18bc Reviewed-on: https://chromium-review.googlesource.com/396231 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
e09595d23c
commit
e25e8064a4
1 changed files with 3 additions and 5 deletions
|
|
@ -28,6 +28,7 @@
|
|||
#endif
|
||||
|
||||
static int ifd_version;
|
||||
static int max_regions = 0;
|
||||
static int selected_chip = 0;
|
||||
|
||||
static const struct region_name region_names[MAX_REGIONS] = {
|
||||
|
|
@ -85,9 +86,11 @@ static void check_ifd_version(char *image, int size)
|
|||
switch (read_freq) {
|
||||
case SPI_FREQUENCY_20MHZ:
|
||||
ifd_version = IFD_VERSION_1;
|
||||
max_regions = MAX_REGIONS_OLD;
|
||||
break;
|
||||
case SPI_FREQUENCY_17MHZ:
|
||||
ifd_version = IFD_VERSION_2;
|
||||
max_regions = MAX_REGIONS;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown descriptor version: %d\n",
|
||||
|
|
@ -653,7 +656,6 @@ static void dump_layout(char *image, int size, char *layout_fname)
|
|||
static void write_regions(char *image, int size)
|
||||
{
|
||||
int i;
|
||||
int max_regions = MAX_REGIONS;
|
||||
|
||||
fdbar_t *fdb = find_fd(image, size);
|
||||
if (!fdb)
|
||||
|
|
@ -662,10 +664,6 @@ static void write_regions(char *image, int size)
|
|||
frba_t *frba =
|
||||
(frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
|
||||
|
||||
/* Older descriptor images have fewer regions */
|
||||
if (ifd_version < IFD_VERSION_2)
|
||||
max_regions = MAX_REGIONS_OLD;
|
||||
|
||||
for (i = 0; i < max_regions; i++) {
|
||||
region_t region = get_region(frba, i);
|
||||
dump_region(i, frba);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue