diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-03 21:29:44 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-03-03 19:17:25 -0700 |
commit | 15421b71bccc3a12e64cfa1e8089e50cc2a93fe4 (patch) | |
tree | ec893da315794fe9f2b695f7c08f4a0d3212ccba /drivers | |
parent | 24fd7e383da23adf785fc2d2b8bddfc29b85346b (diff) | |
download | u-boot-15421b71bccc3a12e64cfa1e8089e50cc2a93fe4.zip u-boot-15421b71bccc3a12e64cfa1e8089e50cc2a93fe4.tar.gz u-boot-15421b71bccc3a12e64cfa1e8089e50cc2a93fe4.tar.bz2 |
dm: core: Add DM_DEVICE_REMOVE condition to all exit paths
At present device_bind() does some unnecessary work if a device fails to
bind in SPL. Add the missing conditions.
Also fix a style nit in the same function while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/device.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index d1098a3..81f6880 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -137,9 +137,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, if (parent) { size = parent->driver->per_child_plat_auto; - if (!size) { + if (!size) size = parent->uclass->uc_drv->per_child_plat_auto; - } if (size) { dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA); ptr = calloc(1, size); @@ -209,14 +208,18 @@ fail_uclass_bind: } } fail_alloc3: - if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { - free(dev_get_uclass_plat(dev)); - dev_set_uclass_plat(dev, NULL); + if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) { + if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { + free(dev_get_uclass_plat(dev)); + dev_set_uclass_plat(dev, NULL); + } } fail_alloc2: - if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { - free(dev_get_plat(dev)); - dev_set_plat(dev, NULL); + if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) { + if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { + free(dev_get_plat(dev)); + dev_set_plat(dev, NULL); + } } fail_alloc1: devres_release_all(dev); |