[PATCH 02/10] driver: consult feature controller prior to device probe

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Aug 17 22:19:47 PDT 2022


The newly added feature controller framework has two goals: Avoid
probing device in barebox that aren't indeed available and fixing
up the kernel tree, so the same devices aren't probed either.

The first one is easily done, by checking whether a feature is gated
prior to probe.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/base/driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index e7288f6a61cc..072870bea444 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -27,6 +27,7 @@
 #include <linux/err.h>
 #include <complete.h>
 #include <pinctrl.h>
+#include <featctrl.h>
 #include <linux/clk/clk-conf.h>
 
 #ifdef CONFIG_DEBUG_PROBES
@@ -85,6 +86,14 @@ int device_probe(struct device_d *dev)
 	static int depth = 0;
 	int ret;
 
+	ret = of_feature_controller_check(dev->device_node);
+	if (ret < 0)
+		return ret;
+	if (ret == FEATCTRL_GATED) {
+		dev_dbg(dev, "feature gated, skipping probe\n");
+		return -ENODEV;
+	}
+
 	depth++;
 
 	pr_report_probe("%*sprobe-> %s\n", depth * 4, "", dev_name(dev));
-- 
2.30.2




More information about the barebox mailing list