[PATCH] ASoC: Use of_property_present() for testing DT property presence

Amadeusz Sławiński amadeuszx.slawinski at linux.intel.com
Fri Mar 10 07:01:45 PST 2023


On 3/10/2023 3:47 PM, Rob Herring wrote:
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties. As
> part of this, convert of_get_property/of_find_property calls to the
> recently added of_property_present() helper when we just want to test
> for presence of a property and nothing more.
> 
> Signed-off-by: Rob Herring <robh at kernel.org>
> ---
>   sound/soc/codecs/lpass-macro-common.c | 2 +-
>   sound/soc/generic/audio-graph-card.c  | 2 +-
>   sound/soc/generic/audio-graph-card2.c | 2 +-
>   sound/soc/mxs/mxs-sgtl5000.c          | 2 +-
>   sound/soc/samsung/i2s.c               | 2 +-
>   sound/soc/sh/fsi.c                    | 2 +-
>   sound/soc/stm/stm32_i2s.c             | 2 +-
>   sound/soc/stm/stm32_sai_sub.c         | 4 ++--
>   sound/soc/tegra/tegra_asoc_machine.c  | 2 +-
>   9 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c
> index 1b9082d237c1..f54baaad54d4 100644
> --- a/sound/soc/codecs/lpass-macro-common.c
> +++ b/sound/soc/codecs/lpass-macro-common.c
> @@ -16,7 +16,7 @@ struct lpass_macro *lpass_macro_pds_init(struct device *dev)
>   	struct lpass_macro *l_pds;
>   	int ret;
>   
> -	if (!of_find_property(dev->of_node, "power-domains", NULL))
> +	if (!of_property_present(dev->of_node, "power-domains"))
>   		return NULL;
>   
>   	l_pds = devm_kzalloc(dev, sizeof(*l_pds), GFP_KERNEL);
> diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
> index 5daa824a4ffc..d788f5f23a8a 100644
> --- a/sound/soc/generic/audio-graph-card.c
> +++ b/sound/soc/generic/audio-graph-card.c
> @@ -78,7 +78,7 @@ static int graph_get_dai_id(struct device_node *ep)
>   		 * only of_graph_parse_endpoint().
>   		 * We need to check "reg" property
>   		 */
> -		if (of_get_property(ep,   "reg", NULL))
> +		if (of_property_present(ep,   "reg"))

Bit of nit picking, but any reason, why there are multiple spaces, 
before "reg" here?

>   			return info.id;
>   
>   		node = of_get_parent(ep);
> diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
> index 06609a526b78..259544f64df9 100644
> --- a/sound/soc/generic/audio-graph-card2.c
> +++ b/sound/soc/generic/audio-graph-card2.c
> @@ -376,7 +376,7 @@ static int graph_get_dai_id(struct device_node *ep)
>   		 * only of_graph_parse_endpoint().
>   		 * We need to check "reg" property
>   		 */
> -		if (of_get_property(ep,   "reg", NULL))
> +		if (of_property_present(ep,   "reg"))

And here?





More information about the linux-arm-kernel mailing list