diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-10-10 05:59:52 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-11-04 07:18:08 -0500 |
commit | e38e0cfa48ac38f4fe24453d2523852467c95b21 (patch) | |
tree | 6b949db59b0c73cc3d3bc04f52d479bd605c658e /sound | |
parent | b1d5776d865951c213a1caaab5d8bf5de7615dbd (diff) |
[ALSA] Remove kmalloc wrappers
Modules: ALSA Core
Remove kmalloc wrappers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/Kconfig | 6 | ||||
-rw-r--r-- | sound/core/Makefile | 3 | ||||
-rw-r--r-- | sound/core/info.c | 2 | ||||
-rw-r--r-- | sound/core/memory.c | 163 | ||||
-rw-r--r-- | sound/core/misc.c | 2 | ||||
-rw-r--r-- | sound/core/sound.c | 14 |
6 files changed, 4 insertions, 186 deletions
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 48cf45cfd0b7..82718836f937 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig | |||
@@ -127,12 +127,6 @@ config SND_DEBUG | |||
127 | help | 127 | help |
128 | Say Y here to enable ALSA debug code. | 128 | Say Y here to enable ALSA debug code. |
129 | 129 | ||
130 | config SND_DEBUG_MEMORY | ||
131 | bool "Debug memory" | ||
132 | depends on SND_DEBUG | ||
133 | help | ||
134 | Say Y here to enable debugging of memory allocations. | ||
135 | |||
136 | config SND_DEBUG_DETECT | 130 | config SND_DEBUG_DETECT |
137 | bool "Debug detection" | 131 | bool "Debug detection" |
138 | depends on SND_DEBUG | 132 | depends on SND_DEBUG |
diff --git a/sound/core/Makefile b/sound/core/Makefile index 969d75528bde..5a01c76d02e8 100644 --- a/sound/core/Makefile +++ b/sound/core/Makefile | |||
@@ -3,8 +3,7 @@ | |||
3 | # Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz> | 3 | # Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz> |
4 | # | 4 | # |
5 | 5 | ||
6 | snd-objs := sound.o init.o memory.o info.o control.o misc.o \ | 6 | snd-objs := sound.o init.o memory.o info.o control.o misc.o device.o |
7 | device.o wrappers.o | ||
8 | ifeq ($(CONFIG_ISA_DMA_API),y) | 7 | ifeq ($(CONFIG_ISA_DMA_API),y) |
9 | snd-objs += isadma.o | 8 | snd-objs += isadma.o |
10 | endif | 9 | endif |
diff --git a/sound/core/info.c b/sound/core/info.c index 37024d68a26e..39f9b97d9219 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -566,7 +566,6 @@ int __init snd_info_init(void) | |||
566 | } | 566 | } |
567 | #endif | 567 | #endif |
568 | snd_info_version_init(); | 568 | snd_info_version_init(); |
569 | snd_memory_info_init(); | ||
570 | snd_minor_info_init(); | 569 | snd_minor_info_init(); |
571 | snd_minor_info_oss_init(); | 570 | snd_minor_info_oss_init(); |
572 | snd_card_info_init(); | 571 | snd_card_info_init(); |
@@ -578,7 +577,6 @@ int __exit snd_info_done(void) | |||
578 | snd_card_info_done(); | 577 | snd_card_info_done(); |
579 | snd_minor_info_oss_done(); | 578 | snd_minor_info_oss_done(); |
580 | snd_minor_info_done(); | 579 | snd_minor_info_done(); |
581 | snd_memory_info_done(); | ||
582 | snd_info_version_done(); | 580 | snd_info_version_done(); |
583 | if (snd_proc_root) { | 581 | if (snd_proc_root) { |
584 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) | 582 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) |
diff --git a/sound/core/memory.c b/sound/core/memory.c index b99343616f81..862d62d2e144 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> | 2 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> |
3 | * | 3 | * |
4 | * Memory allocation helpers. | 4 | * Misc memory accessors |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -20,168 +20,9 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <sound/driver.h> | 23 | #include <linux/config.h> |
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/time.h> | ||
29 | #include <linux/pci.h> | ||
30 | #include <sound/core.h> | ||
31 | #include <sound/info.h> | ||
32 | |||
33 | /* | ||
34 | * memory allocation helpers and debug routines | ||
35 | */ | ||
36 | |||
37 | #ifdef CONFIG_SND_DEBUG_MEMORY | ||
38 | |||
39 | struct snd_alloc_track { | ||
40 | unsigned long magic; | ||
41 | void *caller; | ||
42 | size_t size; | ||
43 | struct list_head list; | ||
44 | long data[0]; | ||
45 | }; | ||
46 | |||
47 | #define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data) | ||
48 | |||
49 | static long snd_alloc_kmalloc; | ||
50 | static LIST_HEAD(snd_alloc_kmalloc_list); | ||
51 | static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock); | ||
52 | #define KMALLOC_MAGIC 0x87654321 | ||
53 | static snd_info_entry_t *snd_memory_info_entry; | ||
54 | |||
55 | void __init snd_memory_init(void) | ||
56 | { | ||
57 | snd_alloc_kmalloc = 0; | ||
58 | } | ||
59 | |||
60 | void snd_memory_done(void) | ||
61 | { | ||
62 | struct list_head *head; | ||
63 | struct snd_alloc_track *t; | ||
64 | |||
65 | if (snd_alloc_kmalloc > 0) | ||
66 | snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc); | ||
67 | list_for_each_prev(head, &snd_alloc_kmalloc_list) { | ||
68 | t = list_entry(head, struct snd_alloc_track, list); | ||
69 | if (t->magic != KMALLOC_MAGIC) { | ||
70 | snd_printk(KERN_ERR "Corrupted kmalloc\n"); | ||
71 | break; | ||
72 | } | ||
73 | snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller) | ||
78 | { | ||
79 | unsigned long cpu_flags; | ||
80 | struct snd_alloc_track *t; | ||
81 | void *ptr; | ||
82 | |||
83 | ptr = snd_wrapper_kmalloc(size + sizeof(struct snd_alloc_track), flags); | ||
84 | if (ptr != NULL) { | ||
85 | t = (struct snd_alloc_track *)ptr; | ||
86 | t->magic = KMALLOC_MAGIC; | ||
87 | t->caller = caller; | ||
88 | spin_lock_irqsave(&snd_alloc_kmalloc_lock, cpu_flags); | ||
89 | list_add_tail(&t->list, &snd_alloc_kmalloc_list); | ||
90 | spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, cpu_flags); | ||
91 | t->size = size; | ||
92 | snd_alloc_kmalloc += size; | ||
93 | ptr = t->data; | ||
94 | } | ||
95 | return ptr; | ||
96 | } | ||
97 | |||
98 | #define _snd_kmalloc(size, flags) __snd_kmalloc((size), (flags), __builtin_return_address(0)); | ||
99 | void *snd_hidden_kmalloc(size_t size, gfp_t flags) | ||
100 | { | ||
101 | return _snd_kmalloc(size, flags); | ||
102 | } | ||
103 | |||
104 | void *snd_hidden_kzalloc(size_t size, gfp_t flags) | ||
105 | { | ||
106 | void *ret = _snd_kmalloc(size, flags); | ||
107 | if (ret) | ||
108 | memset(ret, 0, size); | ||
109 | return ret; | ||
110 | } | ||
111 | EXPORT_SYMBOL(snd_hidden_kzalloc); | ||
112 | |||
113 | void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags) | ||
114 | { | ||
115 | void *ret = NULL; | ||
116 | if (n != 0 && size > INT_MAX / n) | ||
117 | return ret; | ||
118 | return snd_hidden_kzalloc(n * size, flags); | ||
119 | } | ||
120 | |||
121 | void snd_hidden_kfree(const void *obj) | ||
122 | { | ||
123 | unsigned long flags; | ||
124 | struct snd_alloc_track *t; | ||
125 | if (obj == NULL) | ||
126 | return; | ||
127 | t = snd_alloc_track_entry(obj); | ||
128 | if (t->magic != KMALLOC_MAGIC) { | ||
129 | snd_printk(KERN_WARNING "bad kfree (called from %p)\n", __builtin_return_address(0)); | ||
130 | return; | ||
131 | } | ||
132 | spin_lock_irqsave(&snd_alloc_kmalloc_lock, flags); | ||
133 | list_del(&t->list); | ||
134 | spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, flags); | ||
135 | t->magic = 0; | ||
136 | snd_alloc_kmalloc -= t->size; | ||
137 | obj = t; | ||
138 | snd_wrapper_kfree(obj); | ||
139 | } | ||
140 | |||
141 | char *snd_hidden_kstrdup(const char *s, gfp_t flags) | ||
142 | { | ||
143 | int len; | ||
144 | char *buf; | ||
145 | |||
146 | if (!s) return NULL; | ||
147 | |||
148 | len = strlen(s) + 1; | ||
149 | buf = _snd_kmalloc(len, flags); | ||
150 | if (buf) | ||
151 | memcpy(buf, s, len); | ||
152 | return buf; | ||
153 | } | ||
154 | |||
155 | static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) | ||
156 | { | ||
157 | snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); | ||
158 | } | ||
159 | |||
160 | int __init snd_memory_info_init(void) | ||
161 | { | ||
162 | snd_info_entry_t *entry; | ||
163 | |||
164 | entry = snd_info_create_module_entry(THIS_MODULE, "meminfo", NULL); | ||
165 | if (entry) { | ||
166 | entry->c.text.read_size = 256; | ||
167 | entry->c.text.read = snd_memory_info_read; | ||
168 | if (snd_info_register(entry) < 0) { | ||
169 | snd_info_free_entry(entry); | ||
170 | entry = NULL; | ||
171 | } | ||
172 | } | ||
173 | snd_memory_info_entry = entry; | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | int __exit snd_memory_info_done(void) | ||
178 | { | ||
179 | if (snd_memory_info_entry) | ||
180 | snd_info_unregister(snd_memory_info_entry); | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | #endif /* CONFIG_SND_DEBUG_MEMORY */ | ||
185 | 26 | ||
186 | /** | 27 | /** |
187 | * copy_to_user_fromio - copy data from mmio-space to user-space | 28 | * copy_to_user_fromio - copy data from mmio-space to user-space |
diff --git a/sound/core/misc.c b/sound/core/misc.c index 3eddfdede9f3..b53e563c09e6 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -30,7 +30,7 @@ void release_and_free_resource(struct resource *res) | |||
30 | { | 30 | { |
31 | if (res) { | 31 | if (res) { |
32 | release_resource(res); | 32 | release_resource(res); |
33 | kfree_nocheck(res); | 33 | kfree(res); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
diff --git a/sound/core/sound.c b/sound/core/sound.c index e94eebd8ad6f..dee602245fe8 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -350,9 +350,7 @@ static int __init alsa_sound_init(void) | |||
350 | devfs_remove("snd"); | 350 | devfs_remove("snd"); |
351 | return -EIO; | 351 | return -EIO; |
352 | } | 352 | } |
353 | snd_memory_init(); | ||
354 | if (snd_info_init() < 0) { | 353 | if (snd_info_init() < 0) { |
355 | snd_memory_done(); | ||
356 | unregister_chrdev(major, "alsa"); | 354 | unregister_chrdev(major, "alsa"); |
357 | devfs_remove("snd"); | 355 | devfs_remove("snd"); |
358 | return -ENOMEM; | 356 | return -ENOMEM; |
@@ -381,7 +379,6 @@ static void __exit alsa_sound_exit(void) | |||
381 | #endif | 379 | #endif |
382 | snd_info_minor_unregister(); | 380 | snd_info_minor_unregister(); |
383 | snd_info_done(); | 381 | snd_info_done(); |
384 | snd_memory_done(); | ||
385 | if (unregister_chrdev(major, "alsa") != 0) | 382 | if (unregister_chrdev(major, "alsa") != 0) |
386 | snd_printk(KERN_ERR "unable to unregister major device number %d\n", major); | 383 | snd_printk(KERN_ERR "unable to unregister major device number %d\n", major); |
387 | devfs_remove("snd"); | 384 | devfs_remove("snd"); |
@@ -403,12 +400,6 @@ EXPORT_SYMBOL(snd_register_oss_device); | |||
403 | EXPORT_SYMBOL(snd_unregister_oss_device); | 400 | EXPORT_SYMBOL(snd_unregister_oss_device); |
404 | #endif | 401 | #endif |
405 | /* memory.c */ | 402 | /* memory.c */ |
406 | #ifdef CONFIG_SND_DEBUG_MEMORY | ||
407 | EXPORT_SYMBOL(snd_hidden_kmalloc); | ||
408 | EXPORT_SYMBOL(snd_hidden_kcalloc); | ||
409 | EXPORT_SYMBOL(snd_hidden_kfree); | ||
410 | EXPORT_SYMBOL(snd_hidden_kstrdup); | ||
411 | #endif | ||
412 | EXPORT_SYMBOL(copy_to_user_fromio); | 403 | EXPORT_SYMBOL(copy_to_user_fromio); |
413 | EXPORT_SYMBOL(copy_from_user_toio); | 404 | EXPORT_SYMBOL(copy_from_user_toio); |
414 | /* init.c */ | 405 | /* init.c */ |
@@ -492,8 +483,3 @@ EXPORT_SYMBOL(snd_verbose_printk); | |||
492 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | 483 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) |
493 | EXPORT_SYMBOL(snd_verbose_printd); | 484 | EXPORT_SYMBOL(snd_verbose_printd); |
494 | #endif | 485 | #endif |
495 | /* wrappers */ | ||
496 | #ifdef CONFIG_SND_DEBUG_MEMORY | ||
497 | EXPORT_SYMBOL(snd_wrapper_kmalloc); | ||
498 | EXPORT_SYMBOL(snd_wrapper_kfree); | ||
499 | #endif | ||