diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-12-01 10:42:42 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 12:30:02 +0100 |
commit | e28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4 (patch) | |
tree | b69095abb998dedc2953368ba2c75978d80f644a /sound/core/init.c | |
parent | 7cd01dd840824e7c6023ad1dbfdb94a2183a7adb (diff) | |
download | op-kernel-dev-e28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4.zip op-kernel-dev-e28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4.tar.gz |
[ALSA] Optimize for config without PROC_FS
Modules: HWDEP Midlevel,ALSA Core,PCM Midlevel,Timer Midlevel
Optimize the code when compiled without CONFIG_PROC_FS.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/init.c')
-rw-r--r-- | sound/core/init.c | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/sound/core/init.c b/sound/core/init.c index 58e17d3..7581668 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -46,12 +46,39 @@ DEFINE_RWLOCK(snd_card_rwlock); int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); #endif +#ifdef CONFIG_PROC_FS static void snd_card_id_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { snd_iprintf(buffer, "%s\n", entry->card->id); } +static inline int init_info_for_card(struct snd_card *card) +{ + int err; + struct snd_info_entry *entry; + + if ((err = snd_info_card_register(card)) < 0) { + snd_printd("unable to create card info\n"); + return err; + } + if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { + snd_printd("unable to create card entry\n"); + return err; + } + entry->c.text.read_size = PAGE_SIZE; + entry->c.text.read = snd_card_id_read; + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + entry = NULL; + } + card->proc_id = entry; + return 0; +} +#else /* !CONFIG_PROC_FS */ +#define init_info_for_card(card) +#endif + static void snd_card_free_thread(void * __card); /** @@ -273,8 +300,7 @@ int snd_card_free(struct snd_card *card) } if (card->private_free) card->private_free(card); - if (card->proc_id) - snd_info_unregister(card->proc_id); + snd_info_unregister(card->proc_id); if (snd_info_card_free(card) < 0) { snd_printk(KERN_WARNING "unable to free card info\n"); /* Not fatal error */ @@ -414,7 +440,6 @@ static void choose_default_id(struct snd_card *card) int snd_card_register(struct snd_card *card) { int err; - struct snd_info_entry *entry; snd_assert(card != NULL, return -EINVAL); if ((err = snd_device_register_all(card)) < 0) @@ -429,22 +454,7 @@ int snd_card_register(struct snd_card *card) choose_default_id(card); snd_cards[card->number] = card; write_unlock(&snd_card_rwlock); - if ((err = snd_info_card_register(card)) < 0) { - snd_printd("unable to create card info\n"); - goto __skip_info; - } - if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { - snd_printd("unable to create card entry\n"); - goto __skip_info; - } - entry->c.text.read_size = PAGE_SIZE; - entry->c.text.read = snd_card_id_read; - if (snd_info_register(entry) < 0) { - snd_info_free_entry(entry); - entry = NULL; - } - card->proc_id = entry; - __skip_info: + init_info_for_card(card); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) if (snd_mixer_oss_notify_callback) snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); @@ -452,6 +462,7 @@ int snd_card_register(struct snd_card *card) return 0; } +#ifdef CONFIG_PROC_FS static struct snd_info_entry *snd_card_info_entry = NULL; static void snd_card_info_read(struct snd_info_entry *entry, @@ -478,7 +489,7 @@ static void snd_card_info_read(struct snd_info_entry *entry, snd_iprintf(buffer, "--- no soundcards ---\n"); } -#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) +#ifdef CONFIG_SND_OSSEMUL void snd_card_info_read_oss(struct snd_info_buffer *buffer) { @@ -550,15 +561,15 @@ int __init snd_card_info_init(void) int __exit snd_card_info_done(void) { - if (snd_card_info_entry) - snd_info_unregister(snd_card_info_entry); + snd_info_unregister(snd_card_info_entry); #ifdef MODULE - if (snd_card_module_info_entry) - snd_info_unregister(snd_card_module_info_entry); + snd_info_unregister(snd_card_module_info_entry); #endif return 0; } +#endif /* CONFIG_PROC_FS */ + /** * snd_component_add - add a component string * @card: soundcard structure |