diff mbox series

ASoC: codecs: lpass-va-macro: remove some dead code

Message ID X8c5gjZO7YN/CFsq@mwanda (mailing list archive)
State Accepted
Commit 4d638b9cc79eff11bad13fb3715c0ef38a9edaec
Headers show
Series ASoC: codecs: lpass-va-macro: remove some dead code | expand

Commit Message

Dan Carpenter Dec. 2, 2020, 6:51 a.m. UTC
The "decimator" variable is in the 0-7 range and it's unsigned so there
is no need to check for negative values.

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/codecs/lpass-va-macro.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Srinivas Kandagatla Dec. 2, 2020, 3:54 p.m. UTC | #1
Thanks Dan for the patch!

Do you use any tools to do this checks?


On 02/12/2020 06:51, Dan Carpenter wrote:
> The "decimator" variable is in the 0-7 range and it's unsigned so there
> is no need to check for negative values.
> 
> Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

> ---
>   sound/soc/codecs/lpass-va-macro.c | 15 ++++-----------
>   1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
> index 3e6bbef26dcb..91e6890d6efc 100644
> --- a/sound/soc/codecs/lpass-va-macro.c
> +++ b/sound/soc/codecs/lpass-va-macro.c
> @@ -844,17 +844,10 @@ static int va_macro_hw_params(struct snd_pcm_substream *substream,
>   
>   	for_each_set_bit(decimator, &va->active_ch_mask[dai->id],
>   			 VA_MACRO_DEC_MAX) {
> -		if (decimator >= 0) {
> -			tx_fs_reg = CDC_VA_TX0_TX_PATH_CTL +
> -				    VA_MACRO_TX_PATH_OFFSET * decimator;
> -			snd_soc_component_update_bits(component, tx_fs_reg,
> -						0x0F, tx_fs_rate);
> -		} else {
> -			dev_err(va_dev,
> -				"%s: ERROR: Invalid decimator: %d\n",
> -				__func__, decimator);
> -			return -EINVAL;
> -		}
> +		tx_fs_reg = CDC_VA_TX0_TX_PATH_CTL +
> +			    VA_MACRO_TX_PATH_OFFSET * decimator;
> +		snd_soc_component_update_bits(component, tx_fs_reg, 0x0F,
> +					      tx_fs_rate);
>   	}
>   	return 0;
>   }
>
Mark Brown Dec. 2, 2020, 5:19 p.m. UTC | #2
On Wed, 2 Dec 2020 09:51:46 +0300, Dan Carpenter wrote:
> The "decimator" variable is in the 0-7 range and it's unsigned so there
> is no need to check for negative values.

Applied to

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

Thanks!

[1/1] ASoC: codecs: lpass-va-macro: remove some dead code
      commit: 4d638b9cc79eff11bad13fb3715c0ef38a9edaec

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
Dan Carpenter Dec. 2, 2020, 6:37 p.m. UTC | #3
On Wed, Dec 02, 2020 at 03:54:53PM +0000, Srinivas Kandagatla wrote:
> Thanks Dan for the patch!
> 
> Do you use any tools to do this checks?
> 

Yeah.  This was a Smatch warning:

sound/soc/codecs/lpass-va-macro.c:847 va_macro_hw_params() warn: always true condition '(decimator >= 0) => (0-u32max >= 0)'

But every static checker will complain about these.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 3e6bbef26dcb..91e6890d6efc 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -844,17 +844,10 @@  static int va_macro_hw_params(struct snd_pcm_substream *substream,
 
 	for_each_set_bit(decimator, &va->active_ch_mask[dai->id],
 			 VA_MACRO_DEC_MAX) {
-		if (decimator >= 0) {
-			tx_fs_reg = CDC_VA_TX0_TX_PATH_CTL +
-				    VA_MACRO_TX_PATH_OFFSET * decimator;
-			snd_soc_component_update_bits(component, tx_fs_reg,
-						0x0F, tx_fs_rate);
-		} else {
-			dev_err(va_dev,
-				"%s: ERROR: Invalid decimator: %d\n",
-				__func__, decimator);
-			return -EINVAL;
-		}
+		tx_fs_reg = CDC_VA_TX0_TX_PATH_CTL +
+			    VA_MACRO_TX_PATH_OFFSET * decimator;
+		snd_soc_component_update_bits(component, tx_fs_reg, 0x0F,
+					      tx_fs_rate);
 	}
 	return 0;
 }