ASoC: bells: Use common error handling code in bells_set_bias_level_post()
Subsystems (4)
PATCH 1/1 ASoC: bells: Use common error handling code in bells_set_bias_level_post()
From: Markus Elfring <[email protected]>
Date: Sun, 19 Nov 2017 15:00:22 +0100
* Add a jump target so that a specific error message is stored only once at the end of this function implementation.
* Replace two calls of the macro "pr_err" by goto statements.
This issue was detected by using the Coccinelle software.
--- sound/soc/samsung/bells.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/samsung/bells.c +8 -8
@@ -120,18 +120,14 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,switch (level) {case SND_SOC_BIAS_STANDBY : ret =snd_soc_codec_set_pll (codec,WM5102_FLL1 ,0 ,0 ,0 ); -if (ret <0 ) { -pr_err ("Failed to stop FLL: %d\n" , ret); -return ret; - } +if (ret <0 ) + goto report_failure;if (bells->asyncclk_rate) { ret =snd_soc_codec_set_pll (codec,WM5102_FLL2 ,0 ,0 ,0 ); -if (ret <0 ) { -pr_err ("Failed to stop FLL: %d\n" , ret); -return ret; - } +if (ret <0 ) + goto report_failure; }break ;
@@ -142,6 +138,10 @@ static int bells_set_bias_level_post(struct snd_soc_card *card, dapm->bias_level = level;return 0 ; + +report_failure: +pr_err ("Failed to stop FLL: %d\n" , ret); +return ret; }static int bells_late_probe (struct snd_soc_card *card)
Signature · 1 line
2.15.0
Quoted 20 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 19 Nov 2017 15:00:22 +0100* Add a jump target so that a specific error message is stored only once at the end of this function implementation.
* Replace two calls of the macro "
pr_err" by goto statements.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- sound/soc/samsung/bells.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)sound/soc/samsung/bells.c +0
-0
sound/soc/samsung/bells.c static int bells_set_bias_level_post(struct snd_soc_card *card, · line 125
Quoted 10 lines
sound/soc/samsung/bells.c +2
-4@@ -120,18 +120,14 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,switch (level) {case SND_SOC_BIAS_STANDBY : ret =snd_soc_codec_set_pll (codec,WM5102_FLL1 ,0 ,0 ,0 ); -if (ret <0 ) { -pr_err ("Failed to stop FLL: %d\n" , ret); -return ret; - } +if (ret <0 ) + goto report_failure;
No. The same as previously - just for error path code this makes code less readable.
Best regards,
Krzysztof