diff mbox

[U-Boot,08/14] image: Create a table of information for each category

Message ID 1467305540-13607-9-git-send-email-sjg@chromium.org
State Accepted
Commit 56d7ab74767c60c4ec48061864df0c421e4799e7
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass June 30, 2016, 4:52 p.m. UTC
Add a table that contains the category name, the number of items in each
category and a pointer to the table of items. This will allow us to use
generic code to deal with the categories.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/image.c  | 13 +++++++++++++
 include/image.h |  9 +++++++++
 2 files changed, 22 insertions(+)

Comments

Tom Rini July 2, 2016, 1:36 a.m. UTC | #1
On Thu, Jun 30, 2016 at 10:52:14AM -0600, Simon Glass wrote:

> Add a table that contains the category name, the number of items in each
> category and a pointer to the table of items. This will allow us to use
> generic code to deal with the categories.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini July 16, 2016, 1:48 p.m. UTC | #2
On Thu, Jun 30, 2016 at 10:52:14AM -0600, Simon Glass wrote:

> Add a table that contains the category name, the number of items in each
> category and a pointer to the table of items. This will allow us to use
> generic code to deal with the categories.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/image.c b/common/image.c
index 0be09e5..4e503b3 100644
--- a/common/image.c
+++ b/common/image.c
@@ -176,6 +176,19 @@  static const table_entry_t uimage_comp[] = {
 	{	-1,		"",		"",			},
 };
 
+struct table_info {
+	const char *desc;
+	int count;
+	const table_entry_t *table;
+};
+
+static const struct table_info table_info[IH_COUNT] = {
+	{ "architecture", IH_ARCH_COUNT, uimage_arch },
+	{ "compression", IH_COMP_COUNT, uimage_comp },
+	{ "operating system", IH_OS_COUNT, uimage_os },
+	{ "image type", IH_TYPE_COUNT, uimage_type },
+};
+
 /*****************************************************************************/
 /* Legacy format routines */
 /*****************************************************************************/
diff --git a/include/image.h b/include/image.h
index 7717b3d..c5b691a 100644
--- a/include/image.h
+++ b/include/image.h
@@ -123,6 +123,15 @@  struct lmb;
 # define IMAGE_OF_SYSTEM_SETUP	0
 #endif
 
+enum ih_category {
+	IH_ARCH,
+	IH_COMP,
+	IH_OS,
+	IH_TYPE,
+
+	IH_COUNT,
+};
+
 /*
  * Operating System Codes
  */