mirror of
https://xff.cz/git/u-boot/
synced 2025-09-30 15:01:27 +02:00
dm: core: Export a new function to read platdata
Add a new internal function, device_ofdata_to_platdata() to handle allocating private space associated with each device and reading the platform data from the device tree. Call this new function from device_probe(). Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -311,12 +311,11 @@ static void *alloc_priv(int size, uint flags)
|
|||||||
return priv;
|
return priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_probe(struct udevice *dev)
|
int device_ofdata_to_platdata(struct udevice *dev)
|
||||||
{
|
{
|
||||||
const struct driver *drv;
|
const struct driver *drv;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int seq;
|
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -369,6 +368,32 @@ int device_probe(struct udevice *dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
device_free(dev);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int device_probe(struct udevice *dev)
|
||||||
|
{
|
||||||
|
const struct driver *drv;
|
||||||
|
int ret;
|
||||||
|
int seq;
|
||||||
|
|
||||||
|
if (!dev)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (dev->flags & DM_FLAG_ACTIVATED)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
drv = dev->driver;
|
||||||
|
assert(drv);
|
||||||
|
|
||||||
|
ret = device_ofdata_to_platdata(dev);
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/* Ensure all parents are probed */
|
/* Ensure all parents are probed */
|
||||||
if (dev->parent) {
|
if (dev->parent) {
|
||||||
ret = device_probe(dev->parent);
|
ret = device_probe(dev->parent);
|
||||||
|
@@ -83,6 +83,22 @@ int device_bind_with_driver_data(struct udevice *parent,
|
|||||||
int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
|
int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
|
||||||
const struct driver_info *info, struct udevice **devp);
|
const struct driver_info *info, struct udevice **devp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_ofdata_to_platdata() - Read platform data for a device
|
||||||
|
*
|
||||||
|
* Read platform data for a device (typically from the device tree) so that
|
||||||
|
* the information needed to probe the device is present.
|
||||||
|
*
|
||||||
|
* This may cause some others devices to be probed if this one depends on them,
|
||||||
|
* e.g. a GPIO line will cause a GPIO device to be probed.
|
||||||
|
*
|
||||||
|
* All private data associated with the device is allocated.
|
||||||
|
*
|
||||||
|
* @dev: Pointer to device to process
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int device_ofdata_to_platdata(struct udevice *dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* device_probe() - Probe a device, activating it
|
* device_probe() - Probe a device, activating it
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user