mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] of: implement of_property_present helper
Date: Mon, 3 Apr 2023 09:05:27 +0200	[thread overview]
Message-ID: <20230403070527.GP19113@pengutronix.de> (raw)
In-Reply-To: <20230331090453.1424337-1-a.fatoum@pengutronix.de>

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@pengutronix.de>
> ---
>  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 |



      reply	other threads:[~2023-04-03  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  9:04 Ahmad Fatoum
2023-04-03  7:05 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230403070527.GP19113@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox