Commit 29d11b8838bb2aa324b8873159cbd7088870a75b

Authored by Mario Six
Committed by Simon Glass
1 parent 147c607448

core: Make device_is_compatible live-tree compatible

Judging from its name and parameters, device_is_compatible looks like it
is compatible with a live device tree, but it actually isn't.

Make it compatible with a live device tree.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>

Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff

drivers/core/device.c
... ... @@ -17,6 +17,7 @@
17 17 #include <dm/device.h>
18 18 #include <dm/device-internal.h>
19 19 #include <dm/lists.h>
  20 +#include <dm/of_access.h>
20 21 #include <dm/pinctrl.h>
21 22 #include <dm/platdata.h>
22 23 #include <dm/read.h>
23 24  
... ... @@ -703,8 +704,12 @@
703 704 bool device_is_compatible(struct udevice *dev, const char *compat)
704 705 {
705 706 const void *fdt = gd->fdt_blob;
  707 + ofnode node = dev_ofnode(dev);
706 708  
707   - return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat);
  709 + if (ofnode_is_np(node))
  710 + return of_device_is_compatible(ofnode_to_np(node), compat, NULL, NULL);
  711 + else
  712 + return !fdt_node_check_compatible(fdt, ofnode_to_offset(node), compat);
708 713 }
709 714  
710 715 bool of_machine_is_compatible(const char *compat)