Re: [PATCH] of: implement of_property_present helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 31, 2023 at 11:04:53AM +0200, Ahmad Fatoum wrote:
> 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@xxxxxxxxxxxxxx>
> ---
>  include/of.h | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/include/of.h b/include/of.h
> index 3fb6ecec8dfe..22358f5579ec 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -1038,8 +1038,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)
> @@ -1049,6 +1051,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)
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux