lib: utils: Extend fdt_find_match() Implementation
authorAnup Patel <anup.patel@wdc.com>
Tue, 12 May 2020 08:29:52 +0000 (13:59 +0530)
committerAnup Patel <anup@brainfault.org>
Sat, 23 May 2020 05:06:33 +0000 (10:36 +0530)
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
include/sbi_utils/fdt/fdt_helper.h
lib/utils/fdt/fdt_helper.c
lib/utils/ipi/fdt_ipi.c
lib/utils/irqchip/fdt_irqchip.c
lib/utils/reset/fdt_reset.c
lib/utils/serial/fdt_serial.c
lib/utils/timer/fdt_timer.c
platform/generic/platform.c

index 42390e8..72fb167 100644 (file)
@@ -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,
index 61d70d9..58f8951 100644 (file)
@@ -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)
index d8ba0b2..d99a941 100644 (file)
@@ -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;
 
index 5f5cf97..87def52 100644 (file)
@@ -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;
 
index 98fbb54..dfbd33e 100644 (file)
@@ -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;
 
index ae1aeea..fa6c478 100644 (file)
@@ -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;
 
index 1ad08fe..46edb83 100644 (file)
@@ -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;
 
index 7b4a0ae..a4a07e3 100644 (file)
@@ -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;