diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-12-01 04:42:42 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:30:02 -0500 |
commit | e28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4 (patch) | |
tree | b69095abb998dedc2953368ba2c75978d80f644a /sound | |
parent | 7cd01dd840824e7c6023ad1dbfdb94a2183a7adb (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')
-rw-r--r-- | sound/core/hwdep.c | 33 | ||||
-rw-r--r-- | sound/core/info.c | 13 | ||||
-rw-r--r-- | sound/core/init.c | 59 | ||||
-rw-r--r-- | sound/core/pcm.c | 104 | ||||
-rw-r--r-- | sound/core/pcm_memory.c | 39 | ||||
-rw-r--r-- | sound/core/sound.c | 2 | ||||
-rw-r--r-- | sound/core/sound_oss.c | 6 | ||||
-rw-r--r-- | sound/core/timer.c | 48 |
8 files changed, 184 insertions, 120 deletions
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index b8c0c8c4d126..618c43be0bc3 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c | |||
@@ -458,6 +458,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) | |||
458 | return snd_hwdep_free(hwdep); | 458 | return snd_hwdep_free(hwdep); |
459 | } | 459 | } |
460 | 460 | ||
461 | #ifdef CONFIG_PROC_FS | ||
461 | /* | 462 | /* |
462 | * Info interface | 463 | * Info interface |
463 | */ | 464 | */ |
@@ -477,13 +478,9 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry, | |||
477 | up(®ister_mutex); | 478 | up(®ister_mutex); |
478 | } | 479 | } |
479 | 480 | ||
480 | /* | 481 | static struct snd_info_entry *snd_hwdep_proc_entry; |
481 | * ENTRY functions | ||
482 | */ | ||
483 | 482 | ||
484 | static struct snd_info_entry *snd_hwdep_proc_entry = NULL; | 483 | static void __init snd_hwdep_proc_init(void) |
485 | |||
486 | static int __init alsa_hwdep_init(void) | ||
487 | { | 484 | { |
488 | struct snd_info_entry *entry; | 485 | struct snd_info_entry *entry; |
489 | 486 | ||
@@ -496,6 +493,25 @@ static int __init alsa_hwdep_init(void) | |||
496 | } | 493 | } |
497 | } | 494 | } |
498 | snd_hwdep_proc_entry = entry; | 495 | snd_hwdep_proc_entry = entry; |
496 | } | ||
497 | |||
498 | static void __exit snd_hwdep_proc_done(void) | ||
499 | { | ||
500 | snd_info_unregister(snd_hwdep_proc_entry); | ||
501 | } | ||
502 | #else /* !CONFIG_PROC_FS */ | ||
503 | #define snd_hwdep_proc_init() | ||
504 | #define snd_hwdep_proc_done() | ||
505 | #endif /* CONFIG_PROC_FS */ | ||
506 | |||
507 | |||
508 | /* | ||
509 | * ENTRY functions | ||
510 | */ | ||
511 | |||
512 | static int __init alsa_hwdep_init(void) | ||
513 | { | ||
514 | snd_hwdep_proc_init(); | ||
499 | snd_ctl_register_ioctl(snd_hwdep_control_ioctl); | 515 | snd_ctl_register_ioctl(snd_hwdep_control_ioctl); |
500 | snd_ctl_register_ioctl_compat(snd_hwdep_control_ioctl); | 516 | snd_ctl_register_ioctl_compat(snd_hwdep_control_ioctl); |
501 | return 0; | 517 | return 0; |
@@ -505,10 +521,7 @@ static void __exit alsa_hwdep_exit(void) | |||
505 | { | 521 | { |
506 | snd_ctl_unregister_ioctl(snd_hwdep_control_ioctl); | 522 | snd_ctl_unregister_ioctl(snd_hwdep_control_ioctl); |
507 | snd_ctl_unregister_ioctl_compat(snd_hwdep_control_ioctl); | 523 | snd_ctl_unregister_ioctl_compat(snd_hwdep_control_ioctl); |
508 | if (snd_hwdep_proc_entry) { | 524 | snd_hwdep_proc_done(); |
509 | snd_info_unregister(snd_hwdep_proc_entry); | ||
510 | snd_hwdep_proc_entry = NULL; | ||
511 | } | ||
512 | } | 525 | } |
513 | 526 | ||
514 | module_init(alsa_hwdep_init) | 527 | module_init(alsa_hwdep_init) |
diff --git a/sound/core/info.c b/sound/core/info.c index ec3282f266f0..ae8853921464 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -37,6 +37,8 @@ | |||
37 | * | 37 | * |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #ifdef CONFIG_PROC_FS | ||
41 | |||
40 | int snd_info_check_reserved_words(const char *str) | 42 | int snd_info_check_reserved_words(const char *str) |
41 | { | 43 | { |
42 | static char *reserved[] = | 44 | static char *reserved[] = |
@@ -66,8 +68,6 @@ int snd_info_check_reserved_words(const char *str) | |||
66 | return 1; | 68 | return 1; |
67 | } | 69 | } |
68 | 70 | ||
69 | #ifdef CONFIG_PROC_FS | ||
70 | |||
71 | static DECLARE_MUTEX(info_mutex); | 71 | static DECLARE_MUTEX(info_mutex); |
72 | 72 | ||
73 | struct snd_info_private_data { | 73 | struct snd_info_private_data { |
@@ -580,12 +580,10 @@ int __exit snd_info_done(void) | |||
580 | snd_info_version_done(); | 580 | snd_info_version_done(); |
581 | if (snd_proc_root) { | 581 | if (snd_proc_root) { |
582 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) | 582 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) |
583 | if (snd_seq_root) | 583 | snd_info_unregister(snd_seq_root); |
584 | snd_info_unregister(snd_seq_root); | ||
585 | #endif | 584 | #endif |
586 | #ifdef CONFIG_SND_OSSEMUL | 585 | #ifdef CONFIG_SND_OSSEMUL |
587 | if (snd_oss_root) | 586 | snd_info_unregister(snd_oss_root); |
588 | snd_info_unregister(snd_oss_root); | ||
589 | #endif | 587 | #endif |
590 | snd_remove_proc_entry(&proc_root, snd_proc_root); | 588 | snd_remove_proc_entry(&proc_root, snd_proc_root); |
591 | } | 589 | } |
@@ -937,7 +935,8 @@ int snd_info_unregister(struct snd_info_entry * entry) | |||
937 | { | 935 | { |
938 | struct proc_dir_entry *root; | 936 | struct proc_dir_entry *root; |
939 | 937 | ||
940 | snd_assert(entry != NULL, return -ENXIO); | 938 | if (! entry) |
939 | return 0; | ||
941 | snd_assert(entry->p != NULL, return -ENXIO); | 940 | snd_assert(entry->p != NULL, return -ENXIO); |
942 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; | 941 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; |
943 | snd_assert(root, return -ENXIO); | 942 | snd_assert(root, return -ENXIO); |
diff --git a/sound/core/init.c b/sound/core/init.c index 58e17d385f8d..75816688607c 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -46,12 +46,39 @@ DEFINE_RWLOCK(snd_card_rwlock); | |||
46 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); | 46 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #ifdef CONFIG_PROC_FS | ||
49 | static void snd_card_id_read(struct snd_info_entry *entry, | 50 | static 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 | ||
56 | static 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 | |||
55 | static void snd_card_free_thread(void * __card); | 82 | static 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) | |||
414 | int snd_card_register(struct snd_card *card) | 440 | int 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 | ||
455 | static struct snd_info_entry *snd_card_info_entry = NULL; | 466 | static struct snd_info_entry *snd_card_info_entry = NULL; |
456 | 467 | ||
457 | static void snd_card_info_read(struct snd_info_entry *entry, | 468 | 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, | |||
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 | ||
483 | void snd_card_info_read_oss(struct snd_info_buffer *buffer) | 494 | void 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 | ||
551 | int __exit snd_card_info_done(void) | 562 | int __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 |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 95036c83de43..28ca61eb0b0d 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -151,30 +151,6 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
151 | #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v | 151 | #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v |
152 | #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v | 152 | #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v |
153 | 153 | ||
154 | static char *snd_pcm_stream_names[] = { | ||
155 | STREAM(PLAYBACK), | ||
156 | STREAM(CAPTURE), | ||
157 | }; | ||
158 | |||
159 | static char *snd_pcm_state_names[] = { | ||
160 | STATE(OPEN), | ||
161 | STATE(SETUP), | ||
162 | STATE(PREPARED), | ||
163 | STATE(RUNNING), | ||
164 | STATE(XRUN), | ||
165 | STATE(DRAINING), | ||
166 | STATE(PAUSED), | ||
167 | STATE(SUSPENDED), | ||
168 | }; | ||
169 | |||
170 | static char *snd_pcm_access_names[] = { | ||
171 | ACCESS(MMAP_INTERLEAVED), | ||
172 | ACCESS(MMAP_NONINTERLEAVED), | ||
173 | ACCESS(MMAP_COMPLEX), | ||
174 | ACCESS(RW_INTERLEAVED), | ||
175 | ACCESS(RW_NONINTERLEAVED), | ||
176 | }; | ||
177 | |||
178 | static char *snd_pcm_format_names[] = { | 154 | static char *snd_pcm_format_names[] = { |
179 | FORMAT(S8), | 155 | FORMAT(S8), |
180 | FORMAT(U8), | 156 | FORMAT(U8), |
@@ -216,6 +192,36 @@ static char *snd_pcm_format_names[] = { | |||
216 | FORMAT(U18_3BE), | 192 | FORMAT(U18_3BE), |
217 | }; | 193 | }; |
218 | 194 | ||
195 | const char *snd_pcm_format_name(snd_pcm_format_t format) | ||
196 | { | ||
197 | return snd_pcm_format_names[format]; | ||
198 | } | ||
199 | |||
200 | #ifdef CONFIG_PROC_FS | ||
201 | static char *snd_pcm_stream_names[] = { | ||
202 | STREAM(PLAYBACK), | ||
203 | STREAM(CAPTURE), | ||
204 | }; | ||
205 | |||
206 | static char *snd_pcm_state_names[] = { | ||
207 | STATE(OPEN), | ||
208 | STATE(SETUP), | ||
209 | STATE(PREPARED), | ||
210 | STATE(RUNNING), | ||
211 | STATE(XRUN), | ||
212 | STATE(DRAINING), | ||
213 | STATE(PAUSED), | ||
214 | STATE(SUSPENDED), | ||
215 | }; | ||
216 | |||
217 | static char *snd_pcm_access_names[] = { | ||
218 | ACCESS(MMAP_INTERLEAVED), | ||
219 | ACCESS(MMAP_NONINTERLEAVED), | ||
220 | ACCESS(MMAP_COMPLEX), | ||
221 | ACCESS(RW_INTERLEAVED), | ||
222 | ACCESS(RW_NONINTERLEAVED), | ||
223 | }; | ||
224 | |||
219 | static char *snd_pcm_subformat_names[] = { | 225 | static char *snd_pcm_subformat_names[] = { |
220 | SUBFORMAT(STD), | 226 | SUBFORMAT(STD), |
221 | }; | 227 | }; |
@@ -236,11 +242,6 @@ static const char *snd_pcm_access_name(snd_pcm_access_t access) | |||
236 | return snd_pcm_access_names[access]; | 242 | return snd_pcm_access_names[access]; |
237 | } | 243 | } |
238 | 244 | ||
239 | const char *snd_pcm_format_name(snd_pcm_format_t format) | ||
240 | { | ||
241 | return snd_pcm_format_names[format]; | ||
242 | } | ||
243 | |||
244 | static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) | 245 | static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) |
245 | { | 246 | { |
246 | return snd_pcm_subformat_names[subformat]; | 247 | return snd_pcm_subformat_names[subformat]; |
@@ -288,7 +289,6 @@ static const char *snd_pcm_oss_format_name(int format) | |||
288 | } | 289 | } |
289 | #endif | 290 | #endif |
290 | 291 | ||
291 | #ifdef CONFIG_PROC_FS | ||
292 | static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, | 292 | static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, |
293 | struct snd_info_buffer *buffer) | 293 | struct snd_info_buffer *buffer) |
294 | { | 294 | { |
@@ -431,7 +431,6 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, | |||
431 | snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr); | 431 | snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr); |
432 | snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr); | 432 | snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr); |
433 | } | 433 | } |
434 | #endif | ||
435 | 434 | ||
436 | #ifdef CONFIG_SND_DEBUG | 435 | #ifdef CONFIG_SND_DEBUG |
437 | static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry, | 436 | static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry, |
@@ -596,6 +595,12 @@ static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) | |||
596 | } | 595 | } |
597 | return 0; | 596 | return 0; |
598 | } | 597 | } |
598 | #else /* !CONFIG_PROC_FS */ | ||
599 | static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; } | ||
600 | static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; } | ||
601 | static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; } | ||
602 | static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; } | ||
603 | #endif /* CONFIG_PROC_FS */ | ||
599 | 604 | ||
600 | /** | 605 | /** |
601 | * snd_pcm_new_stream - create a new PCM stream | 606 | * snd_pcm_new_stream - create a new PCM stream |
@@ -1013,6 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) | |||
1013 | return 0; | 1018 | return 0; |
1014 | } | 1019 | } |
1015 | 1020 | ||
1021 | #ifdef CONFIG_PROC_FS | ||
1016 | /* | 1022 | /* |
1017 | * Info interface | 1023 | * Info interface |
1018 | */ | 1024 | */ |
@@ -1039,18 +1045,12 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry, | |||
1039 | up(®ister_mutex); | 1045 | up(®ister_mutex); |
1040 | } | 1046 | } |
1041 | 1047 | ||
1042 | /* | ||
1043 | * ENTRY functions | ||
1044 | */ | ||
1045 | |||
1046 | static struct snd_info_entry *snd_pcm_proc_entry = NULL; | 1048 | static struct snd_info_entry *snd_pcm_proc_entry = NULL; |
1047 | 1049 | ||
1048 | static int __init alsa_pcm_init(void) | 1050 | static void snd_pcm_proc_init(void) |
1049 | { | 1051 | { |
1050 | struct snd_info_entry *entry; | 1052 | struct snd_info_entry *entry; |
1051 | 1053 | ||
1052 | snd_ctl_register_ioctl(snd_pcm_control_ioctl); | ||
1053 | snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl); | ||
1054 | if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { | 1054 | if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { |
1055 | snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, | 1055 | snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, |
1056 | snd_pcm_proc_read); | 1056 | snd_pcm_proc_read); |
@@ -1060,6 +1060,29 @@ static int __init alsa_pcm_init(void) | |||
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | snd_pcm_proc_entry = entry; | 1062 | snd_pcm_proc_entry = entry; |
1063 | } | ||
1064 | |||
1065 | static void snd_pcm_proc_done(void) | ||
1066 | { | ||
1067 | if (snd_pcm_proc_entry) | ||
1068 | snd_info_unregister(snd_pcm_proc_entry); | ||
1069 | } | ||
1070 | |||
1071 | #else /* !CONFIG_PROC_FS */ | ||
1072 | #define snd_pcm_proc_init() | ||
1073 | #define snd_pcm_proc_done() | ||
1074 | #endif /* CONFIG_PROC_FS */ | ||
1075 | |||
1076 | |||
1077 | /* | ||
1078 | * ENTRY functions | ||
1079 | */ | ||
1080 | |||
1081 | static int __init alsa_pcm_init(void) | ||
1082 | { | ||
1083 | snd_ctl_register_ioctl(snd_pcm_control_ioctl); | ||
1084 | snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl); | ||
1085 | snd_pcm_proc_init(); | ||
1063 | return 0; | 1086 | return 0; |
1064 | } | 1087 | } |
1065 | 1088 | ||
@@ -1067,10 +1090,7 @@ static void __exit alsa_pcm_exit(void) | |||
1067 | { | 1090 | { |
1068 | snd_ctl_unregister_ioctl(snd_pcm_control_ioctl); | 1091 | snd_ctl_unregister_ioctl(snd_pcm_control_ioctl); |
1069 | snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl); | 1092 | snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl); |
1070 | if (snd_pcm_proc_entry) { | 1093 | snd_pcm_proc_done(); |
1071 | snd_info_unregister(snd_pcm_proc_entry); | ||
1072 | snd_pcm_proc_entry = NULL; | ||
1073 | } | ||
1074 | } | 1094 | } |
1075 | 1095 | ||
1076 | module_init(alsa_pcm_init) | 1096 | module_init(alsa_pcm_init) |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index d37bcb761884..a0119ae67dcd 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -100,10 +100,8 @@ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream | |||
100 | int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) | 100 | int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) |
101 | { | 101 | { |
102 | snd_pcm_lib_preallocate_dma_free(substream); | 102 | snd_pcm_lib_preallocate_dma_free(substream); |
103 | if (substream->proc_prealloc_entry) { | 103 | snd_info_unregister(substream->proc_prealloc_entry); |
104 | snd_info_unregister(substream->proc_prealloc_entry); | 104 | substream->proc_prealloc_entry = NULL; |
105 | substream->proc_prealloc_entry = NULL; | ||
106 | } | ||
107 | return 0; | 105 | return 0; |
108 | } | 106 | } |
109 | 107 | ||
@@ -126,6 +124,7 @@ int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm) | |||
126 | return 0; | 124 | return 0; |
127 | } | 125 | } |
128 | 126 | ||
127 | #ifdef CONFIG_PROC_FS | ||
129 | /* | 128 | /* |
130 | * read callback for prealloc proc file | 129 | * read callback for prealloc proc file |
131 | * | 130 | * |
@@ -185,20 +184,10 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, | |||
185 | } | 184 | } |
186 | } | 185 | } |
187 | 186 | ||
188 | /* | 187 | static inline void preallocate_info_init(struct snd_pcm_substream *substream) |
189 | * pre-allocate the buffer and create a proc file for the substream | ||
190 | */ | ||
191 | static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, | ||
192 | size_t size, size_t max) | ||
193 | { | 188 | { |
194 | struct snd_info_entry *entry; | 189 | struct snd_info_entry *entry; |
195 | 190 | ||
196 | if (size > 0 && preallocate_dma && substream->number < maximum_substreams) | ||
197 | preallocate_pcm_pages(substream, size); | ||
198 | |||
199 | if (substream->dma_buffer.bytes > 0) | ||
200 | substream->buffer_bytes_max = substream->dma_buffer.bytes; | ||
201 | substream->dma_max = max; | ||
202 | if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) { | 191 | if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) { |
203 | entry->c.text.read_size = 64; | 192 | entry->c.text.read_size = 64; |
204 | entry->c.text.read = snd_pcm_lib_preallocate_proc_read; | 193 | entry->c.text.read = snd_pcm_lib_preallocate_proc_read; |
@@ -212,6 +201,26 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, | |||
212 | } | 201 | } |
213 | } | 202 | } |
214 | substream->proc_prealloc_entry = entry; | 203 | substream->proc_prealloc_entry = entry; |
204 | } | ||
205 | |||
206 | #else /* !CONFIG_PROC_FS */ | ||
207 | #define preallocate_info_init(s) | ||
208 | #endif | ||
209 | |||
210 | /* | ||
211 | * pre-allocate the buffer and create a proc file for the substream | ||
212 | */ | ||
213 | static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, | ||
214 | size_t size, size_t max) | ||
215 | { | ||
216 | |||
217 | if (size > 0 && preallocate_dma && substream->number < maximum_substreams) | ||
218 | preallocate_pcm_pages(substream, size); | ||
219 | |||
220 | if (substream->dma_buffer.bytes > 0) | ||
221 | substream->buffer_bytes_max = substream->dma_buffer.bytes; | ||
222 | substream->dma_max = max; | ||
223 | preallocate_info_init(substream); | ||
215 | return 0; | 224 | return 0; |
216 | } | 225 | } |
217 | 226 | ||
diff --git a/sound/core/sound.c b/sound/core/sound.c index 3b91f180f687..a8eda02bcf1c 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -320,6 +320,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) | |||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | #ifdef CONFIG_PROC_FS | ||
323 | /* | 324 | /* |
324 | * INFO PART | 325 | * INFO PART |
325 | */ | 326 | */ |
@@ -396,6 +397,7 @@ int __exit snd_minor_info_done(void) | |||
396 | snd_info_unregister(snd_minor_info_entry); | 397 | snd_info_unregister(snd_minor_info_entry); |
397 | return 0; | 398 | return 0; |
398 | } | 399 | } |
400 | #endif /* CONFIG_PROC_FS */ | ||
399 | 401 | ||
400 | /* | 402 | /* |
401 | * INIT PART | 403 | * INIT PART |
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 3ae1c0d7ffd0..d0be32b517c1 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c | |||
@@ -244,11 +244,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, | |||
244 | up(&sound_oss_mutex); | 244 | up(&sound_oss_mutex); |
245 | } | 245 | } |
246 | 246 | ||
247 | #endif /* CONFIG_PROC_FS */ | ||
248 | 247 | ||
249 | int __init snd_minor_info_oss_init(void) | 248 | int __init snd_minor_info_oss_init(void) |
250 | { | 249 | { |
251 | #ifdef CONFIG_PROC_FS | ||
252 | struct snd_info_entry *entry; | 250 | struct snd_info_entry *entry; |
253 | 251 | ||
254 | entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root); | 252 | entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root); |
@@ -261,17 +259,15 @@ int __init snd_minor_info_oss_init(void) | |||
261 | } | 259 | } |
262 | } | 260 | } |
263 | snd_minor_info_oss_entry = entry; | 261 | snd_minor_info_oss_entry = entry; |
264 | #endif | ||
265 | return 0; | 262 | return 0; |
266 | } | 263 | } |
267 | 264 | ||
268 | int __exit snd_minor_info_oss_done(void) | 265 | int __exit snd_minor_info_oss_done(void) |
269 | { | 266 | { |
270 | #ifdef CONFIG_PROC_FS | ||
271 | if (snd_minor_info_oss_entry) | 267 | if (snd_minor_info_oss_entry) |
272 | snd_info_unregister(snd_minor_info_oss_entry); | 268 | snd_info_unregister(snd_minor_info_oss_entry); |
273 | #endif | ||
274 | return 0; | 269 | return 0; |
275 | } | 270 | } |
271 | #endif /* CONFIG_PROC_FS */ | ||
276 | 272 | ||
277 | #endif /* CONFIG_SND_OSSEMUL */ | 273 | #endif /* CONFIG_SND_OSSEMUL */ |
diff --git a/sound/core/timer.c b/sound/core/timer.c index c62dbacdca13..2425b971b240 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -1052,6 +1052,7 @@ static int snd_timer_register_system(void) | |||
1052 | return snd_timer_global_register(timer); | 1052 | return snd_timer_global_register(timer); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | #ifdef CONFIG_PROC_FS | ||
1055 | /* | 1056 | /* |
1056 | * Info interface | 1057 | * Info interface |
1057 | */ | 1058 | */ |
@@ -1107,6 +1108,33 @@ static void snd_timer_proc_read(struct snd_info_entry *entry, | |||
1107 | up(®ister_mutex); | 1108 | up(®ister_mutex); |
1108 | } | 1109 | } |
1109 | 1110 | ||
1111 | static struct snd_info_entry *snd_timer_proc_entry = NULL; | ||
1112 | |||
1113 | static void __init snd_timer_proc_init(void) | ||
1114 | { | ||
1115 | struct snd_info_entry *entry; | ||
1116 | |||
1117 | entry = snd_info_create_module_entry(THIS_MODULE, "timers", NULL); | ||
1118 | if (entry != NULL) { | ||
1119 | entry->c.text.read_size = SNDRV_TIMER_DEVICES * 128; | ||
1120 | entry->c.text.read = snd_timer_proc_read; | ||
1121 | if (snd_info_register(entry) < 0) { | ||
1122 | snd_info_free_entry(entry); | ||
1123 | entry = NULL; | ||
1124 | } | ||
1125 | } | ||
1126 | snd_timer_proc_entry = entry; | ||
1127 | } | ||
1128 | |||
1129 | static void __exit snd_timer_proc_done(void) | ||
1130 | { | ||
1131 | snd_info_unregister(snd_timer_proc_entry); | ||
1132 | } | ||
1133 | #else /* !CONFIG_PROC_FS */ | ||
1134 | #define snd_timer_proc_init() | ||
1135 | #define snd_timer_proc_done() | ||
1136 | #endif | ||
1137 | |||
1110 | /* | 1138 | /* |
1111 | * USER SPACE interface | 1139 | * USER SPACE interface |
1112 | */ | 1140 | */ |
@@ -1928,27 +1956,15 @@ static struct file_operations snd_timer_f_ops = | |||
1928 | * ENTRY functions | 1956 | * ENTRY functions |
1929 | */ | 1957 | */ |
1930 | 1958 | ||
1931 | static struct snd_info_entry *snd_timer_proc_entry = NULL; | ||
1932 | |||
1933 | static int __init alsa_timer_init(void) | 1959 | static int __init alsa_timer_init(void) |
1934 | { | 1960 | { |
1935 | int err; | 1961 | int err; |
1936 | struct snd_info_entry *entry; | ||
1937 | 1962 | ||
1938 | #ifdef SNDRV_OSS_INFO_DEV_TIMERS | 1963 | #ifdef SNDRV_OSS_INFO_DEV_TIMERS |
1939 | snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, | 1964 | snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, |
1940 | "system timer"); | 1965 | "system timer"); |
1941 | #endif | 1966 | #endif |
1942 | entry = snd_info_create_module_entry(THIS_MODULE, "timers", NULL); | 1967 | |
1943 | if (entry != NULL) { | ||
1944 | entry->c.text.read_size = SNDRV_TIMER_DEVICES * 128; | ||
1945 | entry->c.text.read = snd_timer_proc_read; | ||
1946 | if (snd_info_register(entry) < 0) { | ||
1947 | snd_info_free_entry(entry); | ||
1948 | entry = NULL; | ||
1949 | } | ||
1950 | } | ||
1951 | snd_timer_proc_entry = entry; | ||
1952 | if ((err = snd_timer_register_system()) < 0) | 1968 | if ((err = snd_timer_register_system()) < 0) |
1953 | snd_printk(KERN_ERR "unable to register system timer (%i)\n", | 1969 | snd_printk(KERN_ERR "unable to register system timer (%i)\n", |
1954 | err); | 1970 | err); |
@@ -1956,6 +1972,7 @@ static int __init alsa_timer_init(void) | |||
1956 | &snd_timer_f_ops, NULL, "timer")) < 0) | 1972 | &snd_timer_f_ops, NULL, "timer")) < 0) |
1957 | snd_printk(KERN_ERR "unable to register timer device (%i)\n", | 1973 | snd_printk(KERN_ERR "unable to register timer device (%i)\n", |
1958 | err); | 1974 | err); |
1975 | snd_timer_proc_init(); | ||
1959 | return 0; | 1976 | return 0; |
1960 | } | 1977 | } |
1961 | 1978 | ||
@@ -1969,10 +1986,7 @@ static void __exit alsa_timer_exit(void) | |||
1969 | struct snd_timer *timer = list_entry(p, struct snd_timer, device_list); | 1986 | struct snd_timer *timer = list_entry(p, struct snd_timer, device_list); |
1970 | snd_timer_unregister(timer); | 1987 | snd_timer_unregister(timer); |
1971 | } | 1988 | } |
1972 | if (snd_timer_proc_entry) { | 1989 | snd_timer_proc_done(); |
1973 | snd_info_unregister(snd_timer_proc_entry); | ||
1974 | snd_timer_proc_entry = NULL; | ||
1975 | } | ||
1976 | #ifdef SNDRV_OSS_INFO_DEV_TIMERS | 1990 | #ifdef SNDRV_OSS_INFO_DEV_TIMERS |
1977 | snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); | 1991 | snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); |
1978 | #endif | 1992 | #endif |