diff options
author | Simon Glass <sjg@chromium.org> | 2015-01-25 08:27:02 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-01-29 17:09:55 -0700 |
commit | ba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0 (patch) | |
tree | 9564204a9d60215eaa5fd178a9b77a42485abc59 /drivers/core/device.c | |
parent | cdc133bde9dd221319b9cf7fd99fcb4da8ba195c (diff) | |
download | u-boot-imx-ba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0.zip u-boot-imx-ba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0.tar.gz u-boot-imx-ba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0.tar.bz2 |
dm: core: Allow uclasses to specify platdata for a device's children
In many cases the child platform data for a device's children is defined by
the uclass rather than the individual devices. For example, a SPI bus needs
to know the chip select and speed for each of its children. It makes sense
to allow this information to be defined the SPI uclass rather than each
individual driver.
If the device provides a size value for its child platdata, then use it.
Failng that, fall back to that provided by the uclass.
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index ee97cc8..2f33b0e 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -83,6 +83,10 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name, if (parent) { int size = parent->driver->per_child_platdata_auto_alloc_size; + if (!size) { + size = parent->uclass->uc_drv-> + per_child_platdata_auto_alloc_size; + } if (size) { dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA; dev->parent_platdata = calloc(1, size); |