Commit 961e6947 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: intel: sof_sdw: Only pass codec_conf pointer around

Rather than passing around a pointer to the codec_conf array, an index
into it and a size, simply pass around a pointer to the current codec_conf.
This reduces the amount of state moving around.
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240326160429.13560-5-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1329f5b0
...@@ -1457,10 +1457,8 @@ static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic" ...@@ -1457,10 +1457,8 @@ static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"
static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
struct snd_soc_dai_link *dai_links, int sdw_be_num, struct snd_soc_dai_link *dai_links, int sdw_be_num,
const struct snd_soc_acpi_link_adr *adr_link, const struct snd_soc_acpi_link_adr *adr_link,
struct snd_soc_codec_conf *codec_conf, struct snd_soc_codec_conf **codec_conf,
int codec_count, int *be_id, int *be_id, bool *ignore_pch_dmic,
int *codec_conf_index,
bool *ignore_pch_dmic,
bool append_dai_type, bool append_dai_type,
int adr_index, int adr_index,
int dai_index) int dai_index)
...@@ -1509,7 +1507,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1509,7 +1507,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
continue; continue;
/* sanity check */ /* sanity check */
if (*codec_conf_index >= codec_count) { if (*codec_conf >= card->codec_conf + card->num_configs) {
dev_err(dev, "codec_conf array overflowed\n"); dev_err(dev, "codec_conf array overflowed\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1520,12 +1518,11 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1520,12 +1518,11 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
if (ret) if (ret)
return ret; return ret;
codec_conf[*codec_conf_index].dlc = codecs[codec_dlc_index]; (*codec_conf)->dlc = codecs[codec_dlc_index];
codec_conf[*codec_conf_index].name_prefix = (*codec_conf)->name_prefix = adr_link_next->adr_d[j].name_prefix;
adr_link_next->adr_d[j].name_prefix;
codec_dlc_index++; codec_dlc_index++;
(*codec_conf_index)++; (*codec_conf)++;
} }
j = 0; j = 0;
...@@ -1646,7 +1643,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) ...@@ -1646,7 +1643,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
bool append_dai_type = false; bool append_dai_type = false;
bool ignore_pch_dmic = false; bool ignore_pch_dmic = false;
int codec_conf_num = 0; int codec_conf_num = 0;
int codec_conf_index = 0;
bool group_generated[SDW_MAX_GROUPS] = { }; bool group_generated[SDW_MAX_GROUPS] = { };
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
int num_links, link_index = 0; int num_links, link_index = 0;
...@@ -1706,6 +1702,9 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) ...@@ -1706,6 +1702,9 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
if (!codec_conf) if (!codec_conf)
return -ENOMEM; return -ENOMEM;
card->codec_conf = codec_conf;
card->num_configs = codec_conf_num;
/* SDW */ /* SDW */
if (!sdw_be_num) if (!sdw_be_num)
goto SSP; goto SSP;
...@@ -1764,9 +1763,9 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) ...@@ -1764,9 +1763,9 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
ret = create_sdw_dailink(card, &link_index, dai_links, ret = create_sdw_dailink(card, &link_index, dai_links,
sdw_be_num, adr_link, sdw_be_num, adr_link,
codec_conf, codec_conf_num, &codec_conf, &current_be_id,
&current_be_id, &codec_conf_index, &ignore_pch_dmic,
&ignore_pch_dmic, append_dai_type, i, j); append_dai_type, i, j);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to create dai link %d\n", link_index); dev_err(dev, "failed to create dai link %d\n", link_index);
return ret; return ret;
...@@ -1886,9 +1885,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) ...@@ -1886,9 +1885,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
card->dai_link = dai_links; card->dai_link = dai_links;
card->num_links = num_links; card->num_links = num_links;
card->codec_conf = codec_conf;
card->num_configs = codec_conf_num;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment