Commit a8d14981 authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 69fad28c
...@@ -528,28 +528,17 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) ...@@ -528,28 +528,17 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
entry->mode = S_IFDIR | 0555; entry->mode = S_IFDIR | 0555;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
return -ENOMEM;
}
pstr->proc_root = entry; pstr->proc_root = entry;
entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root); 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); 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 #ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(pcm->card, "xrun_debug", entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
pstr->proc_root); pstr->proc_root);
if (entry) { 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->c.text.write = snd_pcm_xrun_debug_write;
entry->mode |= 0200; entry->mode |= 0200;
entry->private_data = pstr;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
} }
#endif #endif
return 0; return 0;
...@@ -562,6 +551,21 @@ static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) ...@@ -562,6 +551,21 @@ static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
return 0; 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) static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
{ {
struct snd_info_entry *entry; struct snd_info_entry *entry;
...@@ -576,53 +580,22 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) ...@@ -576,53 +580,22 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
entry->mode = S_IFDIR | 0555; entry->mode = S_IFDIR | 0555;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
return -ENOMEM;
}
substream->proc_root = entry; substream->proc_root = entry;
entry = snd_info_create_card_entry(card, "info", substream->proc_root);
if (entry) { create_substream_info_entry(substream, "info",
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_info_read); snd_pcm_substream_proc_info_read);
if (snd_info_register(entry) < 0) create_substream_info_entry(substream, "hw_params",
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); snd_pcm_substream_proc_hw_params_read);
if (snd_info_register(entry) < 0) create_substream_info_entry(substream, "sw_params",
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); snd_pcm_substream_proc_sw_params_read);
if (snd_info_register(entry) < 0) create_substream_info_entry(substream, "status",
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); snd_pcm_substream_proc_status_read);
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
}
#ifdef CONFIG_SND_PCM_XRUN_DEBUG #ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(card, "xrun_injection", entry = create_substream_info_entry(substream, "xrun_injection", NULL);
substream->proc_root);
if (entry) { if (entry) {
entry->private_data = substream;
entry->c.text.read = NULL;
entry->c.text.write = snd_pcm_xrun_injection_write; entry->c.text.write = snd_pcm_xrun_injection_write;
entry->mode = S_IFREG | 0200; entry->mode = S_IFREG | 0200;
if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
} }
#endif /* CONFIG_SND_PCM_XRUN_DEBUG */ #endif /* CONFIG_SND_PCM_XRUN_DEBUG */
......
...@@ -192,20 +192,19 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream) ...@@ -192,20 +192,19 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
{ {
struct snd_info_entry *entry; struct snd_info_entry *entry;
if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) { entry = snd_info_create_card_entry(substream->pcm->card, "prealloc",
entry->c.text.read = snd_pcm_lib_preallocate_proc_read; 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->c.text.write = snd_pcm_lib_preallocate_proc_write;
entry->mode |= 0200; 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 */ #else /* !CONFIG_SND_VERBOSE_PROCFS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment