Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp833720imm; Mon, 21 May 2018 15:23:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpr2zvVVg/b88jzx6HXDmfiNNVL5cKDKZERvv5wTKObw4nEhDEYxrlWZ/RpIt95Z5DvGSbU X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr21627472plb.99.1526941433379; Mon, 21 May 2018 15:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526941433; cv=none; d=google.com; s=arc-20160816; b=v3FpFz4KBiLX65g1xgzMUODTL0whBavlxgmhicp6xH7JVu9UPJOrtYMwrGTTQum3uI zhc1RGTFpVJ2KHQde8BL9dCxV+QRLJwW7SNeqK5yDMWAd8WW1y8b7Iw6ikQOJ7zIC4Ye lbzqgQYnexphAnpQsRMp6tuPIe9cAWX+TNPuCKWIYhO7rOqe9HBK7yvZKo8Ke/DgTZSP UVkH3hQgATtoOmP7vzwJZPuJIPX7kMHWwmw5yxfIBMp4JBWJNdaPymAUm4EkupMvnb93 Fm+AhmJidZxGh7JYduWFU9Mnr0xeEk8SdKJ0zttAhw8bCegBLWqgF3L8leQHuvRk0Gf5 n8JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=qkwX2YgxmQ26nOVX7FVrBptirf3oLctX7wN3Y79+zYs=; b=o+RH6xLuyHQ2cBBmnsCyp9hWnZ6gtqACwbzx26Bd6e9NncsErZ5SuSMokw3KrK4wbk uAWDp5G2FfLNgE1pqhnerxTmcoeO2X4GO466D/WPvUWEBCd4D1sgz/G+enQ1QTGIgjOi qrbXUlz6BK8H8HYskBqKdVEyXmQL36roa/CUeN4vImSDKWcF3Fgfs3o6ct6FKN+6by85 brhhpeY+8FZPO2V5xiJdu2y1SwgcVsZNFTw1Ga73CqNZdEkzAf1YN8ij1K+dL0voQIbd IUdH1xi/Ns9RyEfuQW3rrWUZP2Ee27EkEzA1caXl4tJH5u5hKfbSh29RaPrzMnl5vMMZ 5KtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ddc23J6m; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6-v6si14932038plq.382.2018.05.21.15.23.38; Mon, 21 May 2018 15:23:53 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ddc23J6m; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753307AbeEUWX0 (ORCPT + 99 others); Mon, 21 May 2018 18:23:26 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:40114 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751473AbeEUWXX (ORCPT ); Mon, 21 May 2018 18:23:23 -0400 Received: by mail-qt0-f195.google.com with SMTP id h2-v6so20988807qtp.7 for ; Mon, 21 May 2018 15:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qkwX2YgxmQ26nOVX7FVrBptirf3oLctX7wN3Y79+zYs=; b=ddc23J6mFbllqpscBHjGdLqFhqc/9hk39ziCkV+nwMWctamPvv4sDzJ5er2mZv84Ku VlXJ1LS2WZc4rgajrQhn/GPJwTudOJ7kuiQ9L+nP1T8/rubphUKwuEfR5IXBy1+mDYfc LL+xdlfAu+5BKqpJ9loboq+lZOm6WeTkC9u9EDZy07Qq3iLLMKP2vBt4Mrs3XBB51RzA 77YK+I63RpKFx/oo6+qgcVRysp/Ywc+M/TzhvW9jQXwzbk2rLUtASpHMEQGnZGcxQkwc wfgWICoM4X2tmA8M0fTAp4SVctZtz56m9rzoGe04Jn6FqQ66A5Zy+TxmY7LH+Ib17jit STaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qkwX2YgxmQ26nOVX7FVrBptirf3oLctX7wN3Y79+zYs=; b=rluNScrZPwcao0jL4J1gYIxgHsgZN3VLoRFgw1iXBg/ysn+PymWIGvgM7FliiMfvgO ypQ2fm3LpGhHPyhv5nUkBRZyXYPofPm7xRkf236Gj39JE9Lh98v+h6/MpxI+evYs8bgi +FqOXQE8++x5q3Eca+67RxsDw3VaQQCcWcxbsPjE3AOR5voWYM3QaFt7Wgq5P8NsrrqF bHUa0ryhwoxuRYt9Ieoo6VUGACedTEnUS38C2+iK2M0eF2A/6s2svVdbhmws9ecDDvWC oQKsOQsMyIYDPtrN1je78kDgzTR2P6LdclK3jx66FxEk7CsPaKtEfGj1LKieyzsg609t g6Eg== X-Gm-Message-State: ALKqPweQ9c75zNJvEB3oe/PmtNdFEVQT+UlEiWrOkf1Fobwxbl91JVXV iljfP+cygiYUs6t/kJTf4gAs1pgj7Ey6vKzCTzk= X-Received: by 2002:aed:2c43:: with SMTP id f61-v6mr20158858qtd.105.1526941402760; Mon, 21 May 2018 15:23:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Mon, 21 May 2018 15:23:22 -0700 (PDT) In-Reply-To: <1526903890-35761-31-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-31-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 22 May 2018 01:23:22 +0300 Message-ID: Subject: Re: [PATCH 30/33] ALSA: oxygen: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , ALSA Development Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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; What's wrong with unsigned int i; ? > > 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 > -- With Best Regards, Andy Shevchenko