From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <lgirdwood@gmail.com>, <cezary.rojewski@intel.com>,
<peter.ujfalusi@linux.intel.com>,
<ranjani.sridharan@linux.intel.com>,
<kai.vehmanen@linux.intel.com>, <yung-chuan.liao@linux.intel.com>,
<pierre-louis.bossart@linux.intel.com>,
<alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>
Subject: [PATCH 03/12] ASoC: intel: sof_sdw: Check link mask validity in get_dailink_info
Date: Tue, 8 Aug 2023 14:20:04 +0100 [thread overview]
Message-ID: <20230808132013.889419-3-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20230808132013.889419-1-ckeepax@opensource.cirrus.com>
As get_dailink_info spins through all the links anyway simply check the
link masks there. This saves an extra check and means the code will
fail earlier if the mask is invalid.
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/intel/boards/sof_sdw.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 89614d08d0918..268629d5505c3 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -1053,6 +1053,10 @@ static int get_dailink_info(struct device *dev,
int stream;
u64 adr;
+ /* make sure the link mask has a single bit set */
+ if (!is_power_of_2(adr_link->mask))
+ return -EINVAL;
+
for (i = 0; i < adr_link->num_adr; i++) {
adr = adr_link->adr_d[i].adr;
codec_index = find_codec_info_part(adr);
@@ -1302,10 +1306,6 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION;
adr_d = &adr_link->adr_d[adr_index];
- /* make sure the link mask has a single bit set */
- if (!is_power_of_2(adr_link->mask))
- return -EINVAL;
-
cpu_dai_id[index++] = ffs(adr_link->mask) - 1;
if (!adr_d->endpoints->aggregated || no_aggregation) {
*cpu_dai_num = 1;
@@ -1334,10 +1334,6 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
endpoint->group_id != *group_id)
continue;
- /* make sure the link mask has a single bit set */
- if (!is_power_of_2(adr_next->mask))
- return -EINVAL;
-
if (index >= SDW_MAX_CPU_DAIS) {
dev_err(dev, "cpu_dai_id array overflows\n");
return -EINVAL;
--
2.30.2
next prev parent reply other threads:[~2023-08-08 13:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 13:20 [PATCH 01/12] ASoC: intel: sof_sdw: Printk's should end with a newline Charles Keepax
2023-08-08 13:20 ` [PATCH 02/12] ASoC: intel: sof_sdw: Remove duplicate NULL check on adr_link Charles Keepax
2023-08-08 13:20 ` Charles Keepax [this message]
2023-08-08 13:20 ` [PATCH 04/12] ASoC: intel: sof-sdw: Move check for valid group id to get_dailink_info Charles Keepax
2023-08-08 13:20 ` [PATCH 05/12] ASoC: intel: sof_sdw: Add helper to create a single codec DLC Charles Keepax
2023-08-08 13:20 ` [PATCH 06/12] ASoC: intel: sof_sdw: Pull device loop up into create_sdw_dailink Charles Keepax
2023-08-08 13:20 ` [PATCH 07/12] ASoC: intel: sof_sdw: Update DLC index each time one is added Charles Keepax
2023-08-08 13:20 ` [PATCH 08/12] ASoC: intel: sof_sdw: Move range check of codec_conf into inner loop Charles Keepax
2023-08-08 13:20 ` [PATCH 09/12] ASoC: intel: sof_sdw: Device loop should not always start at adr_index Charles Keepax
2023-08-08 13:20 ` [PATCH 10/12] ASoC: intel: sof_sdw: Support multiple groups on the same link Charles Keepax
2023-08-08 13:20 ` [PATCH 11/12] ASoC: intel: sof_sdw: Allow different devices " Charles Keepax
2023-08-08 13:20 ` [PATCH 12/12] ASoC: intel: sof_sdw: Simplify get_slave_info Charles Keepax
2023-08-08 20:32 ` [PATCH 01/12] ASoC: intel: sof_sdw: Printk's should end with a newline 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=20230808132013.889419-3-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=yung-chuan.liao@linux.intel.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;
as well as URLs for NNTP newsgroup(s).