summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-25 15:27:02 (GMT)
committerSimon Glass <sjg@chromium.org>2015-01-30 00:09:55 (GMT)
commitba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0 (patch)
tree9564204a9d60215eaa5fd178a9b77a42485abc59 /drivers
parentcdc133bde9dd221319b9cf7fd99fcb4da8ba195c (diff)
downloadu-boot-ba8da9dc43ac8ae3351345df12dc7f9d1cd07ae0.tar.xz
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')
-rw-r--r--drivers/core/device.c4
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);