[U-Boot] [PATCH 3/5][repost] tools: mkimage: Making table_entry code global

Prafulla Wadaskar prafulla at marvell.com
Mon Sep 7 11:29:08 CEST 2009


1. get_table_entry_id API made global
2. get_table_entry_name API made global
3. struct table_entry moved to image.h

Currently it is used by image.c only
These APIs are very usefull and can be used by other part of code

This patch makes these APIs and struct global

Signed-off-by: Prafulla Wadaskar <prafulla at marvell.com>
Acked-by: Ron Lee <ron.debian.org>
---
 common/image.c  |   10 ++--------
 include/image.h |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/common/image.c b/common/image.c
index ca8205c..e8ecfa5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -74,12 +74,6 @@ static const image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
 #include <image.h>
 #endif /* !USE_HOSTCC*/
 
-typedef struct table_entry {
-	int	id;		/* as defined in image.h	*/
-	char	*sname;		/* short (input) name		*/
-	char	*lname;		/* long (output) name		*/
-} table_entry_t;
-
 static table_entry_t uimage_arch[] = {
 	{	IH_ARCH_INVALID,	NULL,		"Invalid ARCH",	},
 	{	IH_ARCH_ALPHA,		"alpha",	"Alpha",	},
@@ -514,7 +508,7 @@ static void genimg_print_time (time_t timestamp)
  *     long entry name if translation succeeds
  *     msg otherwise
  */
-static char *get_table_entry_name (table_entry_t *table, char *msg, int id)
+char *get_table_entry_name (table_entry_t *table, char *msg, int id)
 {
 	for (; table->id >= 0; ++table) {
 		if (table->id == id)
@@ -561,7 +555,7 @@ const char *genimg_get_comp_name (uint8_t comp)
  *     entry id if translation succeeds
  *     -1 otherwise
  */
-static int get_table_entry_id (table_entry_t *table,
+int get_table_entry_id (table_entry_t *table,
 		const char *table_name, const char *name)
 {
 	table_entry_t *t;
diff --git a/include/image.h b/include/image.h
index 4a7bf78..58f13f9 100644
--- a/include/image.h
+++ b/include/image.h
@@ -284,6 +284,32 @@ typedef struct bootm_headers {
 #define uimage_to_cpu(x)		be32_to_cpu(x)
 #define cpu_to_uimage(x)		cpu_to_be32(x)
 
+/*
+ * Translation table for entries of a specific type
+ * This structue is used by the global functions get_table_entry_id,
+ * get_table_entry_name and these functions and this structure can also be
+ * referred by other part of code
+ */
+typedef struct table_entry {
+	int	id;
+	char	*sname;		/* name used to find table entry */
+	char	*lname;		/* name used to print for messages */
+} table_entry_t;
+
+/*
+ * get_table_entry_id() will go over translation table trying to find
+ * entry that matches given short name. If matching entry is found,
+ * its id returned to the caller.
+ */
+int get_table_entry_id (table_entry_t *table,
+		const char *table_name, const char *name);
+/*
+ * get_table_entry_name() will go over translation table trying to find
+ * entry that matches given id. If matching entry is found, its long
+ * name is returned to the caller.
+ */
+char *get_table_entry_name (table_entry_t *table, char *msg, int id);
+
 const char *genimg_get_os_name (uint8_t os);
 const char *genimg_get_arch_name (uint8_t arch);
 const char *genimg_get_type_name (uint8_t type);
-- 
1.5.3.3



More information about the U-Boot mailing list