* [PATCH 0/2] ASoC-Rockchip: Fine-tuning for rk_aif1_hw_params() @ 2017-11-19 12:42 SF Markus Elfring 2017-11-19 12:43 ` [PATCH 1/2] ASoC: rockchip: Use common error handling code in rk_aif1_hw_params() SF Markus Elfring 2017-11-19 12:44 ` [PATCH 2/2] ASoC: rockchip: Delete an unnecessary variable initialisation " SF Markus Elfring 0 siblings, 2 replies; 3+ messages in thread From: SF Markus Elfring @ 2017-11-19 12:42 UTC (permalink / raw) To: linux-arm-kernel From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 19 Nov 2017 13:34:56 +0100 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): Use common error handling code Delete two unnecessary variable initialisations sound/soc/rockchip/rockchip_max98090.c | 13 +++++-------- sound/soc/rockchip/rockchip_rt5645.c | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) -- 2.15.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] ASoC: rockchip: Use common error handling code in rk_aif1_hw_params() 2017-11-19 12:42 [PATCH 0/2] ASoC-Rockchip: Fine-tuning for rk_aif1_hw_params() SF Markus Elfring @ 2017-11-19 12:43 ` SF Markus Elfring 2017-11-19 12:44 ` [PATCH 2/2] ASoC: rockchip: Delete an unnecessary variable initialisation " SF Markus Elfring 1 sibling, 0 replies; 3+ messages in thread From: SF Markus Elfring @ 2017-11-19 12:43 UTC (permalink / raw) To: linux-arm-kernel From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 19 Nov 2017 13:23:35 +0100 Add a jump target so that a bit of exception handling can be better reused in an if branch of these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- sound/soc/rockchip/rockchip_max98090.c | 11 ++++------- sound/soc/rockchip/rockchip_rt5645.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 789d6f1e2b5f..419fa6ef14bb 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -104,17 +104,14 @@ static int rk_aif1_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT); - if (ret < 0) { - dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); - return ret; - } + if (ret < 0) + goto report_failure; ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN); - if (ret < 0) { + if (ret < 0) +report_failure: dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); - return ret; - } return ret; } diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c index 9e0c17805807..7f763d0963d3 100644 --- a/sound/soc/rockchip/rockchip_rt5645.c +++ b/sound/soc/rockchip/rockchip_rt5645.c @@ -98,17 +98,14 @@ static int rk_aif1_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT); - if (ret < 0) { - dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); - return ret; - } + if (ret < 0) + goto report_failure; ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN); - if (ret < 0) { + if (ret < 0) +report_failure: dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); - return ret; - } return ret; } -- 2.15.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] ASoC: rockchip: Delete an unnecessary variable initialisation in rk_aif1_hw_params() 2017-11-19 12:42 [PATCH 0/2] ASoC-Rockchip: Fine-tuning for rk_aif1_hw_params() SF Markus Elfring 2017-11-19 12:43 ` [PATCH 1/2] ASoC: rockchip: Use common error handling code in rk_aif1_hw_params() SF Markus Elfring @ 2017-11-19 12:44 ` SF Markus Elfring 1 sibling, 0 replies; 3+ messages in thread From: SF Markus Elfring @ 2017-11-19 12:44 UTC (permalink / raw) To: linux-arm-kernel From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 19 Nov 2017 13:26:06 +0100 The variable "ret" will eventually be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- sound/soc/rockchip/rockchip_max98090.c | 2 +- sound/soc/rockchip/rockchip_rt5645.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 419fa6ef14bb..6d661a93588f 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -76,7 +76,7 @@ static const struct snd_kcontrol_new rk_mc_controls[] = { static int rk_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - int ret = 0; + int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c index 7f763d0963d3..d032d8bd15b9 100644 --- a/sound/soc/rockchip/rockchip_rt5645.c +++ b/sound/soc/rockchip/rockchip_rt5645.c @@ -70,7 +70,7 @@ static const struct snd_kcontrol_new rk_mc_controls[] = { static int rk_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - int ret = 0; + int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; -- 2.15.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-19 12:44 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-11-19 12:42 [PATCH 0/2] ASoC-Rockchip: Fine-tuning for rk_aif1_hw_params() SF Markus Elfring 2017-11-19 12:43 ` [PATCH 1/2] ASoC: rockchip: Use common error handling code in rk_aif1_hw_params() SF Markus Elfring 2017-11-19 12:44 ` [PATCH 2/2] ASoC: rockchip: Delete an unnecessary variable initialisation " SF Markus Elfring
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).