diff options
| author | Rob Herring <robh@kernel.org> | 2023-02-09 15:35:01 -0600 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-07-17 18:24:52 +0200 |
| commit | f1195eb22425dcf965b5237031f8d50b79d75b13 (patch) | |
| tree | 56b70154046f83b74ea6e1528d4044222aa5f8fb /include | |
| parent | 9c4736267c744dba638e6c6a26db485f0c08c89b (diff) | |
| download | linux-f1195eb22425dcf965b5237031f8d50b79d75b13.tar.gz linux-f1195eb22425dcf965b5237031f8d50b79d75b13.tar.bz2 linux-f1195eb22425dcf965b5237031f8d50b79d75b13.zip | |
of: Add of_property_present() helper
[ Upstream commit 9cbad37ce8122de32a1529e394b468bc101c9e7f ]
Add an of_property_present() function similar to
fwnode_property_present(). of_property_read_bool() could be used
directly, but it is cleaner to not use it on non-boolean properties.
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Tested-by: Frank Rowand <frowand.list@gmail.com>
Link: https://lore.kernel.org/all/20230215215547.691573-1-robh@kernel.org/
Signed-off-by: Rob Herring <robh@kernel.org>
Stable-dep-of: 171eb6f71e9e ("ASoC: meson: meson-card-utils: use of_property_present() for DT parsing")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/of.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index ec6b8a1af73c..728b9df20a52 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1044,7 +1044,8 @@ 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. + * Search for a boolean property in a device node. Usage on non-boolean + * property types is deprecated. * * Return: true if the property exists false otherwise. */ @@ -1057,6 +1058,20 @@ static inline bool of_property_read_bool(const struct device_node *np, } /** + * 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); +} + +/** * of_property_read_u8_array - Find and read an array of u8 from a property. * * @np: device node from which the property value is to be read. |
