Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp492343imm; Thu, 31 May 2018 04:24:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLxXCKTfyHyzMKkemb5t4KAdW2fM592dDjcp9MFv1ioWOqUSqsa0oLbBBWhtWwvzzYsFp2f X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr6560652pld.205.1527765894234; Thu, 31 May 2018 04:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527765894; cv=none; d=google.com; s=arc-20160816; b=HFyNo4dzCt5cd16ZAtAM1qHJqlFc5ZH+UiTYA8XUSvtkxECBPMzGQX39tvuehvRnhi hQsopesUo6wNT3TzY5VeeD6rLW5X0wrsp6+p/L+1zkW4HV0vI1D0zvDCwWGk4lTeAbih yfRmrQWbj3NHpOuDPt56vQzJg/Ggz2dx4nPIB6iXR4NazZZNKGhr7LOHguBf96WApH0L qktV7KzMmYWvQV3xZlR4I3Yh09BXeN6MP9yZ6SGKckg+Gz/PFaXIEltv0xOw9730FP68 ZIowppgQBbRaE/Nm3/qbWSG8k79o6bSklX5iWEsE0cQDXI7J92KXS6ML5pcLPd5zRCa/ G7Pw== 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=2o1fyIe0YsaoKiNSdjsCj5mtzgTuKwyoKjDI31T3E+U=; b=yqIUoE6eZ0uP8OSkCNYMWyVaiDpgcQLiEbcmvXXeI5/O6K3S/xfRs7yB8LqPjlUW4w E0fLdCwTxjXONFo8DVZIG3XDiSZ4/VggEptL0xN4rck1Bvs4YSVkSEdEnDMGyEx+LwQa WOsuK2OdpDpJSh+41X6QXkpKATK2sLN/zZSpzLSnygeg235i/QDyL3wI6vePd71PI7yC 1Vo+ZAsMAa7oeS25kliJsxksRXW+4hNf9Xc5fxb3dbrKStPiruVk0PDxu4hqWlOser7s athl1vLf9BG1Rh+skLuPKrU/HI5ozlHno1PacGNc8h+D0C6L6ETVcW2DnQjljr7Vqd+/ f90A== 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 d14-v6si8211055plr.244.2018.05.31.04.24.40; Thu, 31 May 2018 04:24:54 -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 S1755008AbeEaLXu (ORCPT + 99 others); Thu, 31 May 2018 07:23:50 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8173 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754825AbeEaLWs (ORCPT ); Thu, 31 May 2018 07:22:48 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5403459EAD6FD; Thu, 31 May 2018 19:22:35 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:27 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Liam Girdwood" , Mark Brown , "Jaroslav Kysela" , Takashi Iwai , Subject: [PATCH v2 18/21] ASoC: dapm: use match_string() helper Date: Thu, 31 May 2018 19:11:23 +0800 Message-ID: <1527765086-19873-19-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-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 instead of open coded variant. Reviewed-by: Andy Shevchenko Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Signed-off-by: Yisheng Xie --- v2: - add Reviewed-by tag. 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