Skip to content

Commit 29b2625

Browse files
committed
ALSA: info: Move card id proc creation into info.c
The creation of card's id proc file can be moved gracefully into info.c. Also, the assignment of card->proc_id is superfluous and can be dropped. So let's do it. Basically this is no functional change but code refactoring, but one potential behavior change is that now it returns properly the error code from snd_info_card_register(), which is a good thing (tm). Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a858ee6 commit 29b2625

3 files changed

Lines changed: 14 additions & 31 deletions

File tree

‎include/sound/core.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ struct snd_card {
120120
struct list_head ctl_files; /* active control files */
121121

122122
struct snd_info_entry *proc_root; /* root for soundcard specific files */
123-
struct snd_info_entry *proc_id; /* the card id */
124123
struct proc_dir_entry *proc_root_link; /* number link to real id */
125124

126125
struct list_head files_list; /* all files associated to this card */

‎sound/core/info.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ int __exit snd_info_done(void)
504504
return 0;
505505
}
506506

507+
static void snd_card_id_read(struct snd_info_entry *entry,
508+
struct snd_info_buffer *buffer)
509+
{
510+
struct snd_card *card = entry->private_data;
511+
512+
snd_iprintf(buffer, "%s\n", card->id);
513+
}
514+
507515
/*
508516
* create a card proc file
509517
* called from init.c
@@ -521,7 +529,8 @@ int snd_info_card_create(struct snd_card *card)
521529
if (!entry)
522530
return -ENOMEM;
523531
card->proc_root = entry;
524-
return 0;
532+
533+
return snd_card_ro_proc_new(card, "id", card, snd_card_id_read);
525534
}
526535

527536
/*

‎sound/core/init.c‎

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -100,33 +100,6 @@ int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
100100
EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
101101
#endif
102102

103-
#ifdef CONFIG_SND_PROC_FS
104-
static void snd_card_id_read(struct snd_info_entry *entry,
105-
struct snd_info_buffer *buffer)
106-
{
107-
struct snd_card *card = entry->private_data;
108-
109-
snd_iprintf(buffer, "%s\n", card->id);
110-
}
111-
112-
static int init_info_for_card(struct snd_card *card)
113-
{
114-
struct snd_info_entry *entry;
115-
116-
entry = snd_info_create_card_entry(card, "id", card->proc_root);
117-
if (!entry) {
118-
dev_dbg(card->dev, "unable to create card entry\n");
119-
return -ENOMEM;
120-
}
121-
snd_info_set_text_ops(entry, card, snd_card_id_read);
122-
card->proc_id = entry;
123-
124-
return snd_info_card_register(card);
125-
}
126-
#else /* !CONFIG_SND_PROC_FS */
127-
#define init_info_for_card(card)
128-
#endif
129-
130103
static int check_empty_slot(struct module *module, int slot)
131104
{
132105
return !slots[slot] || !*slots[slot];
@@ -493,7 +466,6 @@ static int snd_card_do_free(struct snd_card *card)
493466
snd_device_free_all(card);
494467
if (card->private_free)
495468
card->private_free(card);
496-
snd_info_free_entry(card->proc_id);
497469
if (snd_info_card_free(card) < 0) {
498470
dev_warn(card->dev, "unable to free card info\n");
499471
/* Not fatal error */
@@ -797,7 +769,10 @@ int snd_card_register(struct snd_card *card)
797769
}
798770
snd_cards[card->number] = card;
799771
mutex_unlock(&snd_card_mutex);
800-
init_info_for_card(card);
772+
err = snd_info_card_register(card);
773+
if (err < 0)
774+
return err;
775+
801776
#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
802777
if (snd_mixer_oss_notify_callback)
803778
snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);

0 commit comments

Comments
 (0)