Hi, i came across dwc2 usb node like this:
usb@101c0000 { compatible = "snps,dwc2"; reg = <0x101c0000 0x40000>; interrupts = <0x0 0x11 0x4>; clocks = <0x2 0x1c9>; clock-names = "otg"; dr_mode = "host"; phys = <0x6>; phy-names = "usb2-phy"; status = "okay"; }; and as it's at /-root, there's not much i could use to identify between broadcom & rockchip while keeping the code simple for future additions, and not mess w/each SoC compat string individually when applying vendor- specific things.. i guess this should not be abused ever alone w/o some && in any _match(), but when used responsibly may make some _attach() funcs prettier:) to export the _vend variant, or keep as strchr hack like below? (untested diff rly, for just the discussion atm.) -Artturi diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index d6a64499e88..f22ed7a9f49 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -42,6 +42,7 @@ int fdt_translate_reg(void *, struct fdt_reg *); #ifdef DEBUG void fdt_print_node_recurse(void *, int); #endif +static int fdt_is_compatible_vend(void *, const char *); static int tree_inited = 0; static struct fdt tree; @@ -634,6 +635,24 @@ fdt_is_compatible(void *node, const char *name) return 0; } +int +fdt_is_compatible_vend(void *node, const char *name) +{ + size_t vlen = strlen(name); + char *data; + int len; + + len = fdt_node_property(node, "compatible", &data); + while (len > 0) { + if (strncmp(data, name, vlen) == 0) + return 1; + len -= strlen(data) + 1; + data += strlen(data) + 1; + } + + return 0; +} + #ifdef DEBUG /* * Debug methods for printing whole tree, particular odes and properies @@ -902,6 +921,8 @@ int OF_is_compatible(int handle, const char *name) { void *node = (char *)tree.header + handle; + if (strchr(name, ',') == NULL) + return fdt_is_compatible_vend(node, name); return (fdt_is_compatible(node, name)); }