Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1525417imm; Tue, 22 May 2018 05:33:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqqfbSO3X9CsiuCH4NhgkklCdFCOZtNRi594EGIZyLJ3OfSZ34DbgvKpYPrAsuexrAsCFgf X-Received: by 2002:a63:203:: with SMTP id 3-v6mr19003096pgc.133.1526992413161; Tue, 22 May 2018 05:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526992413; cv=none; d=google.com; s=arc-20160816; b=wPMNttQAiC0RjAqR4ItPY+6V4KYdcOKjnTyVv+AeSJGQKo49Ske3Vox+pLzl7dgRGW wdT0oYMvfjgJiKzW0P5af96OCBzec1ZuxriCWzXUq3YviwP3yOf0T8uIe2EYtuhfixij 6asVSp6kxJ8HzBwUidK6QthTPQYaiEAVEXcWHLo4l4RsYUKLsRwR7sUyb6OcUV1rauN7 K0BFK+Z6OrmMVXgsJddV+Dj3LG8JAhqnnLg6qTh7OgP1kYQRRUH4TPfxKPUrGqJXoRlq cqZAndoOHYPkjJ1hzMmgmvTgTFkxNSXMLWI2OF+zv08PppNK9YkZjd/ON5fmMCl0c78k Hg3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=Af23PdUqbJ2EZTfNUAWv21Fa/r4j1l6yMS7C8oTKni0=; b=KH57YmE6h2T6uQtp38c/LKH/KHKwuzpBAnHGvKWCMSuuZXHNqNoJBztrJr8bYa8KHt g31kJaBpZdbSKHTrKc4iJzjPP+ro3yDQ3C4tVPgzMt/XgC2COZZKa4po/+1CRjarzcVo /tx2/V7VfLUlCBSvBCWMvH2/fqUtYG3BEx/9Jm9Cu4y5AWySKYuP4Tp38qluX3DzwKqZ 4V9RBr0KnGwiO89bSjU4B3ChS5ReJVBr5OjR0uC4jCIdpqOZF2yGzD4kUXrW42bjNJ4e UotO+p3Qm9DiyfYTvaGybVsk/hwD4bjc1mQVkdCIvmXs4NxSEO2dMwJY397y0T1zjlSv rdMA== 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 g1-v6si12941062pgo.637.2018.05.22.05.33.18; Tue, 22 May 2018 05:33:33 -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 S1751525AbeEVMdD (ORCPT + 99 others); Tue, 22 May 2018 08:33:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7730 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751192AbeEVMdC (ORCPT ); Tue, 22 May 2018 08:33:02 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3771EC448B47A; Tue, 22 May 2018 20:32:48 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Tue, 22 May 2018 20:32:46 +0800 Subject: Re: [PATCH 31/33] ASoC: max98088: use match_string() helper To: Andy Shevchenko References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-32-git-send-email-xieyisheng1@huawei.com> CC: Linux Kernel Mailing List , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , "ALSA Development Mailing List" From: Yisheng Xie Message-ID: <92b32dee-7ba9-ad6d-573b-9924453a69fb@huawei.com> Date: Tue, 22 May 2018 20:30:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2018/5/22 6:24, Andy Shevchenko wrote: > On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie wrote: >> match_string() returns the index of an array for a matching string, >> which can be used intead of open coded variant. > >> static int max98088_get_channel(struct snd_soc_component *component, const char *name) >> { > >> + int ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name); > I would rather split this and move an assignment to the line before 'if' hmm, you mean something like: int ret; ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name); if (ret < 0) /* Shouldn't happen */ dev_err(component->dev, "Bad EQ channel name '%s'\n", name); return ret; >> >> /* Shouldn't happen */ > >> + if (ret < 0) >> + dev_err(component->dev, "Bad EQ channel name '%s'\n", name); > >> return -EINVAL; > > return ret; Right, sorry for this big mistake. Thanks Yisheng > > ? > >> } >> >> -- >> 1.7.12.4 >> > > >