diff --git a/drivers/core/device.c b/drivers/core/device.c index 9538874017ac4865acc30177b6982b1e6e0f4fd1..49faa29dc1a0eecaa84e76371b8301c2eef14d7b 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -232,7 +232,7 @@ static void device_free(struct udevice *dev) } } -int device_probe(struct udevice *dev) +int device_probe_child(struct udevice *dev, void *parent_priv) { struct driver *drv; int size = 0; @@ -282,6 +282,8 @@ int device_probe(struct udevice *dev) ret = -ENOMEM; goto fail; } + if (parent_priv) + memcpy(dev->parent_priv, parent_priv, size); } ret = device_probe(dev->parent); @@ -335,6 +337,11 @@ fail: return ret; } +int device_probe(struct udevice *dev) +{ + return device_probe_child(dev, NULL); +} + int device_remove(struct udevice *dev) { struct driver *drv; diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 7005d03d08f5d96adcd3f28c2a11f7f9e318ec44..44cb7ef93bfdeea682ea0602d33bf9615260ad9d 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -65,6 +65,19 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, */ int device_probe(struct udevice *dev); +/** + * device_probe() - Probe a child device, activating it + * + * Activate a device so that it is ready for use. All its parents are probed + * first. The child is provided with parent data if parent_priv is not NULL. + * + * @dev: Pointer to device to probe + * @parent_priv: Pointer to parent data. If non-NULL then this is provided to + * the child. + * @return 0 if OK, -ve on error + */ +int device_probe_child(struct udevice *dev, void *parent_priv); + /** * device_remove() - Remove a device, de-activating it * diff --git a/include/dm/device.h b/include/dm/device.h index 160cd5883a2fce305df3156a9892003fb62b4d80..56862d32efc465de11113bdd7c4768128535eeef 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -139,6 +139,10 @@ struct udevice_id { * @per_child_auto_alloc_size: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. + * TODO(sjg@chromium.org): I'm considering dropping this, and just having + * device_probe_child() pass it in. So far the use case for allocating it + * is SPI, but I found that unsatisfactory. Since it is here I will leave it + * until things are clearer. * @ops: Driver-specific operations. This is typically a list of function * pointers defined by the driver, to implement driver functions required by * the uclass.