From f10643cf8a4ca006d1ad194e930cd292fd869d17 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Dec 2020 10:40:14 -0700 Subject: dm: core: Access device ofnode through functions At present ofnode is present in the device even if it is never used. With of-platdata this field is not used, so can be removed. In preparation for this, change the access to go through inline functions. Signed-off-by: Simon Glass --- include/dm/device.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'include/dm/device.h') diff --git a/include/dm/device.h b/include/dm/device.h index 4a1224bcc2..1b274206ea 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic) */ static inline ofnode dev_ofnode(const struct udevice *dev) { +#if !CONFIG_IS_ENABLED(OF_PLATDATA) return dev->node; +#else + return ofnode_null(); +#endif } /* Returns non-zero if the device is active (probed and not removed) */ @@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev) static inline int dev_of_offset(const struct udevice *dev) { - return ofnode_to_offset(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_to_offset(dev_ofnode(dev)); +#else + return -1; +#endif } static inline bool dev_has_ofnode(const struct udevice *dev) { - return ofnode_valid(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_valid(dev_ofnode(dev)); +#else + return false; +#endif +} + +static inline void dev_set_ofnode(struct udevice *dev, ofnode node) +{ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + dev->node = node; +#endif } static inline int dev_seq(const struct udevice *dev) -- cgit v1.2.1