Skip to contentSkip to conversation

ALSA: hda: Clean up jack name helpers

PATCH New Takashi Iwai 1 participant 3 messages Jul 30 Sound

lore
Share & tools
lore
#0 lore raw

cover ALSA: hda: Clean up jack name helpers

[ resent as the previous submission went wrong; apologies if you already
received this ]

A couple of cleanup patches for HD-audio jack name helper functions and callers. Here simply dropping the useless code.

Takashi

===

Takashi Iwai (2):
ALSA: hda: Drop unneeded calculation of index at get_jack_mode_name()
ALSA: hda: Drop index handling from snd_hda_get_pin_label()

 sound/hda/codecs/generic.c         | 19 +--------
 sound/hda/common/auto_parser.c     | 66 +++++-------------------------
 sound/hda/common/hda_auto_parser.h |  2 +-
 sound/hda/common/jack.c            |  2 +-
 4 files changed, 14 insertions(+), 75 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 ALSA: hda: Drop unneeded calculation of index at get_jack_mode_name()

get_jack_mode_name() tries to identify the (potential) index number of the control element to be created, but this index number isn't actually used, since the index is set automatically at instantiating the controls.

Drop the unneeded index retrieval and calculation as a cleanup. Along with the change, find_kctl_name() is no longer used, hence drop this function as well.

---
 sound/hda/codecs/generic.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
sound/hda/codecs/generic.c +1 -18
index 660a9f2c0ded..9f6f44cdbe1e 100644
@@ -2695,30 +2695,13 @@ static const struct snd_kcontrol_new out_jack_mode_enum = {
 	.put = out_jack_mode_put,
 };
 
-static bool find_kctl_name(struct hda_codec *codec, const char *name, int idx)
-{
-	struct hda_gen_spec *spec = codec->spec;
-	const struct snd_kcontrol_new *kctl;
-	int i;
-
-	snd_array_for_each(&spec->kctls, i, kctl) {
-		if (!strcmp(kctl->name, name) && kctl->index == idx)
-			return true;
-	}
-	return false;
-}
-
 static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin,
 			       char *name, size_t name_len)
 {
 	struct hda_gen_spec *spec = codec->spec;
-	int idx = 0;
 
-	snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, &idx);
+	snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, NULL);
 	strlcat(name, " Jack Mode", name_len);
-
-	for (; find_kctl_name(codec, name, idx); idx++)
-		;
 }
 
 static int get_out_jack_num_items(struct hda_codec *codec, hda_nid_t pin)
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/2 ALSA: hda: Drop index handling from snd_hda_get_pin_label()

In reply to Takashi Iwai

Now no one calls snd_hda_get_pin_label() with the index pointer, so let's drop the index handling from this helper function as a code cleanup. This results in reduction of unneeded code.

---
 sound/hda/codecs/generic.c         |  2 +-
 sound/hda/common/auto_parser.c     | 66 +++++-------------------------
 sound/hda/common/hda_auto_parser.h |  2 +-
 sound/hda/common/jack.c            |  2 +-
 4 files changed, 14 insertions(+), 58 deletions(-)
sound/hda/codecs/generic.c +1 -1
index 9f6f44cdbe1e..a4623dd67f81 100644
@@ -2700,7 +2700,7 @@ static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin,
 {
 	struct hda_gen_spec *spec = codec->spec;
 
-	snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, NULL);
+	snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len);
 	strlcat(name, " Jack Mode", name_len);
 }
 
sound/hda/common/auto_parser.c +11 -55

131 lines not on this page · raw message

sound/hda/common/hda_auto_parser.h +1 -1
index 87af3d8c02f7..3c5f3ad40074 100644
@@ -46,7 +46,7 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
 					int input);
 int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 			  const struct auto_pin_cfg *cfg,
-			  char *label, int maxlen, int *indexp);
+			  char *label, int maxlen);
 
 enum {
 	INPUT_PIN_ATTR_UNUSED,	/* pin not connected */
sound/hda/common/jack.c +1 -1
index e0a5cc38540b..c4338f03a54d 100644
@@ -612,7 +612,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
 	if (base_name)
 		strscpy(name, base_name, sizeof(name));
 	else
-		snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL);
+		snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name));
 	if (phantom_jack)
 		/* Example final name: "Internal Mic Phantom Jack" */
 		strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
Signature · 1 line
2.55.0