2024-01-27 15:15:36

by Julia Lawall

[permalink] [raw]
Subject: sound/soc/starfive/jh7110_tdm.c:198:16-18: WARNING opportunity for max() (fwd)



---------- Forwarded message ----------
Date: Sat, 27 Jan 2024 22:30:10 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: sound/soc/starfive/jh7110_tdm.c:198:16-18: WARNING opportunity for
max()

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Walker Chen <[email protected]>
CC: Mark Brown <[email protected]>
CC: Claudiu Beznea <[email protected]>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3a5879d495b226d0404098e3564462d5f1daa33b
commit: fd4762b6b5cfa27bf44f5d624ce74b7dce4a479c ASoC: starfive: Add JH7110 TDM driver
date: 8 months ago
:::::: branch date: 15 hours ago
:::::: commit date: 8 months ago
config: openrisc-randconfig-r053-20240127 (https://download.01.org/0day-ci/archive/20240127/[email protected]/config)
compiler: or1k-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)
>> sound/soc/starfive/jh7110_tdm.c:198:16-18: WARNING opportunity for max()
sound/soc/starfive/jh7110_tdm.c:203:20-22: WARNING opportunity for max()

vim +198 sound/soc/starfive/jh7110_tdm.c

fd4762b6b5cfa2 Walker Chen 2023-05-26 193
fd4762b6b5cfa2 Walker Chen 2023-05-26 194 static int jh7110_tdm_syncdiv(struct jh7110_tdm_dev *tdm)
fd4762b6b5cfa2 Walker Chen 2023-05-26 195 {
fd4762b6b5cfa2 Walker Chen 2023-05-26 196 u32 sl, sscale, syncdiv;
fd4762b6b5cfa2 Walker Chen 2023-05-26 197
fd4762b6b5cfa2 Walker Chen 2023-05-26 @198 if (tdm->rx.sl >= tdm->tx.sl)
fd4762b6b5cfa2 Walker Chen 2023-05-26 199 sl = tdm->rx.sl;
fd4762b6b5cfa2 Walker Chen 2023-05-26 200 else
fd4762b6b5cfa2 Walker Chen 2023-05-26 201 sl = tdm->tx.sl;
fd4762b6b5cfa2 Walker Chen 2023-05-26 202
fd4762b6b5cfa2 Walker Chen 2023-05-26 203 if (tdm->rx.sscale >= tdm->tx.sscale)
fd4762b6b5cfa2 Walker Chen 2023-05-26 204 sscale = tdm->rx.sscale;
fd4762b6b5cfa2 Walker Chen 2023-05-26 205 else
fd4762b6b5cfa2 Walker Chen 2023-05-26 206 sscale = tdm->tx.sscale;
fd4762b6b5cfa2 Walker Chen 2023-05-26 207
fd4762b6b5cfa2 Walker Chen 2023-05-26 208 syncdiv = tdm->pcmclk / tdm->samplerate - 1;
fd4762b6b5cfa2 Walker Chen 2023-05-26 209
fd4762b6b5cfa2 Walker Chen 2023-05-26 210 if ((syncdiv + 1) < (sl * sscale)) {
fd4762b6b5cfa2 Walker Chen 2023-05-26 211 dev_err(tdm->dev, "Failed to set syncdiv!\n");
fd4762b6b5cfa2 Walker Chen 2023-05-26 212 return -EINVAL;
fd4762b6b5cfa2 Walker Chen 2023-05-26 213 }
fd4762b6b5cfa2 Walker Chen 2023-05-26 214
fd4762b6b5cfa2 Walker Chen 2023-05-26 215 if (tdm->syncm == TDM_SYNCM_LONG &&
fd4762b6b5cfa2 Walker Chen 2023-05-26 216 (tdm->rx.sscale <= 1 || tdm->tx.sscale <= 1) &&
fd4762b6b5cfa2 Walker Chen 2023-05-26 217 ((syncdiv + 1) <= sl)) {
fd4762b6b5cfa2 Walker Chen 2023-05-26 218 dev_err(tdm->dev, "Wrong syncdiv! It must be (syncdiv+1) > max[tx.sl, rx.sl]\n");
fd4762b6b5cfa2 Walker Chen 2023-05-26 219 return -EINVAL;
fd4762b6b5cfa2 Walker Chen 2023-05-26 220 }
fd4762b6b5cfa2 Walker Chen 2023-05-26 221
fd4762b6b5cfa2 Walker Chen 2023-05-26 222 jh7110_tdm_writel(tdm, TDM_PCMDIV, syncdiv);
fd4762b6b5cfa2 Walker Chen 2023-05-26 223 return 0;
fd4762b6b5cfa2 Walker Chen 2023-05-26 224 }
fd4762b6b5cfa2 Walker Chen 2023-05-26 225

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki