Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[firefly-linux-kernel-4.4.55.git] / sound / core / ctljack.c
index 6435e82cacf9048d7f1fae7b13a7fbc6a0812392..84a3cd683068a3bbf4a752e05c399600ce83572b 100644 (file)
@@ -41,8 +41,11 @@ static int get_available_index(struct snd_card *card, const char *name)
        sid.iface = SNDRV_CTL_ELEM_IFACE_CARD;
        strlcpy(sid.name, name, sizeof(sid.name));
 
-       while (snd_ctl_find_id(card, &sid))
+       while (snd_ctl_find_id(card, &sid)) {
                sid.index++;
+               /* reset numid; otherwise snd_ctl_find_id() hits this again */
+               sid.numid = 0;
+       }
 
        return sid.index;
 }
@@ -70,11 +73,10 @@ snd_kctl_jack_new(const char *name, struct snd_card *card)
                return NULL;
 
        jack_kctl_name_gen(kctl->id.name, name, sizeof(kctl->id.name));
-       kctl->id.index = get_available_index(card, name);
+       kctl->id.index = get_available_index(card, kctl->id.name);
        kctl->private_value = 0;
        return kctl;
 }
-EXPORT_SYMBOL_GPL(snd_kctl_jack_new);
 
 void snd_kctl_jack_report(struct snd_card *card,
                          struct snd_kcontrol *kctl, bool status)
@@ -84,4 +86,3 @@ void snd_kctl_jack_report(struct snd_card *card,
        kctl->private_value = status;
        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
 }
-EXPORT_SYMBOL_GPL(snd_kctl_jack_report);