aboutsummaryrefslogtreecommitdiff
path: root/sound/core/memory.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-10-10 11:59:52 +0200
committerJaroslav Kysela <perex@suse.cz>2005-11-04 13:18:08 +0100
commite38e0cfa48ac38f4fe24453d2523852467c95b21 (patch)
tree6b949db59b0c73cc3d3bc04f52d479bd605c658e /sound/core/memory.c
parentb1d5776d865951c213a1caaab5d8bf5de7615dbd (diff)
[ALSA] Remove kmalloc wrappers
Modules: ALSA Core Remove kmalloc wrappers. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/memory.c')
-rw-r--r--sound/core/memory.c163
1 files changed, 2 insertions, 161 deletions
diff --git a/sound/core/memory.c b/sound/core/memory.c
index b99343616f8..862d62d2e14 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) by Jaroslav Kysela <perex@suse.cz>
*
- * Memory allocation helpers.
+ * Misc memory accessors
*
*
* This program is free software; you can redistribute it and/or modify
@@ -20,168 +20,9 @@
*
*/
-#include <sound/driver.h>
+#include <linux/config.h>
#include <asm/io.h>
#include <asm/uaccess.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/pci.h>
-#include <sound/core.h>
-#include <sound/info.h>
-
-/*
- * memory allocation helpers and debug routines
- */
-
-#ifdef CONFIG_SND_DEBUG_MEMORY
-
-struct snd_alloc_track {
- unsigned long magic;
- void *caller;
- size_t size;
- struct list_head list;
- long data[0];
-};
-
-#define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data)
-
-static long snd_alloc_kmalloc;
-static LIST_HEAD(snd_alloc_kmalloc_list);
-static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock);
-#define KMALLOC_MAGIC 0x87654321
-static snd_info_entry_t *snd_memory_info_entry;
-
-void __init snd_memory_init(void)
-{
- snd_alloc_kmalloc = 0;
-}
-
-void snd_memory_done(void)
-{
- struct list_head *head;
- struct snd_alloc_track *t;
-
- if (snd_alloc_kmalloc > 0)
- snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
- list_for_each_prev(head, &snd_alloc_kmalloc_list) {
- t = list_entry(head, struct snd_alloc_track, list);
- if (t->magic != KMALLOC_MAGIC) {
- snd_printk(KERN_ERR "Corrupted kmalloc\n");
- break;
- }
- snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
- }
-}
-
-static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller)
-{
- unsigned long cpu_flags;
- struct snd_alloc_track *t;
- void *ptr;
-
- ptr = snd_wrapper_kmalloc(size + sizeof(struct snd_alloc_track), flags);
- if (ptr != NULL) {
- t = (struct snd_alloc_track *)ptr;
- t->magic = KMALLOC_MAGIC;
- t->caller = caller;
- spin_lock_irqsave(&snd_alloc_kmalloc_lock, cpu_flags);
- list_add_tail(&t->list, &snd_alloc_kmalloc_list);
- spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, cpu_flags);
- t->size = size;
- snd_alloc_kmalloc += size;
- ptr = t->data;
- }
- return ptr;
-}
-
-#define _snd_kmalloc(size, flags) __snd_kmalloc((size), (flags), __builtin_return_address(0));
-void *snd_hidden_kmalloc(size_t size, gfp_t flags)
-{
- return _snd_kmalloc(size, flags);
-}
-
-void *snd_hidden_kzalloc(size_t size, gfp_t flags)
-{
- void *ret = _snd_kmalloc(size, flags);
- if (ret)
- memset(ret, 0, size);
- return ret;
-}
-EXPORT_SYMBOL(snd_hidden_kzalloc);
-
-void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags)
-{
- void *ret = NULL;
- if (n != 0 && size > INT_MAX / n)
- return ret;
- return snd_hidden_kzalloc(n * size, flags);
-}
-
-void snd_hidden_kfree(const void *obj)
-{
- unsigned long flags;
- struct snd_alloc_track *t;
- if (obj == NULL)
- return;
- t = snd_alloc_track_entry(obj);
- if (t->magic != KMALLOC_MAGIC) {
- snd_printk(KERN_WARNING "bad kfree (called from %p)\n", __builtin_return_address(0));
- return;
- }
- spin_lock_irqsave(&snd_alloc_kmalloc_lock, flags);
- list_del(&t->list);
- spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, flags);
- t->magic = 0;
- snd_alloc_kmalloc -= t->size;
- obj = t;
- snd_wrapper_kfree(obj);
-}
-
-char *snd_hidden_kstrdup(const char *s, gfp_t flags)
-{
- int len;
- char *buf;
-
- if (!s) return NULL;
-
- len = strlen(s) + 1;
- buf = _snd_kmalloc(len, flags);
- if (buf)
- memcpy(buf, s, len);
- return buf;
-}
-
-static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
-{
- snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
-}
-
-int __init snd_memory_info_init(void)
-{
- snd_info_entry_t *entry;
-
- entry = snd_info_create_module_entry(THIS_MODULE, "meminfo", NULL);
- if (entry) {
- entry->c.text.read_size = 256;
- entry->c.text.read = snd_memory_info_read;
- if (snd_info_register(entry) < 0) {
- snd_info_free_entry(entry);
- entry = NULL;
- }
- }
- snd_memory_info_entry = entry;
- return 0;
-}
-
-int __exit snd_memory_info_done(void)
-{
- if (snd_memory_info_entry)
- snd_info_unregister(snd_memory_info_entry);
- return 0;
-}
-
-#endif /* CONFIG_SND_DEBUG_MEMORY */
/**
* copy_to_user_fromio - copy data from mmio-space to user-space