summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 07:25:15 +0300
committerSimon Glass <sjg@chromium.org>2021-03-22 09:23:28 +0300
commit1ef3af3b2717aba9db79879274ab5e1f1d7b2d25 (patch)
tree20db7bc4bce5c0286f955185de115d92e215a37f /drivers/core
parent607f9bcb0d0af57c52bacf4d3aeb3a7d389ea206 (diff)
downloadu-boot-1ef3af3b2717aba9db79879274ab5e1f1d7b2d25.tar.xz
dm: core: Allow dropping run-time binding of devices
With OF_PLATDATA_INST devices are bound at build time. We should not need binding of devices at runtime in most cases. However it is inflexible to absolutely prohibit it, so add an option to control this. Update the driver model core so that it does not bind devices. Update device_bind() to return an error if called. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 81f6880eac..e915b3089d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -45,6 +45,9 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
bool auto_seq = true;
void *ptr;
+ if (CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND))
+ return -ENOSYS;
+
if (devp)
*devp = NULL;
if (!name)
@@ -395,26 +398,31 @@ int device_of_to_plat(struct udevice *dev)
if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
return 0;
- /* Ensure all parents have ofdata */
- if (dev->parent) {
- ret = device_of_to_plat(dev->parent);
+ /*
+ * This is not needed if binding is disabled, since data is allocated
+ * at build time.
+ */
+ if (!CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND)) {
+ /* Ensure all parents have ofdata */
+ if (dev->parent) {
+ ret = device_of_to_plat(dev->parent);
+ if (ret)
+ goto fail;
+
+ /*
+ * The device might have already been probed during
+ * the call to device_probe() on its parent device
+ * (e.g. PCI bridge devices). Test the flags again
+ * so that we don't mess up the device.
+ */
+ if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
+ return 0;
+ }
+
+ ret = device_alloc_priv(dev);
if (ret)
goto fail;
-
- /*
- * The device might have already been probed during
- * the call to device_probe() on its parent device
- * (e.g. PCI bridge devices). Test the flags again
- * so that we don't mess up the device.
- */
- if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
- return 0;
}
-
- ret = device_alloc_priv(dev);
- if (ret)
- goto fail;
-
drv = dev->driver;
assert(drv);