From: Olivier MOYSAN <olivier.moysan@foss.st.com>
To: Tang Bin <tangbin@cmss.chinamobile.com>,
<arnaud.pouliquen@foss.st.com>, <lgirdwood@gmail.com>,
<broonie@kernel.org>, <perex@perex.cz>, <tiwai@suse.com>,
<mcoquelin.stm32@gmail.com>, <alexandre.torgue@foss.st.com>
Cc: alsa-devel@alsa-project.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: stm32: sai: Use of_device_get_match_data() to simplify code
Date: Mon, 23 May 2022 15:28:48 +0200 [thread overview]
Message-ID: <69d5cef3-57c0-9bc7-a83b-a85ef1c4cf29@foss.st.com> (raw)
In-Reply-To: <20220519124235.21100-1-tangbin@cmss.chinamobile.com>
Hello Tang,
Thanks for the patch. Unfortunately this patch introduces a regression.
In the SAI driver of_device_id struct the data is a simple enum cast to
void* pointer.
static const struct of_device_id stm32_sai_sub_ids[] = {
.data = (void *)STM_SAI_A_ID},
This data is an ID which can be set to 0x0.
Here we have no way to know to discriminate between an error returned by
of_device_get_match_data() or a data id set to 0x0.
The current patch requires a change in the driver.
Either changing STM_SAI_x_ID enums, or replacing data by a struct.
For instance:
struct stm32_sai_comp_data {
unsigned int id;
}
struct stm32_sai_comp_data stm32_sai_comp_data_a = {
.id = STM_SAI_A_ID;
}
struct of_device_id stm32_sai_sub_ids[] = {
.data = &stm32_sai_comp_data_a},
}
Regards
Olivier
On 5/19/22 14:42, Tang Bin wrote:
> Retrieve of match data, it's better and cleaner to use
> 'of_device_get_match_data' over 'of_match_device'.
>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
> sound/soc/stm/stm32_sai_sub.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
> index dd636af81..d300605a2 100644
> --- a/sound/soc/stm/stm32_sai_sub.c
> +++ b/sound/soc/stm/stm32_sai_sub.c
> @@ -1500,7 +1500,6 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
> static int stm32_sai_sub_probe(struct platform_device *pdev)
> {
> struct stm32_sai_sub_data *sai;
> - const struct of_device_id *of_id;
> const struct snd_dmaengine_pcm_config *conf = &stm32_sai_pcm_config;
> int ret;
>
> @@ -1508,10 +1507,9 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
> if (!sai)
> return -ENOMEM;
>
> - of_id = of_match_device(stm32_sai_sub_ids, &pdev->dev);
> - if (!of_id)
> + sai->id = (uintptr_t)of_device_get_match_data(&pdev->dev);
> + if (!sai->id)
> return -EINVAL;
> - sai->id = (uintptr_t)of_id->data;
>
> sai->pdev = pdev;
> mutex_init(&sai->ctrl_lock);
next prev parent reply other threads:[~2022-05-23 13:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 12:42 [PATCH] ASoC: stm32: sai: Use of_device_get_match_data() to simplify code Tang Bin
2022-05-23 13:28 ` Olivier MOYSAN [this message]
2022-05-23 18:57 ` Mark Brown
2022-05-24 1:44 ` [PATCH] ASoC: stm32: sai: Use of_device_get_match_data() tosimplify code tangbin
2022-05-24 14:30 ` Olivier MOYSAN
2022-05-25 7:36 ` [PATCH] ASoC: stm32: sai: Use of_device_get_match_data()tosimplify code tangbin
2022-05-25 12:30 ` Olivier MOYSAN
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=69d5cef3-57c0-9bc7-a83b-a85ef1c4cf29@foss.st.com \
--to=olivier.moysan@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=perex@perex.cz \
--cc=tangbin@cmss.chinamobile.com \
--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