[PATCH 1/4] ASoC: soc-dapm.c: don't use kzalloc() for param on snd_soc_dai_link_event_pre_pmu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

Current snd_soc_dai_link_event_pre_pmu() is using kzalloc() / kfree()
for "params", but it is fixed size, and not used on private data.
It is used for setup rtd at end of this function, just a local variable.
We don't need to use kzalloc() / kfree() for it.
This patch replace it as local variable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 sound/soc/soc-dapm.c | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 73b8bd452ca7..7d4e4068f870 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3837,15 +3837,13 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 	struct snd_soc_dapm_path *path;
 	struct snd_soc_dai *source, *sink;
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-	struct snd_pcm_hw_params *params = NULL;
+	struct snd_pcm_hw_params params;
 	const struct snd_soc_pcm_stream *config = NULL;
 	struct snd_pcm_runtime *runtime = NULL;
 	unsigned int fmt;
 	int ret = 0;
 
-	params = kzalloc(sizeof(*params), GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
+	memset(&params, 0, sizeof(params));
 
 	runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
 	if (!runtime) {
@@ -3902,45 +3900,39 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 		goto out;
 	}
 
-	snd_mask_set(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), fmt);
-	hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min =
-		config->rate_min;
-	hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max =
-		config->rate_max;
-	hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min
-		= config->channels_min;
-	hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max
-		= config->channels_max;
+	snd_mask_set(hw_param_mask(&params, SNDRV_PCM_HW_PARAM_FORMAT), fmt);
+	hw_param_interval(&params, SNDRV_PCM_HW_PARAM_RATE)->min	= config->rate_min;
+	hw_param_interval(&params, SNDRV_PCM_HW_PARAM_RATE)->max	= config->rate_max;
+	hw_param_interval(&params, SNDRV_PCM_HW_PARAM_CHANNELS)->min	= config->channels_min;
+	hw_param_interval(&params, SNDRV_PCM_HW_PARAM_CHANNELS)->max	= config->channels_max;
 
 	substream->stream = SNDRV_PCM_STREAM_CAPTURE;
 	snd_soc_dapm_widget_for_each_source_path(w, path) {
 		source = path->source->priv;
 
-		ret = snd_soc_dai_hw_params(source, substream, params);
+		ret = snd_soc_dai_hw_params(source, substream, &params);
 		if (ret < 0)
 			goto out;
 
-		dapm_update_dai_unlocked(substream, params, source);
+		dapm_update_dai_unlocked(substream, &params, source);
 	}
 
 	substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
 	snd_soc_dapm_widget_for_each_sink_path(w, path) {
 		sink = path->sink->priv;
 
-		ret = snd_soc_dai_hw_params(sink, substream, params);
+		ret = snd_soc_dai_hw_params(sink, substream, &params);
 		if (ret < 0)
 			goto out;
 
-		dapm_update_dai_unlocked(substream, params, sink);
+		dapm_update_dai_unlocked(substream, &params, sink);
 	}
 
-	runtime->format = params_format(params);
-	runtime->subformat = params_subformat(params);
-	runtime->channels = params_channels(params);
-	runtime->rate = params_rate(params);
-
+	runtime->format		= params_format(&params);
+	runtime->subformat	= params_subformat(&params);
+	runtime->channels	= params_channels(&params);
+	runtime->rate		= params_rate(&params);
 out:
-	kfree(params);
 	return ret;
 }
 
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux