From patchwork Tue Oct 25 14:56:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KaiLong Wang X-Patchwork-Id: 13022126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C206DECAAA1 for ; Thu, 27 Oct 2022 13:13:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 76AD02FE7; Thu, 27 Oct 2022 15:12:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 76AD02FE7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666876393; bh=odDDI9deqUgO4EsZ6+Hb4hP6JUozPS+PszvFkqwpFD0=; h=Date:From:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=SCGJLQ0PIWBIVOgUn7Z7vAk9EkfudUs2IBNQyARLf9DcuHXD5Rh7fDWmPzWQrJvDP tJBfl8yKj4SYxgFeZsjkEDhhm+FK2gkLNeIOClzl9lsDPHtDpNRXfhsETb2uXVAtd7 /igpObPQ3csBXrr3YpnFdC0qmhmdBZsYhF03WPeo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AF1A9F80553; Thu, 27 Oct 2022 15:11:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EB0FFF80431; Tue, 25 Oct 2022 17:01:09 +0200 (CEST) Received: from jari.cn (unknown [218.92.28.115]) by alsa1.perex.cz (Postfix) with ESMTP id 5981DF80100 for ; Tue, 25 Oct 2022 17:00:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5981DF80100 Received: by ajax-webmail-localhost.localdomain (Coremail) ; Tue, 25 Oct 2022 22:56:11 +0800 (GMT+08:00) X-Originating-IP: [182.148.15.254] Date: Tue, 25 Oct 2022 22:56:11 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 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 Subject: [PATCH] ALSA/ASoC: replace ternary operator with min() X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT6.0.1 build 20210329(c53f3fee) Copyright (c) 2002-2022 www.mailtech.cn mispb-4e503810-ca60-4ec8-a188-7102c18937cf-zhkzyfz.cn MIME-Version: 1.0 Message-ID: <3d74bcaf.5.1840fa4d439.Coremail.wangkailong@jari.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwCXq+EL+VdjmgQAAA--.1W X-CM-SenderInfo: 5zdqwypdlo00nj6mt2flof0/1tbiAQAKB2FEYx0AUgADsG X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-Mailman-Approved-At: Thu, 27 Oct 2022 15:11:26 +0200 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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) {