dm: core: Allow writing to a flat tree with ofnode

In generally it is not permitted to implement an ofnode function only for
flat tree or live tree. Both must be supported. Also the code for
live tree access should be in of_access.c rather than ofnode.c which is
really just for holding the API-conversion code.

Update ofnode_write_prop() accordingly and fix the test so it can work
with flat tree too.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2022-07-30 15:52:13 -06:00 committed by Tom Rini
parent 7b1dfc9fd7
commit 39e42be12b
5 changed files with 85 additions and 53 deletions

View file

@ -44,6 +44,24 @@ static inline const struct device_node *ofnode_to_np(ofnode node)
return node.np;
}
/**
* ofnode_to_npw() - convert an ofnode to a writeable live DT node pointer
*
* This cannot be called if the reference contains an offset.
*
* @node: Reference containing struct device_node * (possibly invalid)
* Return: pointer to device node (can be NULL)
*/
static inline struct device_node *ofnode_to_npw(ofnode node)
{
#ifdef OF_CHECKS
if (!of_live_active())
return NULL;
#endif
/* Drop constant */
return (struct device_node *)node.np;
}
/**
* ofnode_to_offset() - convert an ofnode to a flat DT offset
*