From: Simon Glass Date: Wed, 23 Dec 2020 02:30:27 +0000 (-0700) Subject: dm: core: Add functions to set priv/plat X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-logo.png?a=commitdiff_plain;h=12559f5bab3e43b603dccfa6c354ffd7da03249c;p=u-boot.git dm: core: Add functions to set priv/plat This should not normally be needed in drivers, but add accessors for the few cases that exist. Signed-off-by: Simon Glass --- diff --git a/drivers/core/device.c b/drivers/core/device.c index d1a08ce783..f2d750c8de 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -959,6 +959,36 @@ int device_set_name(struct udevice *dev, const char *name) return 0; } +void dev_set_priv(struct udevice *dev, void *priv) +{ + dev->priv = priv; +} + +void dev_set_parent_priv(struct udevice *dev, void *parent_priv) +{ + dev->parent_priv = parent_priv; +} + +void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv) +{ + dev->uclass_priv = uclass_priv; +} + +void dev_set_plat(struct udevice *dev, void *plat) +{ + dev->plat = plat; +} + +void dev_set_parent_plat(struct udevice *dev, void *parent_plat) +{ + dev->parent_plat = parent_plat; +} + +void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat) +{ + dev->uclass_plat = uclass_plat; +} + #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) bool device_is_compatible(const struct udevice *dev, const char *compat) { diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index af3b6b2b05..03b092bdf7 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -189,6 +189,90 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv, } #endif +/** + * dev_set_priv() - Set the private data for a device + * + * This is normally handled by driver model, which automatically allocates + * private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @priv New private-data pointer + */ +void dev_set_priv(struct udevice *dev, void *priv); + +/** + * dev_set_parent_priv() - Set the parent-private data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_priv: New parent-private data + */ +void dev_set_parent_priv(struct udevice *dev, void *parent_priv); + +/** + * dev_set_uclass_priv() - Set the uclass private data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_priv: New uclass private data + */ +void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv); + +/** + * dev_set_plat() - Set the platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @plat New platform-data pointer + */ +void dev_set_plat(struct udevice *dev, void *priv); + +/** + * dev_set_parent_plat() - Set the parent platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_plat: New parent platform data + */ +void dev_set_parent_plat(struct udevice *dev, void *parent_plat); + +/** + * dev_set_uclass_plat() - Set the uclass platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_plat: New uclass platform data + */ +void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat); + /** * simple_bus_translate() - translate a bus address to a system address *