[PATCH 19/19] of: Add dummy driver

Sascha Hauer s.hauer at pengutronix.de
Fri Jun 25 00:25:40 PDT 2021


With deep probe support we decide that a device for a new device node is
available when the device has a driver. It sometimes happens that a
consumer of a device node doesn't point to the node to which the driver
is attached to, but instead a subnode, like this:

	usb2phy0: usb2-phy at fe8a0000 {
		compatible = "rockchip,rk3568-usb2phy";

		u2phy0_host: host-port {
			status = "disabled";
		};
	};

	usbhost_dwc3: dwc3 at fd000000 {
		compatible = "snps,dwc3";
		phys = <&u2phy0_host>;
		phy-names = "usb2-phy";
	};

of_device_ensure_probed() would now expect a driver for the &u2phy0_host
node, but the driver is attached to the &usb2phy0 node. This patch adds
of_platform_device_dummy_drv() which can be used in such situations. When
called on the &u2phy0_host it will attach a dummy driver to it so that
deep probe is happy.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/of/platform.c | 9 +++++++++
 include/of.h          | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index bc0477be1d..e3e8227b8c 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -169,6 +169,15 @@ struct device_d *of_platform_device_create(struct device_node *np,
 	return NULL;
 }
 
+struct driver_d dummy_driver = {
+	.name = "dummy-driver",
+};
+
+void of_platform_device_dummy_drv(struct device_d *dev)
+{
+	dev->driver = &dummy_driver;
+}
+
 /**
  * of_device_enable_and_register - Enable and register device
  * @np: pointer to node to enable create device for
diff --git a/include/of.h b/include/of.h
index 98de9d8480..6f1ec94e7e 100644
--- a/include/of.h
+++ b/include/of.h
@@ -268,6 +268,7 @@ extern int barebox_register_fdt(const void *dtb);
 
 extern struct device_d *of_platform_device_create(struct device_node *np,
 						struct device_d *parent);
+extern void of_platform_device_dummy_drv(struct device_d *dev);
 extern int of_platform_populate(struct device_node *root,
 				const struct of_device_id *matches,
 				struct device_d *parent);
@@ -365,6 +366,10 @@ static inline struct device_d *of_platform_device_create(struct device_node *np,
 	return NULL;
 }
 
+static inline void of_platform_device_dummy_drv(struct device_d *dev)
+{
+}
+
 static inline int of_device_ensure_probed(struct device_node *np)
 {
 	return 0;
-- 
2.29.2




More information about the barebox mailing list