Skip to content

Commit 0787a08

Browse files
tobluxbroonie
authored andcommitted
ASoC: starfive: Use max() to simplify code in jh7110_tdm_syncdiv()
Use max() to simplify jh7110_tdm_syncdiv() and improve its readability. Signed-off-by: Thorsten Blum <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4814a8e commit 0787a08

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

sound/soc/starfive/jh7110_tdm.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/clk.h>
1111
#include <linux/device.h>
1212
#include <linux/dmaengine.h>
13+
#include <linux/minmax.h>
1314
#include <linux/module.h>
1415
#include <linux/of_irq.h>
1516
#include <linux/of_platform.h>
@@ -187,16 +188,8 @@ static int jh7110_tdm_syncdiv(struct jh7110_tdm_dev *tdm)
187188
{
188189
u32 sl, sscale, syncdiv;
189190

190-
if (tdm->rx.sl >= tdm->tx.sl)
191-
sl = tdm->rx.sl;
192-
else
193-
sl = tdm->tx.sl;
194-
195-
if (tdm->rx.sscale >= tdm->tx.sscale)
196-
sscale = tdm->rx.sscale;
197-
else
198-
sscale = tdm->tx.sscale;
199-
191+
sl = max(tdm->rx.sl, tdm->tx.sl);
192+
sscale = max(tdm->rx.sscale, tdm->tx.sscale);
200193
syncdiv = tdm->pcmclk / tdm->samplerate - 1;
201194

202195
if ((syncdiv + 1) < (sl * sscale)) {

0 commit comments

Comments
 (0)