summaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-01-23 16:44:38 +0100
committerTakashi Iwai <tiwai@suse.de>2019-01-24 14:40:25 +0100
commit480e32ebd524ffdf3d50cc5cac179fb9e44a552d (patch)
tree7f9030fe1751a73ab636c567305f1a6e848b3e36 /sound/core/pcm.c
parentde89750c56f4bf2f04492c6ce298911381a7597a (diff)
downloadlinux-480e32ebd524ffdf3d50cc5cac179fb9e44a552d.tar.bz2
ALSA: pcm: Simplify proc file destruction
The proc files are recursively freed by calling with the root snd_info_entry object, so we don't have to keep each object for releasing one by one. Move the release of the PCM stream proc root at the beginning, so that we can remove the redundant code and resource. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c66
1 files changed, 11 insertions, 55 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index ca1ea3cf9350..bca0bdf3e33c 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -536,12 +536,9 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root);
if (entry) {
snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read);
- if (snd_info_register(entry) < 0) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- pstr->proc_info_entry = entry;
#ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(pcm->card, "xrun_debug",
@@ -551,24 +548,15 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr)
entry->c.text.write = snd_pcm_xrun_debug_write;
entry->mode |= 0200;
entry->private_data = pstr;
- if (snd_info_register(entry) < 0) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- pstr->proc_xrun_debug_entry = entry;
#endif
return 0;
}
static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr)
{
-#ifdef CONFIG_SND_PCM_XRUN_DEBUG
- snd_info_free_entry(pstr->proc_xrun_debug_entry);
- pstr->proc_xrun_debug_entry = NULL;
-#endif
- snd_info_free_entry(pstr->proc_info_entry);
- pstr->proc_info_entry = NULL;
snd_info_free_entry(pstr->proc_root);
pstr->proc_root = NULL;
return 0;
@@ -597,45 +585,33 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream)
if (entry) {
snd_info_set_text_ops(entry, substream,
snd_pcm_substream_proc_info_read);
- if (snd_info_register(entry) < 0) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- substream->proc_info_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) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- substream->proc_hw_params_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) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- substream->proc_sw_params_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) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- substream->proc_status_entry = entry;
#ifdef CONFIG_SND_PCM_XRUN_DEBUG
entry = snd_info_create_card_entry(card, "xrun_injection",
@@ -645,40 +621,18 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *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) {
+ if (snd_info_register(entry) < 0)
snd_info_free_entry(entry);
- entry = NULL;
- }
}
- substream->proc_xrun_injection_entry = entry;
#endif /* CONFIG_SND_PCM_XRUN_DEBUG */
return 0;
}
-static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
-{
- snd_info_free_entry(substream->proc_info_entry);
- substream->proc_info_entry = NULL;
- snd_info_free_entry(substream->proc_hw_params_entry);
- substream->proc_hw_params_entry = NULL;
- snd_info_free_entry(substream->proc_sw_params_entry);
- substream->proc_sw_params_entry = NULL;
- snd_info_free_entry(substream->proc_status_entry);
- substream->proc_status_entry = NULL;
-#ifdef CONFIG_SND_PCM_XRUN_DEBUG
- snd_info_free_entry(substream->proc_xrun_injection_entry);
- substream->proc_xrun_injection_entry = NULL;
-#endif
- snd_info_free_entry(substream->proc_root);
- substream->proc_root = NULL;
- return 0;
-}
#else /* !CONFIG_SND_VERBOSE_PROCFS */
static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; }
static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; }
static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; }
-static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; }
#endif /* CONFIG_SND_VERBOSE_PROCFS */
static const struct attribute_group *pcm_dev_attr_groups[];
@@ -911,15 +865,17 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
struct snd_pcm_oss_setup *setup, *setupn;
#endif
+
+ /* free all proc files under the stream */
+ snd_pcm_stream_proc_done(pstr);
+
substream = pstr->substream;
while (substream) {
substream_next = substream->next;
snd_pcm_timer_done(substream);
- snd_pcm_substream_proc_done(substream);
kfree(substream);
substream = substream_next;
}
- snd_pcm_stream_proc_done(pstr);
#if IS_ENABLED(CONFIG_SND_PCM_OSS)
for (setup = pstr->oss.setup_list; setup; setup = setupn) {
setupn = setup->next;