Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp225830imm; Mon, 21 May 2018 05:11:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpoGkvXfs4rn/A0BwQrn/tl9cO4TpNWSaQQ+nCHpYPR7GhJ6890XMU8zMv8JzttRUOJsCW5 X-Received: by 2002:a17:902:8d8c:: with SMTP id v12-v6mr20098793plo.366.1526904681265; Mon, 21 May 2018 05:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904681; cv=none; d=google.com; s=arc-20160816; b=VZAUmFMx7jCE/83fluL8GksDdwFixi3ncLALIxOwRhMtZDQgvRSnJsQOVviLIZSF4P SCdAEDt2uEkMoOTyY3xyqJN7E30OmTFjRz5ai7CzPeZTUiF1B8hCwjrhOwdMkSxRgY1R hMhkobG5e5PKCwpVtBFqmC7xWLiyYPE1wvdJGgx6coE8l5ZPTF3I9Q2IxW9ymajwBvLB gGMUVSDMhIZvk6gBjOvXLcg8FayZzyAz3NlBBduxCih46vdGPAP7mryPgDu2cJ6/mZ1M EhYqkWd36ey/LOog+xvMLJijoRSF1m04abjfjyIiDIGgJxhKOGdnm5UclvaayzVT8vg4 ysXA== 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=Jtw2d4M1wAkUUUjxheTX8WzKUVzbg6zkKFtnamS4Eew=; b=oQ8FPOeUugzAqWVM4LD8+30nUc5Svhypca4QD696g/6t6RQgK8GvVF43VjhQhDxx/1 h7TcQ/UP54AEyuoIS7qVf/i5U1P+rgk+8LfABczXNCZvEMdx+eJ9POooK+BGPxz//kB+ YWeSLAlC5okOm8tVPiRiLIidH3Gsa7ZmuHwokZLfGJTTMKxOrRFnedMdgxxGh0iYUn43 ks3nF6nxAgbZXYjXEsHtfRA2+S/d61xQEVqaaGFGocZrWekRGjk12RTARowNWbWhCMzo s1zeNuNyfMZ3Q/X9pyhOKqdSnTismRqvP7f0OElCq/w6G6PdHKhOSLReB//p9zMH7v8/ RGrQ== 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 24-v6si14496572pfj.6.2018.05.21.05.11.07; Mon, 21 May 2018 05:11:21 -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 S1753098AbeEUMJg (ORCPT + 99 others); Mon, 21 May 2018 08:09:36 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7722 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753009AbeEUMJZ (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 6FA7116CE2CAA; 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:05 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Liam Girdwood , Mark Brown , Jaroslav Kysela , "Takashi Iwai" , Subject: [PATCH 33/33] ASoC: dapm: use match_string() helper Date: Mon, 21 May 2018 19:58:10 +0800 Message-ID: <1526903890-35761-34-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: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Signed-off-by: Yisheng Xie --- sound/soc/soc-dapm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 2d97091..1e9a363 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -724,18 +724,14 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, item = 0; } - for (i = 0; i < e->items; i++) { - if (!(strcmp(control_name, e->texts[i]))) { - path->name = e->texts[i]; - if (i == item) - path->connect = 1; - else - path->connect = 0; - return 0; - } - } + i = match_string(e->texts, e->items, control_name); + if (i < 0) + return -ENODEV; + + path->name = e->texts[i]; + path->connect = (i == item); + return 0; - return -ENODEV; } /* set up initial codec paths */ -- 1.7.12.4