[PATCH 2/2] ASoC: soc-dapm.c: tidyup snd_soc_dai_link_event_pre_pmu()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Thu Sep 8 04:45:27 CEST 2022
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
snd_soc_dai_link_event_pre_pmu() is using if/else for config->formats
check, but "else" case is for just error.
Unnecessary if/else is not good for readable code. this patch checks
if config->formats was zero as error case.
Moreover, we don't need to indicate config->formats value in error message,
because it is zero. This patch tidyup it, too.
=> if (config->formats) {
...
} else {
dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n",
=> config->formats);
...
}
Link: https://lore.kernel.org/all/YxiDkDOwRsbXeZ17@sirena.org.uk/
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
sound/soc/soc-dapm.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index fc2f75ed190d..47a7bf99472e 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3900,16 +3900,15 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
}
/* Be a little careful as we don't want to overflow the mask array */
- if (config->formats) {
- fmt = ffs(config->formats) - 1;
- } else {
- dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n",
- config->formats);
+ if (!config->formats) {
+ dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n");
ret = -EINVAL;
goto out;
}
+ fmt = ffs(config->formats) - 1;
+
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;
--
2.25.1
More information about the Alsa-devel
mailing list