devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Use of_property_present() for testing DT property presence
@ 2023-03-10 14:47 Rob Herring
  2023-03-10 15:01 ` Amadeusz Sławiński
  2023-03-11 17:19 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Rob Herring @ 2023-03-10 14:47 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Krzysztof Kozlowski, Sylwester Nawrocki,
	Olivier Moysan, Arnaud Pouliquen, Maxime Coquelin,
	Alexandre Torgue, Thierry Reding, Jonathan Hunter
  Cc: devicetree, alsa-devel, linux-kernel, linux-arm-kernel,
	linux-stm32, linux-tegra

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@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"))
 			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"))
 			return info.id;
 
 		node = of_get_parent(ep);
diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c
index 746f40938675..a55e7256a4c3 100644
--- a/sound/soc/mxs/mxs-sgtl5000.c
+++ b/sound/soc/mxs/mxs-sgtl5000.c
@@ -150,7 +150,7 @@ static int mxs_sgtl5000_probe(struct platform_device *pdev)
 
 	card->dev = &pdev->dev;
 
-	if (of_find_property(np, "audio-routing", NULL)) {
+	if (of_property_present(np, "audio-routing")) {
 		card->dapm_widgets = mxs_sgtl5000_dapm_widgets;
 		card->num_dapm_widgets = ARRAY_SIZE(mxs_sgtl5000_dapm_widgets);
 
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 6f96032090de..083e278aa021 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1289,7 +1289,7 @@ static int i2s_register_clock_provider(struct samsung_i2s_priv *priv)
 	int ret, i;
 
 	/* Register the clock provider only if it's expected in the DTB */
-	if (!of_find_property(dev->of_node, "#clock-cells", NULL))
+	if (!of_property_present(dev->of_node, "#clock-cells"))
 		return 0;
 
 	/* Get the RCLKSRC mux clock parent clock names */
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index f3edc2e3d9d7..9f3f1af6349f 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -1855,7 +1855,7 @@ static void fsi_of_parse(char *name,
 
 	for (i = 0; i < ARRAY_SIZE(of_parse_property); i++) {
 		sprintf(prop, "%s,%s", name, of_parse_property[i].name);
-		if (of_get_property(np, prop, NULL))
+		if (of_property_present(np, prop))
 			flags |= of_parse_property[i].val;
 	}
 	info->flags = flags;
diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index f3dd9f8e621c..9dad85ecb93f 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -1066,7 +1066,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,
 				     "Could not get x11k parent clock\n");
 
 	/* Register mclk provider if requested */
-	if (of_find_property(np, "#clock-cells", NULL)) {
+	if (of_property_present(np, "#clock-cells")) {
 		ret = stm32_i2s_add_mclk_provider(i2s);
 		if (ret < 0)
 			return ret;
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index eb31b49e6597..8ba4206f751d 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -1394,7 +1394,7 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
 
 	/* Get spdif iec60958 property */
 	sai->spdif = false;
-	if (of_get_property(np, "st,iec60958", NULL)) {
+	if (of_property_present(np, "st,iec60958")) {
 		if (!STM_SAI_HAS_SPDIF(sai) ||
 		    sai->dir == SNDRV_PCM_STREAM_CAPTURE) {
 			dev_err(&pdev->dev, "S/PDIF IEC60958 not supported\n");
@@ -1480,7 +1480,7 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
 		return 0;
 
 	/* Register mclk provider if requested */
-	if (of_find_property(np, "#clock-cells", NULL)) {
+	if (of_property_present(np, "#clock-cells")) {
 		ret = stm32_sai_add_mclk_provider(sai);
 		if (ret < 0)
 			return ret;
diff --git a/sound/soc/tegra/tegra_asoc_machine.c b/sound/soc/tegra/tegra_asoc_machine.c
index 78faa8bcae27..2dc1f44c5a8b 100644
--- a/sound/soc/tegra/tegra_asoc_machine.c
+++ b/sound/soc/tegra/tegra_asoc_machine.c
@@ -502,7 +502,7 @@ int tegra_asoc_machine_probe(struct platform_device *pdev)
 	 * If clock parents are not set in DT, configure here to use clk_out_1
 	 * as mclk and extern1 as parent for Tegra30 and higher.
 	 */
-	if (!of_find_property(dev->of_node, "assigned-clock-parents", NULL) &&
+	if (!of_property_present(dev->of_node, "assigned-clock-parents") &&
 	    !of_machine_is_compatible("nvidia,tegra20")) {
 		struct clk *clk_out_1, *clk_extern1;
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: Use of_property_present() for testing DT property presence
  2023-03-10 14:47 [PATCH] ASoC: Use of_property_present() for testing DT property presence Rob Herring
@ 2023-03-10 15:01 ` Amadeusz Sławiński
  2023-03-10 15:14   ` Rob Herring
  2023-03-11 17:19 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Amadeusz Sławiński @ 2023-03-10 15:01 UTC (permalink / raw)
  To: Rob Herring, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Krzysztof Kozlowski,
	Sylwester Nawrocki, Olivier Moysan, Arnaud Pouliquen,
	Maxime Coquelin, Alexandre Torgue, Thierry Reding,
	Jonathan Hunter
  Cc: devicetree, alsa-devel, linux-kernel, linux-arm-kernel,
	linux-stm32, linux-tegra

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@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?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: Use of_property_present() for testing DT property presence
  2023-03-10 15:01 ` Amadeusz Sławiński
@ 2023-03-10 15:14   ` Rob Herring
  2023-03-10 15:31     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2023-03-10 15:14 UTC (permalink / raw)
  To: Amadeusz Sławiński
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Krzysztof Kozlowski, Sylwester Nawrocki,
	Olivier Moysan, Arnaud Pouliquen, Maxime Coquelin,
	Alexandre Torgue, Thierry Reding, Jonathan Hunter, devicetree,
	alsa-devel, linux-kernel, linux-arm-kernel, linux-stm32,
	linux-tegra

On Fri, Mar 10, 2023 at 9:01 AM Amadeusz Sławiński
<amadeuszx.slawinski@linux.intel.com> wrote:
>
> 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@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?

Only because there was before and it was a scripted change.

Rob

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: Use of_property_present() for testing DT property presence
  2023-03-10 15:14   ` Rob Herring
@ 2023-03-10 15:31     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-03-10 15:31 UTC (permalink / raw)
  To: Rob Herring
  Cc: Amadeusz Sławiński, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Krzysztof Kozlowski,
	Sylwester Nawrocki, Olivier Moysan, Arnaud Pouliquen,
	Maxime Coquelin, Alexandre Torgue, Thierry Reding,
	Jonathan Hunter, devicetree, alsa-devel, linux-kernel,
	linux-arm-kernel, linux-stm32, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

On Fri, Mar 10, 2023 at 09:14:08AM -0600, Rob Herring wrote:
> On Fri, Mar 10, 2023 at 9:01 AM Amadeusz Sławiński
> > On 3/10/2023 3:47 PM, Rob Herring wrote:

> > > -             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?

> Only because there was before and it was a scripted change.

Yeah, I don't think there's any reason for that - perhaps at some
point it caused the code to line up?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: Use of_property_present() for testing DT property presence
  2023-03-10 14:47 [PATCH] ASoC: Use of_property_present() for testing DT property presence Rob Herring
  2023-03-10 15:01 ` Amadeusz Sławiński
@ 2023-03-11 17:19 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-03-11 17:19 UTC (permalink / raw)
  To: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Krzysztof Kozlowski, Sylwester Nawrocki,
	Olivier Moysan, Arnaud Pouliquen, Maxime Coquelin,
	Alexandre Torgue, Thierry Reding, Jonathan Hunter, Rob Herring
  Cc: devicetree, alsa-devel, linux-kernel, linux-arm-kernel,
	linux-stm32, linux-tegra

On Fri, 10 Mar 2023 08:47:31 -0600, 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.
> 
> [...]

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] ASoC: Use of_property_present() for testing DT property presence
      commit: 1e108e60a44a924e3666fa2a10b53f6c31522856

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-11 17:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 14:47 [PATCH] ASoC: Use of_property_present() for testing DT property presence Rob Herring
2023-03-10 15:01 ` Amadeusz Sławiński
2023-03-10 15:14   ` Rob Herring
2023-03-10 15:31     ` Mark Brown
2023-03-11 17:19 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).