[alsa-devel] [PATCH v2 16/21] ASoC: max98088: use match_string() helper
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(-)
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)
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?
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
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.
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
The patch
ASoC: max98088: use match_string() helper
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 3470631510fa383feac5969b436499ca9bad03b8 Mon Sep 17 00:00:00 2001
From: Xie Yisheng xieyisheng1@huawei.com Date: Thu, 31 May 2018 19:11:21 +0800 Subject: [PATCH] ASoC: max98088: use match_string() helper
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 Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/max98088.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 865f64c40b79..fb515aaa54fc 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -1382,15 +1382,12 @@ static const char *eq_mode_name[] = {"EQ1 Mode", "EQ2 Mode"};
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)
participants (2)
-
Mark Brown
-
Yisheng Xie