Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Charles Keepax and committed by
Mark Brown
7f5cf197 317dcdec

+12 -26
+12 -26
sound/soc/intel/boards/sof_sdw.c
··· 1265 1265 int *codec_num, unsigned int *group_id, 1266 1266 int adr_index) 1267 1267 { 1268 - const struct snd_soc_acpi_adr_device *adr_d; 1269 - const struct snd_soc_acpi_link_adr *adr_next; 1270 - bool no_aggregation; 1271 - int index = 0; 1268 + bool no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION; 1272 1269 int i; 1273 1270 1274 - no_aggregation = sof_sdw_quirk & SOF_SDW_NO_AGGREGATION; 1275 - adr_d = &adr_link->adr_d[adr_index]; 1276 - 1277 - cpu_dai_id[index++] = ffs(adr_link->mask) - 1; 1278 - if (!adr_d->endpoints->aggregated || no_aggregation) { 1271 + if (!adr_link->adr_d[adr_index].endpoints->aggregated || no_aggregation) { 1272 + cpu_dai_id[0] = ffs(adr_link->mask) - 1; 1279 1273 *cpu_dai_num = 1; 1280 1274 *codec_num = 1; 1281 1275 *group_id = 0; 1282 1276 return 0; 1283 1277 } 1284 1278 1285 - *group_id = adr_d->endpoints->group_id; 1279 + *codec_num = 0; 1280 + *cpu_dai_num = 0; 1281 + *group_id = adr_link->adr_d[adr_index].endpoints->group_id; 1286 1282 1287 1283 /* Count endpoints with the same group_id in the adr_link */ 1288 - *codec_num = 0; 1289 - for (i = 0; i < adr_link->num_adr; i++) { 1290 - if (adr_link->adr_d[i].endpoints->aggregated && 1291 - adr_link->adr_d[i].endpoints->group_id == *group_id) 1292 - (*codec_num)++; 1293 - } 1294 - 1295 - /* gather other link ID of slaves in the same group */ 1296 - for (adr_next = adr_link + 1; adr_next && adr_next->num_adr; adr_next++) { 1284 + for (; adr_link && adr_link->num_adr; adr_link++) { 1297 1285 unsigned int link_codecs = 0; 1298 1286 1299 - for (i = 0; i < adr_next->num_adr; i++) { 1300 - if (adr_next->adr_d[i].endpoints->aggregated && 1301 - adr_next->adr_d[i].endpoints->group_id == *group_id) 1287 + for (i = 0; i < adr_link->num_adr; i++) { 1288 + if (adr_link->adr_d[i].endpoints->aggregated && 1289 + adr_link->adr_d[i].endpoints->group_id == *group_id) 1302 1290 link_codecs++; 1303 1291 } 1304 1292 1305 1293 if (link_codecs) { 1306 1294 *codec_num += link_codecs; 1307 1295 1308 - if (index >= SDW_MAX_CPU_DAIS) { 1296 + if (*cpu_dai_num >= SDW_MAX_CPU_DAIS) { 1309 1297 dev_err(dev, "cpu_dai_id array overflowed\n"); 1310 1298 return -EINVAL; 1311 1299 } 1312 1300 1313 - cpu_dai_id[index++] = ffs(adr_next->mask) - 1; 1301 + cpu_dai_id[(*cpu_dai_num)++] = ffs(adr_link->mask) - 1; 1314 1302 } 1315 1303 } 1316 - 1317 - *cpu_dai_num = index; 1318 1304 1319 1305 return 0; 1320 1306 }