diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-03-31 11:04:53 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-04-05 11:54:37 +0200 |
commit | 3698477e339a902f31f2181805e1026e56612188 (patch) | |
tree | 62c201358eeb948967131de2a22a8e1c0d468326 /include | |
parent | 55f4ec838ab6a31d67ce816ac766c2f48c87988a (diff) | |
download | barebox-3698477e339a902f31f2181805e1026e56612188.tar.gz |
of: implement of_property_present helper
We have various code using of_find_property(np, propname, NULL) to
detect whether propname exists and some more that uses
of_property_read_bool on non-boolean properties.
There's work underway in Linux to switch a lot of these instances to
of_property_present[1]. Let's prepare for porting Linux code that
uses the property by adding it.
[1]: https://lore.kernel.org/linux-devicetree/?q=of_property_present
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230331090453.1424337-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/of.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/of.h b/include/of.h index 0c5c2c0205..b88f39ebfa 100644 --- a/include/of.h +++ b/include/of.h @@ -1039,8 +1039,10 @@ static inline int of_property_read_string_index(const struct device_node *np, * @np: device node from which the property value is to be read. * @propname: name of the property to be searched. * - * Search for a property in a device node. - * Returns true if the property exist false otherwise. + * Search for a boolean property in a device node. Usage on non-boolean + * property types is deprecated. + + * Return: true if the property exist false otherwise. */ static inline bool of_property_read_bool(const struct device_node *np, const char *propname) @@ -1050,6 +1052,20 @@ static inline bool of_property_read_bool(const struct device_node *np, return prop ? true : false; } +/** + * of_property_present - Test if a property is present in a node + * @np: device node to search for the property. + * @propname: name of the property to be searched. + * + * Test for a property present in a device node. + * + * Return: true if the property exists false otherwise. + */ +static inline bool of_property_present(const struct device_node *np, const char *propname) +{ + return of_property_read_bool(np, propname); +} + static inline int of_property_read_u8(const struct device_node *np, const char *propname, u8 *out_value) |