From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Wed, 3 Feb 2021 09:43:20 -0700 Subject: [PATCH v2 04/37] dm: core: Allow dropping run-time binding of devices In-Reply-To: <20210203164353.2577985-1-sjg@chromium.org> References: <20210203164353.2577985-1-sjg@chromium.org> Message-ID: <20210203094345.v2.4.I2883cc0cb1edf613bf2dfb30e4bf982cf03daafc@changeid> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de With OF_PLATDATA_INST devices are bound at build time. we should not allow binding of devices at runtime. 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 --- (no changes since v1) drivers/core/device.c | 38 +++++++++++++++++++++----------------- dts/Kconfig | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 8629df8defb..02e28f014b5 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -44,6 +44,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) @@ -382,26 +385,27 @@ 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); + 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); diff --git a/dts/Kconfig b/dts/Kconfig index e861ea48d01..645a2d2b84d 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -371,6 +371,14 @@ config SPL_OF_PLATDATA_INST Declare devices as udevice instances so that they do not need to be bound when U-Boot starts. This can save time and code space. +config SPL_OF_PLATDATA_NO_BIND + bool "Don't allow run-time binding of devices" + depends on SPL_OF_PLATDATA_INST + default y + help + This removes the ability to bind devices at run time, thus saving + some code space in U-Boot. + endif config TPL_OF_PLATDATA @@ -411,6 +419,14 @@ config TPL_OF_PLATDATA_INST Declare devices as udevice instances so that they do not need to be bound when U-Boot starts. This can save time and code space. +config TPL_OF_PLATDATA_NO_BIND + bool "Don't allow run-time binding of devices" + depends on TPL_OF_PLATDATA_INST + default y + help + This removes the ability to bind devices at run time, thus saving + some code space in U-Boot. + endif endmenu -- 2.30.0.365.g02bc693789-goog