]> err.no Git - linux-2.6/commitdiff
[ALSA] Remove kmalloc wrappers
authorTakashi Iwai <tiwai@suse.de>
Mon, 10 Oct 2005 09:59:52 +0000 (11:59 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 4 Nov 2005 12:18:08 +0000 (13:18 +0100)
Modules: ALSA Core

Remove kmalloc wrappers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/core.h
include/sound/driver.h
sound/core/Kconfig
sound/core/Makefile
sound/core/info.c
sound/core/memory.c
sound/core/misc.c
sound/core/sound.c

index 0a14885fb1d7e0d0ef39ae84f6eb62a7fcaebb89..ed56a356ab7de36d45f36a1a7ef8dee5f2a6c343 100644 (file)
@@ -284,31 +284,6 @@ int snd_oss_init_module(void);
 
 /* memory.c */
 
-#ifdef CONFIG_SND_DEBUG_MEMORY
-void snd_memory_init(void);
-void snd_memory_done(void);
-int snd_memory_info_init(void);
-int snd_memory_info_done(void);
-void *snd_hidden_kmalloc(size_t size, gfp_t flags);
-void *snd_hidden_kzalloc(size_t size, gfp_t flags);
-void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags);
-void snd_hidden_kfree(const void *obj);
-char *snd_hidden_kstrdup(const char *s, gfp_t flags);
-#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
-#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags)
-#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
-#define kfree(obj) snd_hidden_kfree(obj)
-#define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags)
-#define kfree_nocheck(obj) snd_wrapper_kfree(obj)
-#define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
-#else
-#define snd_memory_init() /*NOP*/
-#define snd_memory_done() /*NOP*/
-#define snd_memory_info_init() /*NOP*/
-#define snd_memory_info_done() /*NOP*/
-#define kmalloc_nocheck(size, flags) kmalloc(size, flags)
-#define kfree_nocheck(obj) kfree(obj)
-#endif
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 
index 7973e0c05ae3e3e36344877d833ff11e40c7010b..3f0416ac24d95fe9d711165451028e7e85a38747 100644 (file)
 
 #include <linux/module.h>
 
-/*
- *  ==========================================================================
- */
-
-#ifdef CONFIG_SND_DEBUG_MEMORY
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-void *snd_wrapper_kmalloc(size_t, gfp_t);
-#undef kmalloc
-void snd_wrapper_kfree(const void *);
-#undef kfree
-#endif
-
 #endif /* __SOUND_DRIVER_H */
index 48cf45cfd0b7943f23f1890fa3c898dc1b5a98eb..82718836f93726a0d2ec464117b759dc4aa28442 100644 (file)
@@ -127,12 +127,6 @@ config SND_DEBUG
        help
          Say Y here to enable ALSA debug code.
 
-config SND_DEBUG_MEMORY
-       bool "Debug memory"
-       depends on SND_DEBUG
-       help
-         Say Y here to enable debugging of memory allocations.
-
 config SND_DEBUG_DETECT
        bool "Debug detection"
        depends on SND_DEBUG
index 969d75528bdeb9189f5ff9fdc8aaddac165bf1f5..5a01c76d02e8f0c90b7196c2588e2695a43e6bc8 100644 (file)
@@ -3,8 +3,7 @@
 # Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz>
 #
 
-snd-objs     := sound.o init.o memory.o info.o control.o misc.o \
-                device.o wrappers.o
+snd-objs     := sound.o init.o memory.o info.o control.o misc.o device.o
 ifeq ($(CONFIG_ISA_DMA_API),y)
 snd-objs     += isadma.o
 endif
index 37024d68a26ea25a5358aff96c5c34857fc549d2..39f9b97d92198582fbb34a6281d864b6443d90e8 100644 (file)
@@ -566,7 +566,6 @@ int __init snd_info_init(void)
        }
 #endif
        snd_info_version_init();
-       snd_memory_info_init();
        snd_minor_info_init();
        snd_minor_info_oss_init();
        snd_card_info_init();
@@ -578,7 +577,6 @@ int __exit snd_info_done(void)
        snd_card_info_done();
        snd_minor_info_oss_done();
        snd_minor_info_done();
-       snd_memory_info_done();
        snd_info_version_done();
        if (snd_proc_root) {
 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
index b99343616f81a3d26f113df1c87c5fac3da778fa..862d62d2e144f107a76d9c2b0af93e4c95e1096d 100644 (file)
@@ -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
  *
  */
 
-#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
index 3eddfdede9f3d3445df0fbb4821a382839c07051..b53e563c09e60d0e16f843bb034d0842df0cc432 100644 (file)
@@ -30,7 +30,7 @@ void release_and_free_resource(struct resource *res)
 {
        if (res) {
                release_resource(res);
-               kfree_nocheck(res);
+               kfree(res);
        }
 }
 
index e94eebd8ad6fafe702ee6f7881d3c4030e5134b1..dee602245fe8cd1a7b60fd0cd14a0be8b5f497b2 100644 (file)
@@ -350,9 +350,7 @@ static int __init alsa_sound_init(void)
                devfs_remove("snd");
                return -EIO;
        }
-       snd_memory_init();
        if (snd_info_init() < 0) {
-               snd_memory_done();
                unregister_chrdev(major, "alsa");
                devfs_remove("snd");
                return -ENOMEM;
@@ -381,7 +379,6 @@ static void __exit alsa_sound_exit(void)
 #endif
        snd_info_minor_unregister();
        snd_info_done();
-       snd_memory_done();
        if (unregister_chrdev(major, "alsa") != 0)
                snd_printk(KERN_ERR "unable to unregister major device number %d\n", major);
        devfs_remove("snd");
@@ -403,12 +400,6 @@ EXPORT_SYMBOL(snd_register_oss_device);
 EXPORT_SYMBOL(snd_unregister_oss_device);
 #endif
   /* memory.c */
-#ifdef CONFIG_SND_DEBUG_MEMORY
-EXPORT_SYMBOL(snd_hidden_kmalloc);
-EXPORT_SYMBOL(snd_hidden_kcalloc);
-EXPORT_SYMBOL(snd_hidden_kfree);
-EXPORT_SYMBOL(snd_hidden_kstrdup);
-#endif
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */
@@ -491,9 +482,4 @@ EXPORT_SYMBOL(snd_verbose_printk);
 #endif
 #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK)
 EXPORT_SYMBOL(snd_verbose_printd);
-#endif
-  /* wrappers */
-#ifdef CONFIG_SND_DEBUG_MEMORY
-EXPORT_SYMBOL(snd_wrapper_kmalloc);
-EXPORT_SYMBOL(snd_wrapper_kfree);
 #endif