summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2020-08-20 09:34:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-08-24 08:48:36 +0200
commita78113f9acca7ddb0a9058dc840fc6bba0c21d24 (patch)
tree3ef6d6126d072ab4c99c5e95a754a574cc448e0c /drivers/of
parente8e24151f2254832d0462528ca722d7c4d261a81 (diff)
downloadbarebox-a78113f9acca7ddb0a9058dc840fc6bba0c21d24.tar.gz
barebox-a78113f9acca7ddb0a9058dc840fc6bba0c21d24.tar.xz
of: of_device_get_match_compatible() helper
Some times we need to know, against which compatible did the driver was registered. So, instead of coding it in the driver, add generic helper for all drivers. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/device.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 67a67bd565..b3f522e1fa 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -31,3 +31,15 @@ const void *of_device_get_match_data(const struct device_d *dev)
return match->data;
}
EXPORT_SYMBOL(of_device_get_match_data);
+
+const char *of_device_get_match_compatible(const struct device_d *dev)
+{
+ const struct of_device_id *match;
+
+ match = of_match_device(dev->driver->of_compatible, dev);
+ if (!match)
+ return NULL;
+
+ return match->compatible;
+}
+EXPORT_SYMBOL(of_device_get_match_compatible);