Commit c2eb9c4ea383aee154e7139395872c4da629e715

Authored by Jaroslav Kysela
Committed by Takashi Iwai
1 parent 9fb6198e8c

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>

Showing 3 changed files with 20 additions and 0 deletions Side-by-side Diff

include/sound/info.h
... ... @@ -126,6 +126,7 @@
126 126 int snd_info_card_register(struct snd_card * card);
127 127 int snd_info_card_free(struct snd_card * card);
128 128 void snd_info_card_disconnect(struct snd_card * card);
  129 +void snd_info_card_id_change(struct snd_card * card);
129 130 int snd_info_register(struct snd_info_entry * entry);
130 131  
131 132 /* for card drivers */
... ... @@ -160,6 +161,7 @@
160 161 static inline int snd_info_card_register(struct snd_card * card) { return 0; }
161 162 static inline int snd_info_card_free(struct snd_card * card) { return 0; }
162 163 static inline void snd_info_card_disconnect(struct snd_card * card) { }
  164 +static inline void snd_info_card_id_change(struct snd_card * card) { }
163 165 static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
164 166  
165 167 static inline int snd_card_proc_new(struct snd_card *card, const char *name,
... ... @@ -653,6 +653,23 @@
653 653 }
654 654  
655 655 /*
  656 + * called on card->id change
  657 + */
  658 +void snd_info_card_id_change(struct snd_card *card)
  659 +{
  660 + mutex_lock(&info_mutex);
  661 + if (card->proc_root_link) {
  662 + snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
  663 + card->proc_root_link = NULL;
  664 + }
  665 + if (strcmp(card->id, card->proc_root->name))
  666 + card->proc_root_link = proc_symlink(card->id,
  667 + snd_proc_root,
  668 + card->proc_root->name);
  669 + mutex_unlock(&info_mutex);
  670 +}
  671 +
  672 +/*
656 673 * de-register the card proc file
657 674 * called from init.c
658 675 */
... ... @@ -571,6 +571,7 @@
571 571 goto __exist;
572 572 }
573 573 strcpy(card->id, buf1);
  574 + snd_info_card_id_change(card);
574 575 mutex_unlock(&snd_card_mutex);
575 576  
576 577 return count;