From 2c685c214f2815c12f9d70422d85daa7f48003cf Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Tue, 12 May 2020 13:59:52 +0530 Subject: [PATCH] lib: utils: Extend fdt_find_match() Implementation We extend fdt_find_match() implementation by adding node offset parameter which represents the first node to match from. The improved fdt_find_match() can be used to find multiple match nodes. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi_utils/fdt/fdt_helper.h | 3 ++- lib/utils/fdt/fdt_helper.c | 5 +++-- lib/utils/ipi/fdt_ipi.c | 2 +- lib/utils/irqchip/fdt_irqchip.c | 2 +- lib/utils/reset/fdt_reset.c | 2 +- lib/utils/serial/fdt_serial.c | 2 +- lib/utils/timer/fdt_timer.c | 2 +- platform/generic/platform.c | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 42390e8..72fb167 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -28,7 +28,8 @@ struct platform_uart_data { const struct fdt_match *fdt_match_node(void *fdt, int nodeoff, const struct fdt_match *match_table); -int fdt_find_match(void *fdt, const struct fdt_match *match_table, +int fdt_find_match(void *fdt, int startoff, + const struct fdt_match *match_table, const struct fdt_match **out_match); int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr, diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 61d70d9..58f8951 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -43,7 +43,8 @@ const struct fdt_match *fdt_match_node(void *fdt, int nodeoff, return NULL; } -int fdt_find_match(void *fdt, const struct fdt_match *match_table, +int fdt_find_match(void *fdt, int startoff, + const struct fdt_match *match_table, const struct fdt_match **out_match) { int nodeoff; @@ -52,7 +53,7 @@ int fdt_find_match(void *fdt, const struct fdt_match *match_table, return SBI_ENODEV; while (match_table->compatible) { - nodeoff = fdt_node_offset_by_compatible(fdt, -1, + nodeoff = fdt_node_offset_by_compatible(fdt, startoff, match_table->compatible); if (nodeoff >= 0) { if (out_match) diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c index d8ba0b2..d99a941 100644 --- a/lib/utils/ipi/fdt_ipi.c +++ b/lib/utils/ipi/fdt_ipi.c @@ -69,7 +69,7 @@ static int fdt_ipi_cold_init(void) for (pos = 0; pos < array_size(ipi_drivers); pos++) { drv = ipi_drivers[pos]; - noff = fdt_find_match(fdt, drv->match_table, &match); + noff = fdt_find_match(fdt, -1, drv->match_table, &match); if (noff < 0) continue; diff --git a/lib/utils/irqchip/fdt_irqchip.c b/lib/utils/irqchip/fdt_irqchip.c index 5f5cf97..87def52 100644 --- a/lib/utils/irqchip/fdt_irqchip.c +++ b/lib/utils/irqchip/fdt_irqchip.c @@ -42,7 +42,7 @@ static int fdt_irqchip_cold_init(void) for (pos = 0; pos < array_size(irqchip_drivers); pos++) { drv = irqchip_drivers[pos]; - noff = fdt_find_match(fdt, drv->match_table, &match); + noff = fdt_find_match(fdt, -1, drv->match_table, &match); if (noff < 0) continue; diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index 98fbb54..dfbd33e 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -38,7 +38,7 @@ int fdt_reset_init(void) for (pos = 0; pos < array_size(reset_drivers); pos++) { drv = reset_drivers[pos]; - noff = fdt_find_match(fdt, drv->match_table, &match); + noff = fdt_find_match(fdt, -1, drv->match_table, &match); if (noff < 0) continue; diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c index ae1aeea..fa6c478 100644 --- a/lib/utils/serial/fdt_serial.c +++ b/lib/utils/serial/fdt_serial.c @@ -91,7 +91,7 @@ int fdt_serial_init(void) for (pos = 0; pos < array_size(serial_drivers); pos++) { drv = serial_drivers[pos]; - noff = fdt_find_match(fdt, drv->match_table, &match); + noff = fdt_find_match(fdt, -1, drv->match_table, &match); if (noff < 0) continue; diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index 1ad08fe..46edb83 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -80,7 +80,7 @@ static int fdt_timer_cold_init(void) for (pos = 0; pos < array_size(timer_drivers); pos++) { drv = timer_drivers[pos]; - noff = fdt_find_match(fdt, drv->match_table, &match); + noff = fdt_find_match(fdt, -1, drv->match_table, &match); if (noff < 0) continue; diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 7b4a0ae..a4a07e3 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -41,7 +41,7 @@ static void fw_platform_lookup_special(void *fdt, int root_offset) if (!plat->match_table) continue; - noff = fdt_find_match(fdt, plat->match_table, &match); + noff = fdt_find_match(fdt, -1, plat->match_table, &match); if (noff < 0) continue; -- 2.7.4