diff options
author | Simon Glass <sjg@chromium.org> | 2019-12-29 21:19:21 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-01-07 16:02:38 -0700 |
commit | 153851ddfa39dc1bd4f3b5402d80487d52c644aa (patch) | |
tree | 3c4d8ba6098fae5410decb45a559d6f339f43fc4 /drivers/core | |
parent | bcd90cb6928414e14942c01af374863d4049a25d (diff) | |
download | u-boot-153851ddfa39dc1bd4f3b5402d80487d52c644aa.zip u-boot-153851ddfa39dc1bd4f3b5402d80487d52c644aa.tar.gz u-boot-153851ddfa39dc1bd4f3b5402d80487d52c644aa.tar.bz2 |
dm: core: Add a new flag to track platform data
We want to avoid allocating platform data twice. This could happen if
device_probe() is called after device_ofdata_to_platdata() for the same
device.
Add a flag to track whether device_ofdata_to_platdata() has been called on
a device. Check the flag to make sure it doesn't happen twice, and clear
the flag when the data is freed.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/device-remove.c | 1 | ||||
-rw-r--r-- | drivers/core/device.c | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index 5c8dc4a..444e34b 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -140,6 +140,7 @@ void device_free(struct udevice *dev) dev->parent_priv = NULL; } } + dev->flags &= ~DM_FLAG_PLATDATA_VALID; devres_release_probe(dev); } diff --git a/drivers/core/device.c b/drivers/core/device.c index 9506c7d..9f39218 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -320,7 +320,7 @@ int device_ofdata_to_platdata(struct udevice *dev) if (!dev) return -EINVAL; - if (dev->flags & DM_FLAG_ACTIVATED) + if (dev->flags & DM_FLAG_PLATDATA_VALID) return 0; drv = dev->driver; @@ -368,6 +368,8 @@ int device_ofdata_to_platdata(struct udevice *dev) goto fail; } + dev->flags |= DM_FLAG_PLATDATA_VALID; + return 0; fail: device_free(dev); |