Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp936610imm; Thu, 31 May 2018 12:04:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK6rHJecA+b1P/lK++seDY7nJCSUYjH6vv/BecNjBO1xLpuMHFdpYHofyZzTkKNrywCz8Kz X-Received: by 2002:a62:be10:: with SMTP id l16-v6mr7789090pff.180.1527793471747; Thu, 31 May 2018 12:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527793471; cv=none; d=google.com; s=arc-20160816; b=F0NHNK3A/RyZCRF8/BSZ3N/F+KCNCinchd25CrqIJdcpfyLXJnd/Ex0o01nrBS1uws SnRFN/EvK3TE9UZ2r+dZmQTJSTlPRxRdw+buSZtsvuSBu/QxXEzybqqxNCeo/C9d17y+ p3+ilYQAqTg019YkId+lYRUAf4Ho9zfOElp6+jVZNw+NE8HIaqshakGI9oJ/V3GbzOxN Kyo/ckwFSUwgA2vTnhlqNQVxWY2/iotrjAFcEPDortNE+qMgRr3An8/o7BtgWDFqq0JB R6RqmYSFUuZHuyjEQMMZYebwa/QwXfk/3gnsZnqtH2J+8QIam0RFodmKCb0dx1q36x/o 7WeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date :arc-authentication-results; bh=IUCziKzvjKz59+83nO0V59zMkMvHmaVkrgYHKFSGoQs=; b=0qVr4xGGQuZRJ3gk+bgXxksS6VH9tgJi0Xt9Na4AF9U6UdbeosGxX7bSQaiuQD5SmH YCYJ891BU1w1fWyxCJrxn8MYChInuHK8Rw+HQhRR7ogYe4ZOugpA6VkP0apr/CDqIpQg ZnoHm2pJrMZQ0uCoBqUXV46yn6QzfbaoTSRXwLn75kiZI09i74ESmRvwc8rORekwbHJ9 GgIgF5c6vjCK7LzTZ1LdSnD785R2XsdXCScmuvLRrzbhaoxXUk9ThZSbC75xoEedRgsh s9YSgWWikRwX12fV91tNpnhCLTLFY10jPCXSVSd0gfWCGAm/654OQ57+A+mMbeYoFNBB UoyA== 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 l3-v6si37317286pld.96.2018.05.31.12.04.07; Thu, 31 May 2018 12:04:31 -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 S1756052AbeEaS7g (ORCPT + 99 others); Thu, 31 May 2018 14:59:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:32848 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756035AbeEaS7f (ORCPT ); Thu, 31 May 2018 14:59:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 169C2AD5B; Thu, 31 May 2018 18:59:34 +0000 (UTC) Date: Thu, 31 May 2018 20:59:33 +0200 Message-ID: From: Takashi Iwai To: "Andy Shevchenko" Cc: "Yisheng Xie" , "ALSA Development Mailing List" , "Clemens Ladisch" , "Jaroslav Kysela" , "Linux Kernel Mailing List" Subject: Re: [PATCH v2 15/21] ALSA: oxygen: use match_string() helper In-Reply-To: References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-16-git-send-email-xieyisheng1@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 31 May 2018 20:41:36 +0200, Andy Shevchenko wrote: > > On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie wrote: > > match_string() returns the index of an array for a matching string, > > which can be used instead of open coded variant. > > Sorry, didn't notice before one thing: > > > + 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; > > + } > > It looks to me you may get rid of j completely by utilizing existing err. Well, err isn't ideal as it's referred as the actual index. That is, the line below looks weird to me: chip->controls[err] = ctl; Of course, j isn't the best name, either, but at least, keeping the same variable makes the code conversion logic clearer. thanks, Takashi