All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 8/8] ALSA: core: Clean up OSS proc file management
Date: Thu, 23 Apr 2015 16:49:30 +0200	[thread overview]
Message-ID: <1429800570-10153-9-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1429800570-10153-1-git-send-email-tiwai@suse.de>

A few minor cleanups:
- Move the call of snd_info_minor_register() into snd_info_init() so
  that we can call all proc-related stuff in a shot
- Add missing __init prefix to snd_info_minor_register()
- Return an error properly from snd_oss_info_register()
- Drop snd_info_minor_unregister() that is superfluous now

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/info.h  |  4 +---
 sound/core/info.c     |  3 ++-
 sound/core/info_oss.c | 25 +++++++------------------
 sound/core/sound.c    |  2 --
 4 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/include/sound/info.h b/include/sound/info.h
index 3e2fda3c75ee..16269951bafc 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -94,10 +94,8 @@ struct snd_info_entry {
 
 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
 int snd_info_minor_register(void);
-int snd_info_minor_unregister(void);
 #else
-#define snd_info_minor_register() /* NOP */
-#define snd_info_minor_unregister() /* NOP */
+#define snd_info_minor_register()	0
 #endif
 
 
diff --git a/sound/core/info.c b/sound/core/info.c
index f8bdd9b6f322..c8a413d6cc9b 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -479,7 +479,8 @@ int __init snd_info_init(void)
 	if (snd_info_version_init() < 0 ||
 	    snd_minor_info_init() < 0 ||
 	    snd_minor_info_oss_init() < 0 ||
-	    snd_card_info_init() < 0)
+	    snd_card_info_init() < 0 ||
+	    snd_info_minor_register() < 0)
 		goto error;
 	return 0;
 
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c
index bd4d2c6233c2..1478c8dfd473 100644
--- a/sound/core/info_oss.c
+++ b/sound/core/info_oss.c
@@ -35,7 +35,6 @@
 
 static DEFINE_MUTEX(strings);
 static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
-static struct snd_info_entry *snd_sndstat_proc_entry;
 
 int snd_oss_info_register(int dev, int num, char *string)
 {
@@ -110,25 +109,15 @@ static void snd_sndstat_proc_read(struct snd_info_entry *entry,
 	snd_sndstat_show_strings(buffer, "Mixers", SNDRV_OSS_INFO_DEV_MIXERS);
 }
 
-int snd_info_minor_register(void)
+int __init snd_info_minor_register(void)
 {
 	struct snd_info_entry *entry;
 
 	memset(snd_sndstat_strings, 0, sizeof(snd_sndstat_strings));
-	if ((entry = snd_info_create_module_entry(THIS_MODULE, "sndstat", snd_oss_root)) != NULL) {
-		entry->c.text.read = snd_sndstat_proc_read;
-		if (snd_info_register(entry) < 0) {
-			snd_info_free_entry(entry);
-			entry = NULL;
-		}
-	}
-	snd_sndstat_proc_entry = entry;
-	return 0;
-}
-
-int snd_info_minor_unregister(void)
-{
-	snd_info_free_entry(snd_sndstat_proc_entry);
-	snd_sndstat_proc_entry = NULL;
-	return 0;
+	entry = snd_info_create_module_entry(THIS_MODULE, "sndstat",
+					     snd_oss_root);
+	if (!entry)
+		return -ENOMEM;
+	entry->c.text.read = snd_sndstat_proc_read;
+	return snd_info_register(entry); /* freed in error path */
 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 8fc402e4ff35..e5d37bd7c226 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -409,7 +409,6 @@ static int __init alsa_sound_init(void)
 		unregister_chrdev(major, "alsa");
 		return -ENOMEM;
 	}
-	snd_info_minor_register();
 #ifndef MODULE
 	pr_info("Advanced Linux Sound Architecture Driver Initialized.\n");
 #endif
@@ -418,7 +417,6 @@ static int __init alsa_sound_init(void)
 
 static void __exit alsa_sound_exit(void)
 {
-	snd_info_minor_unregister();
 	snd_info_done();
 	unregister_chrdev(major, "alsa");
 }
-- 
2.3.5

  parent reply	other threads:[~2015-04-23 14:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 14:49 [PATCH 0/8] Proc file cleanups Takashi Iwai
2015-04-23 14:49 ` [PATCH 1/8] ALSA: core: Use seq_file for text proc file reads Takashi Iwai
2015-04-23 14:49 ` [PATCH 2/8] ALSA: core: Fix possible memory leaks at error path in info.c Takashi Iwai
2015-04-23 14:49 ` [PATCH 3/8] ALSA: core: Remove child proc file elements recursively Takashi Iwai
2015-04-23 14:49 ` [PATCH 4/8] ALSA: core: Manage asound root directory with snd_info_entry Takashi Iwai
2015-04-23 14:49 ` [PATCH 5/8] ALSA: core: Remove superfluous exit calls for proc entries Takashi Iwai
2015-04-23 14:49 ` [PATCH 6/8] ALSA: core: Don't ignore errors at creating proc files Takashi Iwai
2015-04-23 14:49 ` [PATCH 7/8] ALSA: core: Build conditionally and remove superfluous ifdefs Takashi Iwai
2015-04-23 14:49 ` Takashi Iwai [this message]
2015-04-23 15:03 ` [PATCH 0/8] Proc file cleanups Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429800570-10153-9-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.