ASoC: add audio-graph-card support
Hello Kuninori Morimoto,
The patch 2692c1c63c29: "ASoC: add audio-graph-card support" from Apr 20, 2017, leads to the following static checker warning:
sound/soc/generic/audio-graph-card.c:275 asoc_graph_card_probe()
info: return a literal instead of 'ret'
sound/soc/generic/audio-graph-card.c
268 goto err;
269 }
270
271 snd_soc_card_set_drvdata(card, priv);
272
273 ret = devm_snd_soc_register_card(dev, card);
274 if (ret >= 0)
275 return ret;
This code is confusing. I'm pretty sure that devm_snd_soc_register_card() returns zero on success or negative error codes but why are we checking
Quoted 1 line
= 0 here?
It's better to do error handling than success handling. People often get a bit creative with the last condition in a function... :/ In other words, it's cleaner like this:
ret = devm_snd_soc_register_card(dev, card); if (ret) goto err; return 0; err: asoc_simple_card_clean_reference(card); return ret;
276 err: 277 asoc_simple_card_clean_reference(card); 278 279 return ret; 280 }
regards,
dan carpenter
Hi Dan
Thank you for your report
Quoted 9 lines
268 goto err; 269 } 270 271 snd_soc_card_set_drvdata(card, priv); 272 273 ret = devm_snd_soc_register_card(dev, card); 274 if (ret >= 0) 275 return ret;
Quoted 3 lines
This code is confusing. I'm pretty sure that
devm_snd_soc_register_card()returns zero on success or negative error codes but why are we checkingQuoted 1 line
= 0 here?
I agree, but Hmm..
It seems historical reason ?
e512e001dafa54e5ac7244416e340750a4356b41 (ASoC: simple-card: Fix the reference count of device nodes) e3c4a28b611b03d69bfbdffda985ef0dd94c2794 (ASoC: simple-card: Fix bug of wrong decrement DT node's refcount)
Current simple-card / simple-scu-card / audio-graph-card / audio-graph-scu-card are using same style. thus, we need to fix for these drivers. Thanks. I will do it
Best regards
---
Kuninori Morimoto