summaryrefslogtreecommitdiff
path: root/sound/soc/intel
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2023-08-08 14:20:04 +0100
committerMark Brown <broonie@kernel.org>2023-08-08 18:57:17 +0100
commite1cfd5fef3d6eaf0ddbc54da70ddf54462b23592 (patch)
treefa0a896384ccceaaf732abe3599ce2a791eafb79 /sound/soc/intel
parent3003ea9cb7bd6399ca9962e0b3dd0ac58b151c2e (diff)
ASoC: intel: sof_sdw: Check link mask validity in get_dailink_info
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> Link: https://lore.kernel.org/r/20230808132013.889419-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/intel')
-rw-r--r--sound/soc/intel/boards/sof_sdw.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 89614d08d091..268629d5505c 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;