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: 10858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1061097wru; Tue, 25 Oct 2022 08:12:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zfHPEz75ErcqJsoxCkITB3DWDd+XmokaeUnezFhCrMPdMvi1yUVEcPz/TR1WDuwTcdT3z X-Received: by 2002:a17:902:db09:b0:185:53c7:6e8e with SMTP id m9-20020a170902db0900b0018553c76e8emr39198398plx.155.1666710770426; Tue, 25 Oct 2022 08:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666710770; cv=none; d=google.com; s=arc-20160816; b=wvJbQiKEGOUGAbTsBSIz/BCz/N8FMvOtZyruklASFcjHEVP1doGmoWV5+Q3QpN/dNQ 4Hrr/MMcZjdTaNTLgCNcEUCv8w6TUpnB32oaz8a/uJitXqr8wNUKwNNSlxx7rKRL67gu OB0/gKLCe/TyBjrYNdZHH7OLY+9Dnwp7MI3NZrPzZz9Hz4EJJ5+EDNHdPgo1Lj5g6oif Su7ZUx87+s8vaHX1vc3ncVWoSL2OONqtYpOtLi01mW3iIFyO0VjxLEYbo6GYRis9feiS Kpg/rAsPsmKgDIHSQb5F991CGwxWCMTF6nR2QrxNKkzMC4Wfs+GRwKnNHYYuALphGAII Ez0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:cc:to:from:date; bh=odDDI9deqUgO4EsZ6+Hb4hP6JUozPS+PszvFkqwpFD0=; b=aeckLxaRW5/wowfsEWiqJIp3914JATuYvT8VAgdR7B+5VTSr3KUChmF1uF2IhDS+4T 8AFiJ7GwH+zC+ir/fXo/FS8bTbNNcburZXzAo4jHYG0Tl0PfV8mOMMIBP1bgxIbvZYVq iKhbHtLdtGbaDwYPBx7RkVWDgfynKKHZ4DGoCsrycoPyFJHCJvit0u0bIrzN510w2HEA GarXp+fudShxi6I0Uzj1uiRq9QXrHCcMWqxm+c07VPs9PXNHuTQCJ/bS/OMBXW0RMtTx 6/GFF7Ro/Na6SMJWbAkuObl+Q2JnkdWy0+hkrSq9wJf5c9H0tmXWcJvYkTQCK/D4NS/I Uihw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o190-20020a6341c7000000b0044ac2bbaccasi3316304pga.729.2022.10.25.08.12.37; Tue, 25 Oct 2022 08:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232221AbiJYPBS (ORCPT + 99 others); Tue, 25 Oct 2022 11:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbiJYPBQ (ORCPT ); Tue, 25 Oct 2022 11:01:16 -0400 Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A050E101C5 for ; Tue, 25 Oct 2022 08:01:13 -0700 (PDT) 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 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org 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-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,RCVD_IN_PBL,RDNS_NONE, T_SPF_HELO_PERMERROR,T_SPF_PERMERROR,XPRIO autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747672912664252700?= X-GMAIL-MSGID: =?utf-8?q?1747672912664252700?= 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) {