diff options
author | Simon Glass | 2023-09-26 08:14:44 -0600 |
---|---|---|
committer | Tom Rini | 2023-10-06 14:38:13 -0400 |
commit | d9216c8683fced4cbf6d437b4357c9368bf1bf86 (patch) | |
tree | b988723a63eb879277b2e1d0437c370945e7ed27 /include/dm | |
parent | 62b1db33778611a3023d1e3a98e869b495edc9ca (diff) |
dm: core: Support writing a boolean
Add functions to write a boolean property. This involves deleting it if
the value is false.
Add a new ofnode_has_property() as well. Add a comment about the behaviour
of of_read_property() when the property value is empty.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r-- | include/dm/ofnode.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index a8605fb718b..ebea29d32af 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1037,11 +1037,20 @@ int ofnode_decode_panel_timing(ofnode node, * @node: node to read * @propname: property to read * @lenp: place to put length on success - * Return: pointer to property, or NULL if not found + * Return: pointer to property value, or NULL if not found or empty */ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp); /** + * ofnode_has_property() - check if a node has a named property + * + * @node: node to read + * @propname: property to read + * Return: true if the property exists in the node, false if not + */ +bool ofnode_has_property(ofnode node, const char *propname); + +/** * ofnode_first_property()- get the reference of the first property * * Get reference to the first property of the node, it is used to iterate @@ -1453,6 +1462,27 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value); int ofnode_write_u32(ofnode node, const char *propname, u32 value); /** + * ofnode_write_bool() - Set a boolean property of an ofnode + * + * This either adds or deleted a property with a zero-length value + * + * @node: The node for whose string property should be set + * @propname: The name of the string property to set + * @value: The new value of the boolean property + * Return: 0 if successful, -ve on error + */ +int ofnode_write_bool(ofnode node, const char *propname, bool value); + +/** + * ofnode_delete_prop() - Delete a property + * + * @node: Node containing the property to delete + * @propname: Name of property to delete + * Return: 0 if successful, -ve on error + */ +int ofnode_delete_prop(ofnode node, const char *propname); + +/** * ofnode_set_enabled() - Enable or disable a device tree node given by its * ofnode * |