Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp224949imm; Mon, 21 May 2018 05:10:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZolJCF1ahrXZtzVdlKhmZJkSH5M08qUs0x8i+LJAEfoXF1xwb6PptWiKqVu1I8P7oOjaXyj X-Received: by 2002:a17:902:76c3:: with SMTP id j3-v6mr19794936plt.15.1526904635992; Mon, 21 May 2018 05:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904635; cv=none; d=google.com; s=arc-20160816; b=RzANJbRvPEIb5+zaNf/T7ww6H+xVkH9jE6a7C/rsrcdTi4Kd18x9GfnYQOlqAO0NGj pfvE58Eh6RfI5MpUynqrHAZASTWlKHcYHDvla61seLZUcm3uw/84RkNXVeLMjCgR+EI5 rEK3JZ1WgoL/6XTajiEtbBikbT6z6LFakfxhShXcC0BciiOWkYT7P618Mwr/nhTp1GBP +SM7rm7HtAJ8BfNk1DD8batPNp44Ovu2zKlhfLjPtSZeMO6L7g+p6UgNNb7TndbofZ9m 61kb+7n6IHgLkG8Bumr9BOWIm5ff+UkFLiHQHYIMTEGXtaF2FQEJg2hu0lgD68npwf9t D4mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=nrnrIXDahL5U9G3XCLyc5l1VzLeg3Kzjgua3161rYYo=; b=x9ZurkYZaFN4opDLpDogSUVzJB5EZI1gFCJzGuQ4GX3AQx+MYQkYodV9usuNtHMXGV M0XvaTZEJSWOL0LXHHp3UwvhAgqR5dTsTcg5m1gNfaZI63h/5DGII19ugSOGpEK2rZ52 fB2bChnhHz2dD/yk+YKJAtvmS7kUXpQUFEEFqykO55zxaHeiDT6bjHX7CKcH9fDuQk92 LSFuKdGfjLRVyK1lB1Qaft49RjPgTNDDfRSsGAoRkHDlg0xH9vM6lxh2MXPww1kYq8wk xgyuxJK+CwWXSvE9Vpdajn0CRsDZcp+NoidhI1HDjSzKTXJqTQVTcZMhJJYPD32W+igA JNyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26-v6si13684749pfn.244.2018.05.21.05.10.21; Mon, 21 May 2018 05:10:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753148AbeEUMJp (ORCPT + 99 others); Mon, 21 May 2018 08:09:45 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7721 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753001AbeEUMJZ (ORCPT ); Mon, 21 May 2018 08:09:25 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 61E3A19AAF962; Mon, 21 May 2018 20:09:11 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:09:03 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , Subject: [PATCH 30/33] ALSA: oxygen: use match_string() helper Date: Mon, 21 May 2018 19:58:07 +0800 Message-ID: <1526903890-35761-31-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Cc: Clemens Ladisch Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Signed-off-by: Yisheng Xie --- sound/pci/oxygen/oxygen_mixer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 4ca1266..fbd8f5e 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c @@ -1052,10 +1052,9 @@ static int add_controls(struct oxygen *chip, [CONTROL_CD_CAPTURE_SWITCH] = "CD Capture Switch", [CONTROL_AUX_CAPTURE_SWITCH] = "Aux Capture Switch", }; - unsigned int i, j; struct snd_kcontrol_new template; struct snd_kcontrol *ctl; - int err; + int i, j, err; for (i = 0; i < count; ++i) { template = controls[i]; @@ -1086,11 +1085,11 @@ static int add_controls(struct oxygen *chip, err = snd_ctl_add(chip->card, ctl); if (err < 0) return err; - for (j = 0; j < CONTROL_COUNT; ++j) - if (!strcmp(ctl->id.name, known_ctl_names[j])) { - chip->controls[j] = ctl; - ctl->private_free = oxygen_any_ctl_free; - } + j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name); + if (j >= 0) { + chip->controls[j] = ctl; + ctl->private_free = oxygen_any_ctl_free; + } } return 0; } -- 1.7.12.4