Message ID | 20241015031742.5144-1-liujing@cmss.chinamobile.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: fix code redundancy in sound/soc/soc-core.c | expand |
On Tue, Oct 15, 2024 at 11:17:42AM +0800, Liu Jing wrote: > 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). The ternery operator is rarely a legibility improvement when used standalone, this seems to just make thing harder to follow.
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;
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@cmss.chinamobile.com> --- sound/soc/soc-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)