ALSA: pcm: Remove superfluous snd_info_register() calls

The calls of snd_info_register() are superfluous and should be avoided
at the procfs creation time.  They are called at the end of the whole
initialization via snd_card_register().  This patch drops such
superfluous calls, as well as cleaning up the calls of substream proc
entries with a common helper.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2019-02-04 15:02:11 +01:00
Родитель 69fad28cef
Коммит a8d149813b
2 изменённых файлов: 37 добавлений и 65 удалений

Просмотреть файл

@ -528,28 +528,17 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
if (!entry)
return -ENOMEM;
entry->mode = S_IFDIR | 0555;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
return -ENOMEM;
}
pstr->proc_root = entry;
entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root);
if (entry) {
if (entry)
snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
#ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
pstr->proc_root);
if (entry) {
entry->c.text.read = snd_pcm_xrun_debug_read;
snd_info_set_text_ops(entry, pstr, snd_pcm_xrun_debug_read);
entry->c.text.write = snd_pcm_xrun_debug_write;
entry->mode |= 0200;
entry->private_data = pstr;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
#endif
return 0;
@ -562,6 +551,21 @@ static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
return 0;
}
static struct snd_info_entry *
create_substream_info_entry(struct snd_pcm_substream *substream,
const char *name,
void (*read)(struct snd_info_entry *,
struct snd_info_buffer *))
{
struct snd_info_entry *entry;
entry = snd_info_create_card_entry(substream->pcm->card, name,
substream->proc_root);
if (entry)
snd_info_set_text_ops(entry, substream, read);
return entry;
}
static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
{
struct snd_info_entry *entry;
@ -576,53 +580,22 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
if (!entry)
return -ENOMEM;
entry->mode = S_IFDIR | 0555;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
return -ENOMEM;
}
substream->proc_root = entry;
entry = snd_info_create_card_entry(card, "info", substream->proc_root);
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_info_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
entry = snd_info_create_card_entry(card, "hw_params",
substream->proc_root);
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_hw_params_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
entry = snd_info_create_card_entry(card, "sw_params",
substream->proc_root);
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_sw_params_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
entry = snd_info_create_card_entry(card, "status",
substream->proc_root);
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_status_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
create_substream_info_entry(substream, "info",
snd_pcm_substream_proc_info_read);
create_substream_info_entry(substream, "hw_params",
snd_pcm_substream_proc_hw_params_read);
create_substream_info_entry(substream, "sw_params",
snd_pcm_substream_proc_sw_params_read);
create_substream_info_entry(substream, "status",
snd_pcm_substream_proc_status_read);
#ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(card, "xrun_injection",
substream->proc_root);
entry = create_substream_info_entry(substream, "xrun_injection", NULL);
if (entry) {
entry->private_data = substream;
entry->c.text.read = NULL;
entry->c.text.write = snd_pcm_xrun_injection_write;
entry->mode = S_IFREG | 0200;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
#endif /* CONFIG_SND_PCM_XRUN_DEBUG */

Просмотреть файл

@ -192,20 +192,19 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
{
struct snd_info_entry *entry;
if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) {
entry->c.text.read = snd_pcm_lib_preallocate_proc_read;
entry = snd_info_create_card_entry(substream->pcm->card, "prealloc",
substream->proc_root);
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_lib_preallocate_proc_read);
entry->c.text.write = snd_pcm_lib_preallocate_proc_write;
entry->mode |= 0200;
entry->private_data = substream;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", substream->proc_root)) != NULL) {
entry->c.text.read = snd_pcm_lib_preallocate_max_proc_read;
entry->private_data = substream;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max",
substream->proc_root);
if (entry)
snd_info_set_text_ops(entry, substream,
snd_pcm_lib_preallocate_max_proc_read);
}
#else /* !CONFIG_SND_VERBOSE_PROCFS */