Skip to content

Commit 5d4788b

Browse files
plbossartbroonie
authored andcommitted
ASoC: SOF: Intel: hda: simplify and reduce indentation for hda_sdw_machine_select()
Simplify code to return when no links are enabled. No functional change, just code cleanup before updates. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 490e6c9 commit 5d4788b

File tree

1 file changed

+73
-70
lines changed

1 file changed

+73
-70
lines changed

sound/soc/sof/intel/hda.c

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,92 +1653,95 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
16531653
hdev = pdata->hw_pdata;
16541654
link_mask = hdev->info.link_mask;
16551655

1656+
if (!link_mask) {
1657+
dev_info(sdev->dev, "SoundWire links not enabled\n");
1658+
return NULL;
1659+
}
1660+
16561661
/*
16571662
* Select SoundWire machine driver if needed using the
16581663
* alternate tables. This case deals with SoundWire-only
16591664
* machines, for mixed cases with I2C/I2S the detection relies
16601665
* on the HID list.
16611666
*/
1662-
if (link_mask) {
1663-
for (mach = pdata->desc->alt_machines;
1664-
mach && mach->link_mask; mach++) {
1665-
/*
1666-
* On some platforms such as Up Extreme all links
1667-
* are enabled but only one link can be used by
1668-
* external codec. Instead of exact match of two masks,
1669-
* first check whether link_mask of mach is subset of
1670-
* link_mask supported by hw and then go on searching
1671-
* link_adr
1672-
*/
1673-
if (~link_mask & mach->link_mask)
1674-
continue;
1675-
1676-
/* No need to match adr if there is no links defined */
1677-
if (!mach->links)
1678-
break;
1679-
1680-
link = mach->links;
1681-
for (i = 0; i < hdev->info.count && link->num_adr;
1682-
i++, link++) {
1683-
/*
1684-
* Try next machine if any expected Slaves
1685-
* are not found on this link.
1686-
*/
1687-
if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1688-
hdev->sdw->ids,
1689-
hdev->sdw->num_slaves))
1690-
break;
1691-
}
1692-
/* Found if all Slaves are checked */
1693-
if (i == hdev->info.count || !link->num_adr)
1694-
break;
1695-
}
1696-
if (mach && mach->link_mask) {
1697-
int dmic_num = 0;
1698-
bool tplg_fixup;
1699-
const char *tplg_filename;
1700-
1701-
mach->mach_params.links = mach->links;
1702-
mach->mach_params.link_mask = mach->link_mask;
1703-
mach->mach_params.platform = dev_name(sdev->dev);
1667+
for (mach = pdata->desc->alt_machines;
1668+
mach && mach->link_mask; mach++) {
1669+
/*
1670+
* On some platforms such as Up Extreme all links
1671+
* are enabled but only one link can be used by
1672+
* external codec. Instead of exact match of two masks,
1673+
* first check whether link_mask of mach is subset of
1674+
* link_mask supported by hw and then go on searching
1675+
* link_adr
1676+
*/
1677+
if (~link_mask & mach->link_mask)
1678+
continue;
17041679

1705-
if (pdata->tplg_filename) {
1706-
tplg_fixup = false;
1707-
} else {
1708-
tplg_fixup = true;
1709-
tplg_filename = mach->sof_tplg_filename;
1710-
}
1680+
/* No need to match adr if there is no links defined */
1681+
if (!mach->links)
1682+
break;
17111683

1684+
link = mach->links;
1685+
for (i = 0; i < hdev->info.count && link->num_adr;
1686+
i++, link++) {
17121687
/*
1713-
* DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1714-
* link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1715-
* if all conditions are true:
1716-
* a) 2 or fewer links are used by SoundWire
1717-
* b) the NHLT table reports the presence of microphones
1688+
* Try next machine if any expected Slaves
1689+
* are not found on this link.
17181690
*/
1719-
if (hweight_long(mach->link_mask) <= 2) {
1720-
int ret;
1721-
1722-
ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
1723-
&dmic_num, tplg_fixup);
1724-
if (ret < 0)
1725-
return NULL;
1726-
}
1727-
if (tplg_fixup)
1728-
pdata->tplg_filename = tplg_filename;
1729-
mach->mach_params.dmic_num = dmic_num;
1691+
if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1692+
hdev->sdw->ids,
1693+
hdev->sdw->num_slaves))
1694+
break;
1695+
}
1696+
/* Found if all Slaves are checked */
1697+
if (i == hdev->info.count || !link->num_adr)
1698+
break;
1699+
}
1700+
if (mach && mach->link_mask) {
1701+
int dmic_num = 0;
1702+
bool tplg_fixup;
1703+
const char *tplg_filename;
1704+
1705+
mach->mach_params.links = mach->links;
1706+
mach->mach_params.link_mask = mach->link_mask;
1707+
mach->mach_params.platform = dev_name(sdev->dev);
1708+
1709+
if (pdata->tplg_filename) {
1710+
tplg_fixup = false;
1711+
} else {
1712+
tplg_fixup = true;
1713+
tplg_filename = mach->sof_tplg_filename;
1714+
}
17301715

1731-
dev_dbg(sdev->dev,
1732-
"SoundWire machine driver %s topology %s\n",
1733-
mach->drv_name,
1734-
pdata->tplg_filename);
1716+
/*
1717+
* DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1718+
* link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1719+
* if all conditions are true:
1720+
* a) 2 or fewer links are used by SoundWire
1721+
* b) the NHLT table reports the presence of microphones
1722+
*/
1723+
if (hweight_long(mach->link_mask) <= 2) {
1724+
int ret;
17351725

1736-
return mach;
1726+
ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
1727+
&dmic_num, tplg_fixup);
1728+
if (ret < 0)
1729+
return NULL;
17371730
}
1731+
if (tplg_fixup)
1732+
pdata->tplg_filename = tplg_filename;
1733+
mach->mach_params.dmic_num = dmic_num;
17381734

1739-
dev_info(sdev->dev, "No SoundWire machine driver found\n");
1735+
dev_dbg(sdev->dev,
1736+
"SoundWire machine driver %s topology %s\n",
1737+
mach->drv_name,
1738+
pdata->tplg_filename);
1739+
1740+
return mach;
17401741
}
17411742

1743+
dev_info(sdev->dev, "No SoundWire machine driver found\n");
1744+
17421745
return NULL;
17431746
}
17441747
#else

0 commit comments

Comments
 (0)