mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>, Rob Herring <robh@kernel.org>,
	linux-sound@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: soc-core: Stop using of_property_read_bool() for non-boolean properties
Date: Wed, 22 Jan 2025 23:43:31 +0000	[thread overview]
Message-ID: <87wmem76u4.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <db10e96fbda121e7456d70e97a013cbfc9755f4d.1737533954.git.geert+renesas@glider.be>


Hi Geert, Mark

Thank you for the patch

> On R-Car:
> 
>     OF: /sound: Read of boolean property 'simple-audio-card,bitclock-master' with a value.
>     OF: /sound: Read of boolean property 'simple-audio-card,frame-master' with a value.
> 
> or:
> 
>     OF: /soc/sound@ec500000/ports/port@0/endpoint: Read of boolean property 'bitclock-master' with a value.
>     OF: /soc/sound@ec500000/ports/port@0/endpoint: Read of boolean property 'frame-master' with a value.
> 
> The use of of_property_read_bool() for non-boolean properties is
> deprecated in favor of of_property_present() when testing for property
> presence.
> 
> Replace testing for presence before calling of_property_read_u32() by
> testing for an -EINVAL return value from the latter, to simplify the
> code.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
(snip)
> -	if (of_property_read_bool(np, "dai-tdm-slot-num")) {
> -		ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);
> -		if (ret)
> -			return ret;
> -
> -		if (slots)
> -			*slots = val;
> -	}
(snip)
> +	ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);
> +	if (ret && ret != -EINVAL)
> +		return ret;
> +	if (!ret && slots)
> +		*slots = val;

Looks good to me

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>


If my understanding was correct, old/new code should have same behavior.
But because of the original code, new code looks complex for me.
The case which this function return error are

	(A) if property does not have a value
	(B) if the property data isn't large enough

I think "DT checker" will indicates error for both case ?
If so, we can simply ignore these 2 cases. Then, the code will be more
simple

	ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);
-	if (ret && ret != -EINVAL)
-		return ret;
	if (!ret && slots)
		*slots = val;

I think this should be extra new patch (if people can agree about it).

Thank you for your help !!

Best regards
---
Kuninori Morimoto

  reply	other threads:[~2025-01-22 23:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22  8:21 Geert Uytterhoeven
2025-01-22 23:43 ` Kuninori Morimoto [this message]
2025-01-23  8:38   ` Geert Uytterhoeven
2025-01-23 22:54     ` Kuninori Morimoto
2025-01-28 20:24 ` Rob Herring
2025-02-05 12:44 ` Mark Brown

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=87wmem76u4.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=tiwai@suse.com \
    /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

all inboxes | Powered by JetHome®