Skip to content

Commit b9d59f9

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: avs: Remove redundancy around DAI shutdown
Move avs_dai_nonhda_be_shutdown() to avs_dai_shutdown() as the function is common for all transfer types, not just non-HDAudio ones. Use it to simplify avs_dai_fe_shutdown(). While at it, fix explicit kfree(data) and use the destructor instead. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 140df6d commit b9d59f9

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

sound/soc/intel/avs/pcm.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_d
8585
return 0;
8686
}
8787

88+
static void avs_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
89+
{
90+
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
91+
struct avs_dev *adev = to_avs_dev(dai->dev);
92+
struct avs_dma_data *data;
93+
94+
data = snd_soc_dai_get_dma_data(dai, substream);
95+
96+
if (rtd->dai_link->ignore_suspend)
97+
adev->num_lp_paths--;
98+
99+
snd_soc_dai_set_dma_data(dai, substream, NULL);
100+
kfree(data);
101+
}
102+
88103
static int avs_dai_hw_params(struct snd_pcm_substream *substream,
89104
struct snd_pcm_hw_params *fe_hw_params,
90105
struct snd_pcm_hw_params *be_hw_params, struct snd_soc_dai *dai,
@@ -166,21 +181,6 @@ static int avs_dai_nonhda_be_startup(struct snd_pcm_substream *substream, struct
166181
return avs_dai_startup(substream, dai, false, &avs_dai_nonhda_be_ops);
167182
}
168183

169-
static void avs_dai_nonhda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
170-
{
171-
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
172-
struct avs_dev *adev = to_avs_dev(dai->dev);
173-
struct avs_dma_data *data;
174-
175-
if (rtd->dai_link->ignore_suspend)
176-
adev->num_lp_paths--;
177-
178-
data = snd_soc_dai_get_dma_data(dai, substream);
179-
180-
snd_soc_dai_set_dma_data(dai, substream, NULL);
181-
kfree(data);
182-
}
183-
184184
static int avs_dai_nonhda_be_hw_params(struct snd_pcm_substream *substream,
185185
struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai)
186186
{
@@ -266,7 +266,7 @@ static int avs_dai_nonhda_be_trigger(struct snd_pcm_substream *substream, int cm
266266

267267
static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = {
268268
.startup = avs_dai_nonhda_be_startup,
269-
.shutdown = avs_dai_nonhda_be_shutdown,
269+
.shutdown = avs_dai_shutdown,
270270
.hw_params = avs_dai_nonhda_be_hw_params,
271271
.hw_free = avs_dai_nonhda_be_hw_free,
272272
.prepare = avs_dai_nonhda_be_prepare,
@@ -290,7 +290,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
290290
link_stream = snd_hdac_ext_stream_assign(&codec->bus->core, substream,
291291
HDAC_EXT_STREAM_TYPE_LINK);
292292
if (!link_stream) {
293-
avs_dai_nonhda_be_shutdown(substream, dai);
293+
avs_dai_shutdown(substream, dai);
294294
return -EBUSY;
295295
}
296296

@@ -306,7 +306,7 @@ static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct
306306
snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK);
307307
substream->runtime->private_data = NULL;
308308

309-
avs_dai_nonhda_be_shutdown(substream, dai);
309+
avs_dai_shutdown(substream, dai);
310310
}
311311

312312
static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream,
@@ -558,18 +558,12 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so
558558

559559
static void avs_dai_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
560560
{
561-
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
562-
struct avs_dev *adev = to_avs_dev(dai->dev);
563561
struct avs_dma_data *data;
564562

565-
if (rtd->dai_link->ignore_suspend)
566-
adev->num_lp_paths--;
567-
568563
data = snd_soc_dai_get_dma_data(dai, substream);
569564

570-
snd_soc_dai_set_dma_data(dai, substream, NULL);
571565
snd_hdac_ext_stream_release(data->host_stream, HDAC_EXT_STREAM_TYPE_HOST);
572-
kfree(data);
566+
avs_dai_shutdown(substream, dai);
573567
}
574568

575569
static int avs_dai_fe_hw_params(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)