Skip to content

Commit c2eb9c4

Browse files
perexgtiwai
authored andcommitted
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>
1 parent 9fb6198 commit c2eb9c4

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎include/sound/info.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int snd_info_card_create(struct snd_card * card);
126126
int snd_info_card_register(struct snd_card * card);
127127
int snd_info_card_free(struct snd_card * card);
128128
void snd_info_card_disconnect(struct snd_card * card);
129+
void snd_info_card_id_change(struct snd_card * card);
129130
int snd_info_register(struct snd_info_entry * entry);
130131

131132
/* for card drivers */
@@ -160,6 +161,7 @@ static inline int snd_info_card_create(struct snd_card * card) { return 0; }
160161
static inline int snd_info_card_register(struct snd_card * card) { return 0; }
161162
static inline int snd_info_card_free(struct snd_card * card) { return 0; }
162163
static inline void snd_info_card_disconnect(struct snd_card * card) { }
164+
static inline void snd_info_card_id_change(struct snd_card * card) { }
163165
static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
164166

165167
static inline int snd_card_proc_new(struct snd_card *card, const char *name,

‎sound/core/info.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,23 @@ int snd_info_card_register(struct snd_card *card)
652652
return 0;
653653
}
654654

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+
655672
/*
656673
* de-register the card proc file
657674
* called from init.c

‎sound/core/init.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ card_id_store_attr(struct device *dev, struct device_attribute *attr,
571571
goto __exist;
572572
}
573573
strcpy(card->id, buf1);
574+
snd_info_card_id_change(card);
574575
mutex_unlock(&snd_card_mutex);
575576

576577
return count;

0 commit comments

Comments
 (0)