]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: starfive: Use max() to simplify code in jh7110_tdm_syncdiv()
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 24 Apr 2025 13:36:49 +0000 (15:36 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 25 Apr 2025 12:20:00 +0000 (13:20 +0100)
Use max() to simplify jh7110_tdm_syncdiv() and improve its readability.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250424133648.86459-2-thorsten.blum@linux.dev
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/starfive/jh7110_tdm.c

index d38090e68df5f079e3b9505b69f7cac8fcb262c1..afdcde7df91ab399c20d0e93dac9eac935ef2dd1 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/dmaengine.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
@@ -187,16 +188,8 @@ static int jh7110_tdm_syncdiv(struct jh7110_tdm_dev *tdm)
 {
        u32 sl, sscale, syncdiv;
 
-       if (tdm->rx.sl >= tdm->tx.sl)
-               sl = tdm->rx.sl;
-       else
-               sl = tdm->tx.sl;
-
-       if (tdm->rx.sscale >= tdm->tx.sscale)
-               sscale = tdm->rx.sscale;
-       else
-               sscale = tdm->tx.sscale;
-
+       sl = max(tdm->rx.sl, tdm->tx.sl);
+       sscale = max(tdm->rx.sscale, tdm->tx.sscale);
        syncdiv = tdm->pcmclk / tdm->samplerate - 1;
 
        if ((syncdiv + 1) < (sl * sscale)) {