ALSA: when card identification is changed, change also /proc/asound symlink

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/include/sound/info.h b/include/sound/info.h
index 8ae72e7..46f702a 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -126,6 +126,7 @@
 int snd_info_card_register(struct snd_card * card);
 int snd_info_card_free(struct snd_card * card);
 void snd_info_card_disconnect(struct snd_card * card);
+void snd_info_card_id_change(struct snd_card * card);
 int snd_info_register(struct snd_info_entry * entry);
 
 /* for card drivers */
@@ -160,6 +161,7 @@
 static inline int snd_info_card_register(struct snd_card * card) { return 0; }
 static inline int snd_info_card_free(struct snd_card * card) { return 0; }
 static inline void snd_info_card_disconnect(struct snd_card * card) { }
+static inline void snd_info_card_id_change(struct snd_card * card) { }
 static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
 
 static inline int snd_card_proc_new(struct snd_card *card, const char *name,
diff --git a/sound/core/info.c b/sound/core/info.c
index 527b207..70fa871 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -653,6 +653,23 @@
 }
 
 /*
+ * called on card->id change
+ */
+void snd_info_card_id_change(struct snd_card *card)
+{
+	mutex_lock(&info_mutex);
+	if (card->proc_root_link) {
+		snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
+		card->proc_root_link = NULL;
+	}
+	if (strcmp(card->id, card->proc_root->name))
+		card->proc_root_link = proc_symlink(card->id,
+						    snd_proc_root,
+						    card->proc_root->name);
+	mutex_unlock(&info_mutex);
+}
+
+/*
  * de-register the card proc file
  * called from init.c
  */
diff --git a/sound/core/init.c b/sound/core/init.c
index 5ff297d..af1e407 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -571,6 +571,7 @@
 			goto __exist;
 	}
 	strcpy(card->id, buf1);
+	snd_info_card_id_change(card);
 	mutex_unlock(&snd_card_mutex);
 
 	return count;