Skip to contentSkip to conversation

image: Add a function to modify category information

PATCH New Naoki Hayama 3 participants 3 messages Oct 7, 2020 – Oct 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 image: Add a function to modify category information

Add a generic function which can check whether a category has an entry ID.

---

 common/image.c  | 18 ++++++++++++++++++
 include/image.h |  9 +++++++++
 2 files changed, 27 insertions(+)
common/image.c +18 -0
index 645bfef169..4fc4a0f1c4 100644
@@ -858,6 +858,24 @@ const char *genimg_get_cat_desc(enum ih_category category)
 	return table_info[category].desc;
 }
 
+/**
+ * genimg_cat_has_id - check whether category has entry id
+ * @category: category to look up (enum ih_category)
+ * @id: entry id to be checked
+ *
+ * This will scan the translation table trying to find the entry that matches
+ * the given id.
+ *
+ * @return true if category has entry id; false if not
+ */
+bool genimg_cat_has_id(enum ih_category category, uint id)
+{
+	if (get_table_entry(table_info[category].table, id))
+		return true;
+
+	return false;
+}
+
 /**
  * get_table_entry_name - translate entry id to long name
  * @table: pointer to a translation table for entries of a specific type
include/image.h +9 -0
index 9a5a87dbf8..6222057f27 100644
@@ -568,6 +568,15 @@ int genimg_get_cat_count(enum ih_category category);
  */
 const char *genimg_get_cat_desc(enum ih_category category);
 
+/**
+ * genimg_cat_has_id() - Check whether a category has an item
+ *
+ * @category:	Category to check
+ * @id:		Item ID
+ * @return true or false as to whether a category has an item
+ */
+bool genimg_cat_has_id(enum ih_category category, uint id);
+
 int genimg_get_os_id(const char *name);
 int genimg_get_arch_id(const char *name);
 int genimg_get_type_id(const char *name);
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/3 image: Add a function to modify category information

In reply to Naoki Hayama
Quoted 5 lines · Naoki Hayama

Add a generic function which can check whether a category has an entry ID.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/643a4e35/attachment.sig>