public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurentiu Mihalcea <laurentiumihalcea111@gmail.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] ASoC: simple-card-utils: fix priv->dai_props indexing
Date: Wed, 8 Jan 2025 13:00:51 +0200	[thread overview]
Message-ID: <197add46-752d-4779-98ff-1cde2543dd63@gmail.com> (raw)
In-Reply-To: <87h66v8bsc.wl-kuninori.morimoto.gx@renesas.com>



On 12/23/2024 2:48 AM, Kuninori Morimoto wrote:
> Hi Laurentiu
>
> Thank you for the patch
>
>> As of commit cb18cd26039f ("ASoC: soc-core: do rtd->id trick at
>> snd_soc_add_pcm_runtime()") the ID stored in the PCM runtime data can
>> no longer be safely used to index the priv->dai_props array. This is
>> because the ID may be modified during snd_soc_add_pcm_runtime(), thus
>> resulting in an ID that's no longer a valid array index.
>>
>> To fix this, use the position of the dai_link stored inside the PCM
>> runtime data relative to the start of the dai_link array as index into
>> the priv->dai_props array.
>>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> (snip)
>> +#define runtime_simple_priv_to_props(priv, rtd)					\
>> +	((priv)->dai_props + ((rtd)->dai_link - (priv)->dai_link))
> Oh yes, indeed.
>
> But I wonder it is needed not only utils, but all drivers
> (= simple-card/audio-graph-card/audio-graph-card2).

At this point I'd say there's no need to do the replacement anywhere else. That's because the code
still using simple_priv_to_props() makes use of the link number to index the array, which is fine.
This is opposed to the PCM runtime data ID that may not correspond to a link number, thus making it
unfit for use as an array index.

>
> Why don't you just replace macro ?
>
> 	- #define simple_priv_to_props(priv, i) // old macro
> 	+ #define simple_priv_to_props(priv, i) // new macro
>
> Or, do you have any reasons ?
>
> In replase case, we would like to have the comment not only git-log but
> on header too.
>
>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto

Thanks for taking your time to review this and sorry for the (very) late reply!

  reply	other threads:[~2025-01-08 11:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 15:12 [PATCH RFC] ASoC: simple-card-utils: fix priv->dai_props indexing Laurentiu Mihalcea
2024-12-23  0:48 ` Kuninori Morimoto
2025-01-08 11:00   ` Laurentiu Mihalcea [this message]
2025-01-09  0:07     ` Kuninori Morimoto
2025-01-10  0:26       ` Laurentiu Mihalcea
2025-01-10  2:25         ` Kuninori Morimoto
2025-01-11  1:10           ` Laurentiu Mihalcea

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=197add46-752d-4779-98ff-1cde2543dd63@gmail.com \
    --to=laurentiumihalcea111@gmail.com \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --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