struct snd_soc_dapm_path *path;
struct snd_soc_dai *source, *sink;
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_pcm_hw_params *params = NULL;
const struct snd_soc_pcm_stream *config = NULL;
struct snd_pcm_runtime *runtime = NULL;
unsigned int fmt;
- int ret = 0;
+ int ret;
/*
* NOTE
* stuff that increases stack usage.
* So, we use kzalloc()/kfree() for params in this function.
*/
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ struct snd_pcm_hw_params *params __free(kfree) = kzalloc(sizeof(*params),
+ GFP_KERNEL);
if (!params)
return -ENOMEM;
runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
- if (!runtime) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!runtime)
+ return -ENOMEM;
substream->runtime = runtime;
ret = snd_soc_dai_startup(source, substream);
if (ret < 0)
- goto out;
+ return ret;
snd_soc_dai_activate(source, substream->stream);
}
ret = snd_soc_dai_startup(sink, substream);
if (ret < 0)
- goto out;
+ return ret;
snd_soc_dai_activate(sink, substream->stream);
}
config = rtd->dai_link->c2c_params + rtd->c2c_params_select;
if (!config) {
dev_err(w->dapm->dev, "ASoC: link config missing\n");
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
/* Be a little careful as we don't want to overflow the mask array */
if (!config->formats) {
dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n");
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
fmt = ffs(config->formats) - 1;
ret = snd_soc_dai_hw_params(source, substream, params);
if (ret < 0)
- goto out;
+ return ret;
dapm_update_dai_unlocked(substream, params, source);
}
ret = snd_soc_dai_hw_params(sink, substream, params);
if (ret < 0)
- goto out;
+ return ret;
dapm_update_dai_unlocked(substream, params, sink);
}
runtime->channels = params_channels(params);
runtime->rate = params_rate(params);
-out:
- /* see above NOTE */
- kfree(params);
-
- return ret;
+ return 0;
}
static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,