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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
Anup Patel 2020-05-12 13:59:52 +05:30 committed by Anup Patel
parent 446a9c6d1e
commit 2c685c214f
8 changed files with 11 additions and 9 deletions

View 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,

View 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)

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;