From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756069AbeEaS7g (ORCPT ); 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 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 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