[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1526903890-35761-31-git-send-email-xieyisheng1@huawei.com>
Date: Mon, 21 May 2018 19:58:07 +0800
From: Yisheng Xie <xieyisheng1@...wei.com>
To: <linux-kernel@...r.kernel.org>
CC: Yisheng Xie <xieyisheng1@...wei.com>,
Clemens Ladisch <clemens@...isch.de>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, <alsa-devel@...a-project.org>
Subject: [PATCH 30/33] ALSA: oxygen: use match_string() helper
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.
Cc: Clemens Ladisch <clemens@...isch.de>
Cc: Jaroslav Kysela <perex@...ex.cz>
Cc: Takashi Iwai <tiwai@...e.com>
Cc: alsa-devel@...a-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
---
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;
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
Powered by blists - more mailing lists