From 73443b9e4c451b17d1e08164ea933ee6a849b2b3 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Thu, 28 Apr 2016 15:36:02 +0530 Subject: drivers: core: device: add support to check dt compatible for a device/machine Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible. Idea taken from Linux. Signed-off-by: Mugunthan V N Reviewed-by: Joe Hershberger --- drivers/core/device.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/core') diff --git a/drivers/core/device.c b/drivers/core/device.c index 5c2dc7021fb..45d5e3e12c0 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -721,3 +721,17 @@ int device_set_name(struct udevice *dev, const char *name) return 0; } + +bool of_device_is_compatible(struct udevice *dev, const char *compat) +{ + const void *fdt = gd->fdt_blob; + + return !fdt_node_check_compatible(fdt, dev->of_offset, compat); +} + +bool of_machine_is_compatible(const char *compat) +{ + const void *fdt = gd->fdt_blob; + + return !fdt_node_check_compatible(fdt, 0, compat); +} -- cgit v1.2.3