summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2013-05-15 09:36:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-05-17 07:39:39 +0200
commit87f6faa4508c8e66a828ccf425663375ca681017 (patch)
tree641dcfcf64a4c915e446de03ead80777ee3ee286 /scripts
parent2434ae9f50c0b83afebe46e6578753c7e39818a3 (diff)
downloadbarebox-87f6faa4508c8e66a828ccf425663375ca681017.tar.gz
barebox-87f6faa4508c8e66a828ccf425663375ca681017.tar.xz
scripts/kwbimage: add a new function image_count_options()
This function returns the number of configuration elements that match a given type. Will be used to do some sanity checking of the number of options. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kwbimage.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 14b35e7818..0d5dcac31e 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -259,6 +259,20 @@ image_find_option(struct image_cfg_element *image_cfg,
return NULL;
}
+static unsigned int
+image_count_options(struct image_cfg_element *image_cfg,
+ int cfgn, unsigned int optiontype)
+{
+ int i;
+ unsigned int count = 0;
+
+ for (i = 0; i < cfgn; i++)
+ if (image_cfg[i].type == optiontype)
+ count++;
+
+ return count;
+}
+
/*
* Compute a 8-bit checksum of a memory area. This algorithm follows
* the requirements of the Marvell SoC BootROM specifications.