[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Minios-devel] [UNIKRAFT PATCHv7 6/8] plat/common: Introduce fdt_node_offset_by_compatible_list helper
- To: Jia He <justin.he@xxxxxxx>, <minios-devel@xxxxxxxxxxxxxxxxxxxx>, Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
- From: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
- Date: Mon, 8 Jul 2019 10:32:08 +0200
- Cc: Felipe Huici <felipe.huici@xxxxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Kaly Xin <Kaly.Xin@xxxxxxx>, Jianyong Wu <jianyong.wu@xxxxxxx>, Florian Schmidt <florian.schmidt@xxxxxxxxx>, Julien Grall <julien.grall@xxxxxxx>, yuri.volchkov@xxxxxxxxx
- Delivery-date: Mon, 08 Jul 2019 09:48:30 +0000
- List-id: Mini-os development list <minios-devel.lists.xenproject.org>
Hello Jianyong Wu,
This patch seems fine.
Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
Thanks & Regards
Sharan
On 6/27/19 9:55 AM, Jia He wrote:
From: Jianyong Wu <jianyong.wu@xxxxxxx>
For most of devices that will use the device tree will have one
or more compatible strings. This helper will avoid implement a
function to match compatible list everywhere.
The valid compatible strings array should be ended with NULL.
E.g.
static const char * const gic_device_list[] = {
"arm,cortex-a15-gic",
"arm,cortex-a7-gic",
"arm,cortex-a9-gic",
NULL}
Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Jianyong Wu <jianyong.wu@xxxxxxx>
Signed-off-by: Jia He <justin.he@xxxxxxx>
---
plat/drivers/include/ofw/fdt.h | 26 ++++++++++++++++++++++++++
plat/drivers/ofw/fdt.c | 15 +++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index 0b8c1d5..aaa32c6 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -112,4 +112,30 @@ static inline uint64_t fdt_reg_read_number(const fdt32_t
*regs, uint32_t size)
*/
int fdt_get_address(const void *fdt, int nodeoffset, uint32_t index,
uint64_t *addr, uint64_t *size);
+
+/**
+ * fdt_node_offset_by_compatible_list - find nodes with a given
+ * 'compatible' list value
+ * @fdt: pointer to the device tree blob
+ * @startoffset: only find nodes after this offset
+ * @compatibles: a list of 'compatible' string to match, should be ended
+ * with NULL string.
+ * fdt_node_offset_by_compatible_list() returns the offset of the
+ * first matched node after startoffset, which has a 'compatible'
+ * property which lists the given compatible string; or if
+ * startoffset is -1, the very first such node in the tree.
+ *
+ * returns:
+ * structure block offset of the located node (>= 0, >startoffset),
+ * on success
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ * tree after startoffset
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset,
+ const char * const compatibles[]);
#endif
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 0ac6006..683dd60 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -262,3 +262,18 @@ int fdt_get_address(const void *fdt, int nodeoffset,
uint32_t index,
return -FDT_ERR_NOTFOUND;
return 0;
}
+
+int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset,
+ const char * const compatibles[])
+{
+ int idx, offset;
+
+ for (idx = 0; compatibles[idx] != NULL; idx++) {
+ offset = fdt_node_offset_by_compatible(fdt, startoffset,
+ compatibles[idx]);
+ if (offset >= 0)
+ return offset;
+ }
+
+ return -FDT_ERR_NOTFOUND;
+}
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|