ASoC: codecs: wcd934x: Use min macro for comparison and assignment
authorDeepak R Varma <drv@mailo.com>
Mon, 13 Feb 2023 17:40:46 +0000 (23:10 +0530)
committerMark Brown <broonie@kernel.org>
Tue, 14 Feb 2023 13:25:20 +0000 (13:25 +0000)
Simplify code by using min helper macro for logical evaluation and value
assignment. The change also facilitates code realignment for improved
readability.
Proposed change is identified using minmax.cocci Coccinelle script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
Link: https://lore.kernel.org/r/Y+p2Hn0nrtHiKwPR@ubun2204.myguest.virtualbox.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd934x.c

index 28175c746b9ae2687ecd2553c506517588cf7908..783479a4d535a17b92e6e15fdefef5bd0d884605 100644 (file)
@@ -4737,13 +4737,9 @@ static u32 wcd934x_get_dmic_sample_rate(struct snd_soc_component *comp,
        if (dec_found && adc_mux_index <= 8) {
                tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
                tx_stream_fs = snd_soc_component_read(comp, tx_fs_reg) & 0x0F;
-               if (tx_stream_fs <= 4)  {
-                       if (wcd->dmic_sample_rate <=
-                                       WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ)
-                               dmic_fs = wcd->dmic_sample_rate;
-                       else
-                               dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ;
-               } else
+               if (tx_stream_fs <= 4)
+                       dmic_fs = min(wcd->dmic_sample_rate, WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ);
+               else
                        dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
        } else {
                dmic_fs = wcd->dmic_sample_rate;