* [PATCH] ASoC: bells: Use common error handling code in bells_set_bias_level_post()
@ 2017-11-19 14:08 SF Markus Elfring
2017-11-20 7:38 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-11-19 14:08 UTC (permalink / raw)
To: alsa-devel, Jaroslav Kysela, Krzysztof Kozlowski, Liam Girdwood,
Mark Brown, Sangbeom Kim, Sylwester Nawrocki, Takashi Iwai
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
sound/soc/samsung/bells.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
index 34deba461ae1..fc9a71523b3e 100644
--- a/sound/soc/samsung/bells.c
+++ b/sound/soc/samsung/bells.c
@@ -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)
--
2.15.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: bells: Use common error handling code in bells_set_bias_level_post()
2017-11-19 14:08 [PATCH] ASoC: bells: Use common error handling code in bells_set_bias_level_post() SF Markus Elfring
@ 2017-11-20 7:38 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2017-11-20 7:38 UTC (permalink / raw)
To: SF Markus Elfring
Cc: alsa-devel, Sangbeom Kim, LKML, Takashi Iwai, kernel-janitors,
Liam Girdwood, Mark Brown, Sylwester Nawrocki
On Sun, Nov 19, 2017 at 3:08 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
> sound/soc/samsung/bells.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
> index 34deba461ae1..fc9a71523b3e 100644
> --- a/sound/soc/samsung/bells.c
> +++ b/sound/soc/samsung/bells.c
> @@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-20 7:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 14:08 [PATCH] ASoC: bells: Use common error handling code in bells_set_bias_level_post() SF Markus Elfring
2017-11-20 7:38 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox