aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/init.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-12-01 04:42:42 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:30:02 -0500
commite28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4 (patch)
treeb69095abb998dedc2953368ba2c75978d80f644a /sound/core/init.c
parent7cd01dd840824e7c6023ad1dbfdb94a2183a7adb (diff)
[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.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index 58e17d385f8..75816688607 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -46,12 +46,39 @@ DEFINE_RWLOCK(snd_card_rwlock);
46int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); 46int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
47#endif 47#endif
48 48
49#ifdef CONFIG_PROC_FS
49static void snd_card_id_read(struct snd_info_entry *entry, 50static void snd_card_id_read(struct snd_info_entry *entry,
50 struct snd_info_buffer *buffer) 51 struct snd_info_buffer *buffer)
51{ 52{
52 snd_iprintf(buffer, "%s\n", entry->card->id); 53 snd_iprintf(buffer, "%s\n", entry->card->id);
53} 54}
54 55
56static inline int init_info_for_card(struct snd_card *card)
57{
58 int err;
59 struct snd_info_entry *entry;
60
61 if ((err = snd_info_card_register(card)) < 0) {
62 snd_printd("unable to create card info\n");
63 return err;
64 }
65 if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
66 snd_printd("unable to create card entry\n");
67 return err;
68 }
69 entry->c.text.read_size = PAGE_SIZE;
70 entry->c.text.read = snd_card_id_read;
71 if (snd_info_register(entry) < 0) {
72 snd_info_free_entry(entry);
73 entry = NULL;
74 }
75 card->proc_id = entry;
76 return 0;
77}
78#else /* !CONFIG_PROC_FS */
79#define init_info_for_card(card)
80#endif
81
55static void snd_card_free_thread(void * __card); 82static void snd_card_free_thread(void * __card);
56 83
57/** 84/**
@@ -273,8 +300,7 @@ int snd_card_free(struct snd_card *card)
273 } 300 }
274 if (card->private_free) 301 if (card->private_free)
275 card->private_free(card); 302 card->private_free(card);
276 if (card->proc_id) 303 snd_info_unregister(card->proc_id);
277 snd_info_unregister(card->proc_id);
278 if (snd_info_card_free(card) < 0) { 304 if (snd_info_card_free(card) < 0) {
279 snd_printk(KERN_WARNING "unable to free card info\n"); 305 snd_printk(KERN_WARNING "unable to free card info\n");
280 /* Not fatal error */ 306 /* Not fatal error */
@@ -414,7 +440,6 @@ static void choose_default_id(struct snd_card *card)
414int snd_card_register(struct snd_card *card) 440int snd_card_register(struct snd_card *card)
415{ 441{
416 int err; 442 int err;
417 struct snd_info_entry *entry;
418 443
419 snd_assert(card != NULL, return -EINVAL); 444 snd_assert(card != NULL, return -EINVAL);
420 if ((err = snd_device_register_all(card)) < 0) 445 if ((err = snd_device_register_all(card)) < 0)
@@ -429,22 +454,7 @@ int snd_card_register(struct snd_card *card)
429 choose_default_id(card); 454 choose_default_id(card);
430 snd_cards[card->number] = card; 455 snd_cards[card->number] = card;
431 write_unlock(&snd_card_rwlock); 456 write_unlock(&snd_card_rwlock);
432 if ((err = snd_info_card_register(card)) < 0) { 457 init_info_for_card(card);
433 snd_printd("unable to create card info\n");
434 goto __skip_info;
435 }
436 if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
437 snd_printd("unable to create card entry\n");
438 goto __skip_info;
439 }
440 entry->c.text.read_size = PAGE_SIZE;
441 entry->c.text.read = snd_card_id_read;
442 if (snd_info_register(entry) < 0) {
443 snd_info_free_entry(entry);
444 entry = NULL;
445 }
446 card->proc_id = entry;
447 __skip_info:
448#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 458#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
449 if (snd_mixer_oss_notify_callback) 459 if (snd_mixer_oss_notify_callback)
450 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); 460 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
@@ -452,6 +462,7 @@ int snd_card_register(struct snd_card *card)
452 return 0; 462 return 0;
453} 463}
454 464
465#ifdef CONFIG_PROC_FS
455static struct snd_info_entry *snd_card_info_entry = NULL; 466static struct snd_info_entry *snd_card_info_entry = NULL;
456 467
457static void snd_card_info_read(struct snd_info_entry *entry, 468static 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,
478 snd_iprintf(buffer, "--- no soundcards ---\n"); 489 snd_iprintf(buffer, "--- no soundcards ---\n");
479} 490}
480 491
481#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) 492#ifdef CONFIG_SND_OSSEMUL
482 493
483void snd_card_info_read_oss(struct snd_info_buffer *buffer) 494void snd_card_info_read_oss(struct snd_info_buffer *buffer)
484{ 495{
@@ -550,15 +561,15 @@ int __init snd_card_info_init(void)
550 561
551int __exit snd_card_info_done(void) 562int __exit snd_card_info_done(void)
552{ 563{
553 if (snd_card_info_entry) 564 snd_info_unregister(snd_card_info_entry);
554 snd_info_unregister(snd_card_info_entry);
555#ifdef MODULE 565#ifdef MODULE
556 if (snd_card_module_info_entry) 566 snd_info_unregister(snd_card_module_info_entry);
557 snd_info_unregister(snd_card_module_info_entry);
558#endif 567#endif
559 return 0; 568 return 0;
560} 569}
561 570
571#endif /* CONFIG_PROC_FS */
572
562/** 573/**
563 * snd_component_add - add a component string 574 * snd_component_add - add a component string
564 * @card: soundcard structure 575 * @card: soundcard structure