diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-03-07 16:14:19 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-03-10 10:28:37 +0100 |
commit | fb887db2bdeaf42630436a28d62deba5572f7217 (patch) | |
tree | d8e5f80f36cfb215dae1f37a79e6fb4b65b135cc /drivers | |
parent | 3610ec11f72b464c900bddd8bfdf12b58c70ea03 (diff) | |
download | barebox-fb887db2bdeaf42630436a28d62deba5572f7217.tar.gz |
driver: Add rescan hook to struct device
When devices are enabled with a device tree overlay the newly enabled
devices can be probed by doing a of_probe(). This works fine for the
regular platform devices, but doesn't work for devices which are not
probed by the core, but by the subsystem. Prominent examples are I2C or
SPI devices.
This patch adds a struct device::rescan hook that subsystems can
implement to trigger rescanning the device nodes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/platform.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index edb082b106..23b8fa7934 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -153,8 +153,10 @@ struct device *of_platform_device_create(struct device_node *np, * Linux uses the OF_POPULATED flag to skip already populated/created * devices. */ - if (np->dev) + if (np->dev) { + device_rescan(np->dev); return np->dev; + } /* count the io resources */ if (of_can_translate_address(np)) @@ -414,17 +416,13 @@ static struct device *of_device_create_on_demand(struct device_node *np) { struct device_node *parent; struct device *parent_dev, *dev; - int ret; parent = of_get_parent(np); if (!parent) return NULL; - if (!np->dev && parent->dev) { - ret = device_detect(parent->dev); - if (ret && ret != -ENOSYS) - return ERR_PTR(ret); - } + if (!np->dev && parent->dev) + device_rescan(parent->dev); if (!np->dev) pr_debug("Creating device for %s\n", np->full_name); |