[PATCH] ASoC: fix code redundancy in sound/soc/soc-core.c
From: Liu Jing
Date: Mon Oct 14 2024 - 23:18:04 EST
In the snd_soc_register_dai function, the logic for assigning the value of dai->id can be simplified
using the conditional operator (also known as the ternary operator).
Signed-off-by: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx>
---
sound/soc/soc-core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 20248a29d167..cbe2be64e1c3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2663,10 +2663,7 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
dai->name = fmt_single_name(dev, &dai->id);
} else {
dai->name = fmt_multiple_name(dev, dai_drv);
- if (dai_drv->id)
- dai->id = dai_drv->id;
- else
- dai->id = component->num_dai;
+ dai->id = dai_drv->id ? dai_drv->id : component->num_dai;
}
if (!dai->name)
return NULL;
--
2.27.0