Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp492463imm; Thu, 31 May 2018 04:25:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4mM1jr++Qi9lhZdSAl7nqVF9Z8l0mzeaY+x7+8sz9LY2+k468CMxhiNbRQ0OgnogUAn6H X-Received: by 2002:a63:ba1c:: with SMTP id k28-v6mr5250487pgf.179.1527765903950; Thu, 31 May 2018 04:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527765903; cv=none; d=google.com; s=arc-20160816; b=I+q/HSqIkqVLQDQ0i/XQAaoSyISCWFb6iQOAEhPhR+gw0qLSjYKFxdd7DBxYwS3rLS TGOVaByQ+OcuP9DDPeMVqZy9Np4ovMpQghatwBeSGIiqkgqK5uISlIkVzjXcrAclU6b7 XjcuntzVZfnNTS/BfP8GoXRKzRHZqhVI35T+dwMcNLqfMZHPM3rGvZAKJYtl5Cgtzma3 uSc67qU9ulXTYevNXBS6LDVJm2D2Q8cZcDZTmrH7vIksgldc6CO1XM8FYjlYR+nHbIXi cE91vGi3yvAcqQFfGXax9+ZLBEXfXaYDMgSMkSTmSkuDV4DysL5MXngpeKQURe1DZXsL Y98A== 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=FNEw6EnfBPlS078/SdBALEXRyPzLk9zztkSEnscLIC4=; b=cDGxLMRAt7E3JP9h/kJmC3DxfzoHR85g2YmBvfJDFxRs1kXzDbvkVXcwre7RgdWSNH L4oqZl6cQLCgniWie9pUsis0qzIDaEOvkL9JTBDSiK1nWEVtbTHJtzhkJTpiOGOl74+8 3qMmheC5LgP5IO/OAPRcUiV6XkE25EGKloFdd9mR7KlroCjR3dcnpeBK2r4YH60QzcjY d7ETsm0kdB9EHHi7mMQ5Cwu13N388+7PO6qny49AiPq17z3DFVBy/85Mt7fE0cZbs+1B Woywds6lZ9d8pYlvEKb/tOnhpDfq9NWVJXS0dNa5GIsPm7oURZNf2MYQ7cfdCP+QR3qp E74g== 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 j6-v6si30026828pgc.509.2018.05.31.04.24.49; Thu, 31 May 2018 04:25:03 -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 S1754990AbeEaLXq (ORCPT + 99 others); Thu, 31 May 2018 07:23:46 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8172 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754823AbeEaLWs (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 45FD2B7D81F8; 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 17/21] ASoC: max98095: use match_string() helper Date: Thu, 31 May 2018 19:11:22 +0800 Message-ID: <1527765086-19873-18-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. Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Signed-off-by: Yisheng Xie --- v2: - split ret=xxxx and move assignment to the line before 'if' - per Andy sound/soc/codecs/max98095.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 6bf2d0b..3b3a10d 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -1634,15 +1634,12 @@ static void max98095_handle_eq_pdata(struct snd_soc_component *component) static int max98095_get_bq_channel(struct snd_soc_component *component, const char *name) { - int i; - - for (i = 0; i < ARRAY_SIZE(bq_mode_name); i++) - if (strcmp(name, bq_mode_name[i]) == 0) - return i; + int ret; - /* Shouldn't happen */ - dev_err(component->dev, "Bad biquad channel name '%s'\n", name); - return -EINVAL; + ret = match_string(bq_mode_name, ARRAY_SIZE(bq_mode_name), name); + if (ret < 0) + dev_err(component->dev, "Bad biquad channel name '%s'\n", name); + return ret; } static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, -- 1.7.12.4