Skip to contentSkip to conversation

ASoC: remove conditional returns with no effect

PATCH Superseded Sang-Heon Jeon 4 participants 8 messages Jul 25 – Jul 27

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover ASoC: remove conditional returns with no effect

Hello,

This series removes conditional returns where both branches return the same value, so the check has no effect. As suggested by Vijendar, the ASoC patch of the treewide v1 series [1] is split per vendor and posted separately.

All patches are generated by the Coccinelle script, which you can find in v1.

If you would rather drop any of the patches, just let me know and I will address it in the next version.

---
Changes from v1 [1]
- Split patches per vendor
- Change base to broonie/sound/for-next
- Filter only ASoC patch

[1] https://lore.kernel.org/all/[email protected]/
---

Sang-Heon Jeon (4):
ASoC: amd: acp: remove conditional return with no effect
ASoC: Intel: atom: remove conditional return with no effect
ASoC: samsung: smdk_spdif: remove conditional return with no effect
ASoC: SOF: Intel: remove conditional return with no effect

 sound/soc/amd/acp/acp-mach-common.c          | 11 +++--------
 sound/soc/intel/atom/sst-mfld-platform-pcm.c |  7 +------
 sound/soc/samsung/smdk_spdif.c               |  8 ++------
 sound/soc/sof/intel/hda-dsp.c                |  6 +-----
 4 files changed, 7 insertions(+), 25 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/4 ASoC: amd: acp: remove conditional return with no effect

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
 sound/soc/amd/acp/acp-mach-common.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/amd/acp/acp-mach-common.c +3 -8
index ef784cca13f2..01a0aaa60246 100644
@@ -938,15 +938,10 @@ static int acp_max98388_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *codec_dai =
 			snd_soc_card_get_codec_dai(card,
 						   MAX98388_CODEC_DAI);
-	int ret;
 
-	ret = snd_soc_dai_set_fmt(codec_dai,
-				  SND_SOC_DAIFMT_CBC_CFC | SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF);
-	if (ret < 0)
-		return ret;
-
-	return ret;
+	return snd_soc_dai_set_fmt(codec_dai,
+				   SND_SOC_DAIFMT_CBC_CFC | SND_SOC_DAIFMT_I2S |
+				   SND_SOC_DAIFMT_NB_NF);
 }
 
 static const struct snd_soc_ops acp_max98388_ops = {
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] ASoC: amd: acp: remove conditional return with no effect

Quoted 9 lines · Sang-Heon Jeon

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

Quoted 30 lines
---
  sound/soc/amd/acp/acp-mach-common.c | 11 +++--------
  1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/amd/acp/acp-mach-common.c +3 -9
index ef784cca13f2..01a0aaa60246 100644
@@ -938,15 +938,10 @@ static int acp_max98388_hw_params(struct snd_pcm_substream *substream,
         struct snd_soc_dai *codec_dai =
                         snd_soc_card_get_codec_dai(card,
                                                    MAX98388_CODEC_DAI);
-       int ret;
 
-       ret = snd_soc_dai_set_fmt(codec_dai,
-                                 SND_SOC_DAIFMT_CBC_CFC | SND_SOC_DAIFMT_I2S |
-                                 SND_SOC_DAIFMT_NB_NF);
-       if (ret < 0)
-               return ret;
-
-       return ret;
+       return snd_soc_dai_set_fmt(codec_dai,
+                                  SND_SOC_DAIFMT_CBC_CFC | SND_SOC_DAIFMT_I2S |
+                                  SND_SOC_DAIFMT_NB_NF);
  }
 
  static const struct snd_soc_ops acp_max98388_ops = {
--

2.43.0

#3 lore raw

PATCH v2 2/4 ASoC: Intel: atom: remove conditional return with no effect

In reply to Sang-Heon Jeon

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +1 -6
index 9ee4d9926e06..a4c8cbfba096 100644
@@ -236,12 +236,7 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
 
 	stream->stream_info.str_id = str_params.stream_id;
 
-	ret_val = stream->ops->open(sst->dev, &str_params);
-	if (ret_val <= 0)
-		return ret_val;
-
-
-	return ret_val;
+	return stream->ops->open(sst->dev, &str_params);
 }
 
 static void sst_period_elapsed(void *arg)
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] ASoC: Intel: atom: remove conditional return with no effect

Quoted 19 lines · Sang-Heon Jeon

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
  sound/soc/intel/atom/sst-mfld-platform-pcm.c | 7 +------
  1 file changed, 1 insertion(+), 6 deletions(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +0 -0
index 9ee4d9926e06..a4c8cbfba096 100644
@@ -236,12 +236,7 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
 
  	stream->stream_info.str_id = str_params.stream_id;
 

sound/soc/intel/atom/sst-mfld-platform-pcm.c static int sst_platform_alloc_stream(struct snd_pcm_substream *substream, · line 242

Quoted 10 lines
sound/soc/intel/atom/sst-mfld-platform-pcm.c +1 -6
-	ret_val = stream->ops->open(sst->dev, &str_params);
-	if (ret_val <= 0)
-		return ret_val;
-
-
-	return ret_val;
+	return stream->ops->open(sst->dev, &str_params);
  }
 
  static void sst_period_elapsed(void *arg)
#5 lore raw

PATCH v2 3/4 ASoC: samsung: smdk_spdif: remove conditional return with no effect

In reply to Sang-Heon Jeon

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
 sound/soc/samsung/smdk_spdif.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
sound/soc/samsung/smdk_spdif.c +2 -6
index 2474eb619882..515e4dfc1432 100644
@@ -130,12 +130,8 @@ static int smdk_hw_params(struct snd_pcm_substream *substream,
 		return ret;
 
 	/* Set S/PDIF uses internal source clock */
-	ret = snd_soc_dai_set_sysclk(cpu_dai, SND_SOC_SPDIF_INT_MCLK,
-					rclk_rate, SND_SOC_CLOCK_IN);
-	if (ret < 0)
-		return ret;
-
-	return ret;
+	return snd_soc_dai_set_sysclk(cpu_dai, SND_SOC_SPDIF_INT_MCLK,
+				      rclk_rate, SND_SOC_CLOCK_IN);
 }
 
 static const struct snd_soc_ops smdk_spdif_ops = {
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 4/4 ASoC: SOF: Intel: remove conditional return with no effect

In reply to Sang-Heon Jeon

Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.

This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
 sound/soc/sof/intel/hda-dsp.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
sound/soc/sof/intel/hda-dsp.c +1 -5
index e9f092f082a1..b9b2bdff4ccb 100644
@@ -1114,11 +1114,7 @@ static int hda_dsp_s5_quirk(struct snd_sof_dev *sdev)
 	usleep_range(500, 1000);
 
 	/* Restore state for shutdown, back to reset */
-	ret = hda_dsp_ctrl_link_reset(sdev, true);
-	if (ret < 0)
-		return ret;
-
-	return ret;
+	return hda_dsp_ctrl_link_reset(sdev, true);
 }
 
 int hda_dsp_shutdown_dma_flush(struct snd_sof_dev *sdev)
Signature · 1 line
2.43.0
maintainer
#7 lore raw
In reply to Sang-Heon Jeon
Quoted 10 lines · Sang-Heon Jeon

ASoC: remove conditional returns with no effect

Hello,

This series removes conditional returns where both branches return the same value, so the check has no effect. As suggested by Vijendar, the ASoC patch of the treewide v1 series [1] is split per vendor and posted separately.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3

Thanks!

[1/4] ASoC: amd: acp: remove conditional return with no effect

      https://git.kernel.org/broonie/asoc/c/3799a56da8f3
[2/4] ASoC: Intel: atom: remove conditional return with no effect
      https://git.kernel.org/broonie/asoc/c/52c095772962
[3/4] ASoC: samsung: smdk_spdif: remove conditional return with no effect
      https://git.kernel.org/broonie/asoc/c/cdb8b41357bb
[4/4] ASoC: SOF: Intel: remove conditional return with no effect
      https://git.kernel.org/broonie/asoc/c/619446b87c0e

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark