* [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup()
@ 2017-11-19 9:00 SF Markus Elfring
2017-11-20 12:34 ` Andy Shevchenko
2017-11-20 16:35 ` Pierre-Louis Bossart
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-11-19 9:00 UTC (permalink / raw)
To: alsa-devel, Andy Shevchenko, Jaroslav Kysela, Liam Girdwood,
Mark Brown, Pierre-Louis Bossart, Takashi Iwai
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 19 Nov 2017 09:53:56 +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 function "dev_err" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/intel/boards/cht_bsw_rt5645.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index 18d129caa974..bf3ffc2b0d8f 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -357,20 +357,16 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS
);
- if (ret < 0) {
- dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
ret = snd_soc_dai_set_fmt(rtd->codec_dai,
SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS
);
- if (ret < 0) {
- dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16);
if (ret < 0) {
@@ -403,6 +399,10 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
}
}
return 0;
+
+report_failure:
+ dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
+ return ret;
}
static int cht_aif1_startup(struct snd_pcm_substream *substream)
--
2.15.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup()
2017-11-19 9:00 [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup() SF Markus Elfring
@ 2017-11-20 12:34 ` Andy Shevchenko
2017-11-20 16:35 ` Pierre-Louis Bossart
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2017-11-20 12:34 UTC (permalink / raw)
To: SF Markus Elfring, alsa-devel, Jaroslav Kysela, Liam Girdwood,
Mark Brown, Pierre-Louis Bossart, Takashi Iwai
Cc: LKML, kernel-janitors
On Sun, 2017-11-19 at 10:00 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
get_maintainter.pl --git-min-percent=67 will do a nice job to make at
least me not seeing this stuff.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup()
2017-11-19 9:00 [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup() SF Markus Elfring
2017-11-20 12:34 ` Andy Shevchenko
@ 2017-11-20 16:35 ` Pierre-Louis Bossart
1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2017-11-20 16:35 UTC (permalink / raw)
To: SF Markus Elfring, alsa-devel, Andy Shevchenko, Jaroslav Kysela,
Liam Girdwood, Mark Brown, Takashi Iwai
Cc: LKML, kernel-janitors
On 11/19/2017 03:00 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 19 Nov 2017 09:53:56 +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 function "dev_err" by goto statements.
>
> This issue was detected by using the Coccinelle software.
Indeed this isn't very smart to provide the same test but no, this is
the wrong way to fix this. The error message is in reply to two
different configurations, one on the codec side and one on the cpu-dai
side. We should change the error message to more clearly indicate the
issue rather than fold both cases under the same handler.
Besides this is the same code as in other machine drivers so needs to be
handled in multiple files as well.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> sound/soc/intel/boards/cht_bsw_rt5645.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
> index 18d129caa974..bf3ffc2b0d8f 100644
> --- a/sound/soc/intel/boards/cht_bsw_rt5645.c
> +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
> @@ -357,20 +357,16 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
> SND_SOC_DAIFMT_NB_NF |
> SND_SOC_DAIFMT_CBS_CFS
> );
> - if (ret < 0) {
> - dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
> - return ret;
> - }
> + if (ret < 0)
> + goto report_failure;
>
> ret = snd_soc_dai_set_fmt(rtd->codec_dai,
> SND_SOC_DAIFMT_I2S |
> SND_SOC_DAIFMT_NB_NF |
> SND_SOC_DAIFMT_CBS_CFS
> );
> - if (ret < 0) {
> - dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
> - return ret;
> - }
> + if (ret < 0)
> + goto report_failure;
>
> ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16);
> if (ret < 0) {
> @@ -403,6 +399,10 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
> }
> }
> return 0;
> +
> +report_failure:
> + dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
> + return ret;
> }
>
> static int cht_aif1_startup(struct snd_pcm_substream *substream)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-20 16:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 9:00 [PATCH] ASoC: cht_bsw_rt5645: Use common error handling code in cht_codec_fixup() SF Markus Elfring
2017-11-20 12:34 ` Andy Shevchenko
2017-11-20 16:35 ` Pierre-Louis Bossart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).