mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 16:40:44 +09:00
dm: core: Allow parents to pass data to children during probe
Buses sometimes want to pass data to their children when they are probed. For example, a SPI bus may want to tell the slave device about the chip select it is connected to. Add a new function to permit the parent data to be supplied to the child. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
This commit is contained in:
parent
a8981d4f80
commit
accd4b19b3
@ -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;
|
struct driver *drv;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@ -282,6 +282,8 @@ int device_probe(struct udevice *dev)
|
|||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
if (parent_priv)
|
||||||
|
memcpy(dev->parent_priv, parent_priv, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = device_probe(dev->parent);
|
ret = device_probe(dev->parent);
|
||||||
@ -335,6 +337,11 @@ fail:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int device_probe(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return device_probe_child(dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int device_remove(struct udevice *dev)
|
int device_remove(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct driver *drv;
|
struct driver *drv;
|
||||||
|
@ -65,6 +65,19 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
|
|||||||
*/
|
*/
|
||||||
int device_probe(struct udevice *dev);
|
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
|
* device_remove() - Remove a device, de-activating it
|
||||||
*
|
*
|
||||||
|
@ -139,6 +139,10 @@ struct udevice_id {
|
|||||||
* @per_child_auto_alloc_size: Each device can hold private data owned by
|
* @per_child_auto_alloc_size: Each device can hold private data owned by
|
||||||
* its parent. If required this will be automatically allocated if this
|
* its parent. If required this will be automatically allocated if this
|
||||||
* value is non-zero.
|
* 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
|
* @ops: Driver-specific operations. This is typically a list of function
|
||||||
* pointers defined by the driver, to implement driver functions required by
|
* pointers defined by the driver, to implement driver functions required by
|
||||||
* the uclass.
|
* the uclass.
|
||||||
|
Loading…
Reference in New Issue
Block a user