mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 21:45:08 -04:00
ASoC: intel: sof_sdw: Simplify get_slave_info
Now the first device on a link is not treated specially there is no need to have a separate loop to handle the current link over the future links, as the logic is identical. Combine this all into a single processing loop. 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-12-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
317dcdecaf
commit
7f5cf19703
@@ -1265,57 +1265,43 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
|
||||
int *codec_num, unsigned int *group_id,
|
||||
int adr_index)
|
||||
{
|
||||
const struct snd_soc_acpi_adr_device *adr_d;
|
||||
const struct snd_soc_acpi_link_adr *adr_next;
|
||||
bool no_aggregation;
|
||||
int index = 0;
|
||||
bool no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION;
|
||||
int i;
|
||||
|
||||
no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION;
|
||||
adr_d = &adr_link->adr_d[adr_index];
|
||||
|
||||
cpu_dai_id[index++] = ffs(adr_link->mask) - 1;
|
||||
if (!adr_d->endpoints->aggregated || no_aggregation) {
|
||||
if (!adr_link->adr_d[adr_index].endpoints->aggregated || no_aggregation) {
|
||||
cpu_dai_id[0] = ffs(adr_link->mask) - 1;
|
||||
*cpu_dai_num = 1;
|
||||
*codec_num = 1;
|
||||
*group_id = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*group_id = adr_d->endpoints->group_id;
|
||||
*codec_num = 0;
|
||||
*cpu_dai_num = 0;
|
||||
*group_id = adr_link->adr_d[adr_index].endpoints->group_id;
|
||||
|
||||
/* Count endpoints with the same group_id in the adr_link */
|
||||
*codec_num = 0;
|
||||
for (i = 0; i < adr_link->num_adr; i++) {
|
||||
if (adr_link->adr_d[i].endpoints->aggregated &&
|
||||
adr_link->adr_d[i].endpoints->group_id == *group_id)
|
||||
(*codec_num)++;
|
||||
}
|
||||
|
||||
/* gather other link ID of slaves in the same group */
|
||||
for (adr_next = adr_link + 1; adr_next && adr_next->num_adr; adr_next++) {
|
||||
for (; adr_link && adr_link->num_adr; adr_link++) {
|
||||
unsigned int link_codecs = 0;
|
||||
|
||||
for (i = 0; i < adr_next->num_adr; i++) {
|
||||
if (adr_next->adr_d[i].endpoints->aggregated &&
|
||||
adr_next->adr_d[i].endpoints->group_id == *group_id)
|
||||
for (i = 0; i < adr_link->num_adr; i++) {
|
||||
if (adr_link->adr_d[i].endpoints->aggregated &&
|
||||
adr_link->adr_d[i].endpoints->group_id == *group_id)
|
||||
link_codecs++;
|
||||
}
|
||||
|
||||
if (link_codecs) {
|
||||
*codec_num += link_codecs;
|
||||
|
||||
if (index >= SDW_MAX_CPU_DAIS) {
|
||||
if (*cpu_dai_num >= SDW_MAX_CPU_DAIS) {
|
||||
dev_err(dev, "cpu_dai_id array overflowed\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cpu_dai_id[index++] = ffs(adr_next->mask) - 1;
|
||||
cpu_dai_id[(*cpu_dai_num)++] = ffs(adr_link->mask) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
*cpu_dai_num = index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user