From: wangkailong@jari.cn
To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com,
broonie@kernel.org, motolav@gmail.com, cezary.rojewski@intel.com,
mkumard@nvidia.com, pierre-louis.bossart@linux.intel.com,
kai.vehmanen@linux.intel.com, peter.ujfalusi@linux.intel.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA/ASoC: replace ternary operator with min()
Date: Tue, 25 Oct 2022 22:56:11 +0800 (GMT+08:00) [thread overview]
Message-ID: <3d74bcaf.5.1840fa4d439.Coremail.wangkailong@jari.cn> (raw)
Fix the following coccicheck warning:
sound/soc/soc-ops.c:817: WARNING opportunity for min()
sound/core/vmaster.c:73: WARNING opportunity for min()
sound/pci/hda/hda_codec.c:337: WARNING opportunity for min()
sound/pci/ctxfi/ctatc.c:448: WARNING opportunity for min()
sound/pci/ctxfi/ctatc.c:387: WARNING opportunity for min()
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
sound/core/vmaster.c | 2 +-
sound/pci/ctxfi/ctatc.c | 4 ++--
sound/pci/hda/hda_codec.c | 2 +-
sound/soc/soc-ops.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index d0f11f37889b..704a09f4bfd6 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -70,7 +70,7 @@ static int follower_update(struct link_follower *follower)
follower->vals[ch] = uctl->value.integer.value[ch];
error:
kfree(uctl);
- return err < 0 ? err : 0;
+ return min(err, 0);
}
/* get the follower ctl info and save the initial values */
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index fbdb8a3d5b8e..9fea50b72cfb 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -384,7 +384,7 @@ static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
apcm->started = 1;
max_cisz = src->multi * src->rsc.msr;
- max_cisz = 0x80 * (max_cisz < 8 ? max_cisz : 8);
+ max_cisz = 0x80 * min(max_cisz, 8);
src->ops->set_sa(src, apcm->vm_block->addr);
src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size);
@@ -445,7 +445,7 @@ atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm)
size = apcm->vm_block->size;
max_cisz = src->multi * src->rsc.msr;
- max_cisz = 128 * (max_cisz < 8 ? max_cisz : 8);
+ max_cisz = 128 * min(max_cisz, 8);
return (position + size - max_cisz - apcm->vm_block->addr) % size;
}
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index b4d1e658c556..c195f99bd8d5 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -334,7 +334,7 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
return 0;
dev_len = parm + 1;
- dev_len = dev_len < max_devices ? dev_len : max_devices;
+ dev_len = min(dev_len, max_devices);
devices = 0;
while (devices < dev_len) {
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index bd88de056358..d71d10055ed7 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -814,7 +814,7 @@ int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
unsigned int size, unsigned int __user *tlv)
{
struct soc_bytes_ext *params = (void *)kcontrol->private_value;
- unsigned int count = size < params->max ? size : params->max;
+ unsigned int count = min_t(unsigned int, size, params->max);
int ret = -ENXIO;
switch (op_flag) {
--
2.25.1
next reply other threads:[~2022-10-25 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 14:56 wangkailong [this message]
2022-10-25 17:01 ` [PATCH] ALSA/ASoC: replace ternary operator with min() Mark Brown
2022-10-26 5:28 ` Takashi Iwai
2022-10-26 12:25 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d74bcaf.5.1840fa4d439.Coremail.wangkailong@jari.cn \
--to=wangkailong@jari.cn \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkumard@nvidia.com \
--cc=motolav@gmail.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox