diff mbox

[v2,16/21] ASoC: max98088: use match_string() helper

Message ID 1527765086-19873-17-git-send-email-xieyisheng1@huawei.com (mailing list archive)
State Accepted
Commit 3470631510fa383feac5969b436499ca9bad03b8
Headers show

Commit Message

Xie Yisheng May 31, 2018, 11:11 a.m. UTC
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
 - split ret=xxx and move assignment to the line before 'if'
 - fix error return value - both per Andy

 sound/soc/codecs/max98088.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Mark Brown May 31, 2018, 11:49 a.m. UTC | #1
On Thu, May 31, 2018 at 07:11:21PM +0800, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.

I don't have either the cover letter or the rest of the series here so
I've no context - what is the story here with regard to dependencies and
things?
Xie Yisheng May 31, 2018, 12:25 p.m. UTC | #2
Hi Mark,

On 2018/5/31 19:49, Mark Brown wrote:
> On Thu, May 31, 2018 at 07:11:21PM +0800, Yisheng Xie wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used instead of open coded variant.
> 
> I don't have either the cover letter or the rest of the series here so
> I've no context - what is the story here with regard to dependencies and
> things?
Sorry about that I should have sent cover letter to you, but for too many maintainer
to sent, I ignore this to avoid make too much noisy.

Anyway, Here is the cover letter of v1 and I have add v2's cover letter to you:
  https://lkml.org/lkml/2018/5/21/303

Each patch in this patchset is a separate one, for what this patchset want to do
is use match_string() helper for echo subsystem.

Thanks
Yisheng
>
Mark Brown May 31, 2018, 4:02 p.m. UTC | #3
On Thu, May 31, 2018 at 08:25:39PM +0800, Yisheng Xie wrote:

> Anyway, Here is the cover letter of v1 and I have add v2's cover letter to you:
>   https://lkml.org/lkml/2018/5/21/303

> Each patch in this patchset is a separate one, for what this patchset want to do
> is use match_string() helper for echo subsystem.

For something like this it's generally easier to not send everything as
one big series - it avoids any confusion about dependencies and there's
no actual relationship between the patches.  Instead just sending each
subsystem as a series or perhaps even just a bunch of separate patches
should make things smoother.
Xie Yisheng June 1, 2018, 12:38 a.m. UTC | #4
Hi Mark,

On 2018/6/1 0:02, Mark Brown wrote:
> On Thu, May 31, 2018 at 08:25:39PM +0800, Yisheng Xie wrote:
> 
>> Anyway, Here is the cover letter of v1 and I have add v2's cover letter to you:
>>   https://lkml.org/lkml/2018/5/21/303
> 
>> Each patch in this patchset is a separate one, for what this patchset want to do
>> is use match_string() helper for echo subsystem.
> 
> For something like this it's generally easier to not send everything as
> one big series - it avoids any confusion about dependencies and there's
> no actual relationship between the patches.  Instead just sending each
> subsystem as a series or perhaps even just a bunch of separate patches
> should make things smoother.

Thanks, will take this suggestion maybe next time.

Thanks
Yisheng
>
diff mbox

Patch

diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 865f64c..fb515aa 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -1382,15 +1382,12 @@  static int max98088_set_bias_level(struct snd_soc_component *component,
 
 static int max98088_get_channel(struct snd_soc_component *component, const char *name)
 {
-	int i;
+	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(eq_mode_name); i++)
-		if (strcmp(name, eq_mode_name[i]) == 0)
-			return i;
-
-	/* Shouldn't happen */
-	dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
-	return -EINVAL;
+	ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
+	if (ret < 0)
+		dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
+	return ret;
 }
 
 static void max98088_setup_eq1(struct snd_soc_component *component)