]> err.no Git - linux-2.6/commitdiff
[ALSA] Remove vmalloc wrapper, kfree_nocheck()
authorTakashi Iwai <tiwai@suse.de>
Mon, 10 Oct 2005 09:56:31 +0000 (11:56 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 4 Nov 2005 12:18:00 +0000 (13:18 +0100)
- Remove vmalloc wrapper
- Add release_and_free_resource() to remove kfree_nocheck() from each driver
  and simplify the code

Signed-off-by: Takashi Iwai <tiwai@suse.de>
44 files changed:
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
include/sound/core.h
include/sound/driver.h
sound/core/memory.c
sound/core/misc.c
sound/core/sound.c
sound/core/wrappers.c
sound/drivers/mpu401/mpu401_uart.c
sound/drivers/mtpav.c
sound/drivers/opl3/opl3_lib.c
sound/drivers/opl4/opl4_lib.c
sound/drivers/serial-u16550.c
sound/drivers/vx/vx_pcm.c
sound/isa/ad1816a/ad1816a_lib.c
sound/isa/ad1848/ad1848_lib.c
sound/isa/cs423x/cs4231_lib.c
sound/isa/cs423x/cs4236.c
sound/isa/es1688/es1688_lib.c
sound/isa/es18xx.c
sound/isa/gus/gus_main.c
sound/isa/gus/interwave.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/emu8000.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/sb/sb_common.c
sound/isa/sscape.c
sound/isa/wavefront/wavefront.c
sound/mips/au1x00.c
sound/pci/als4000.c
sound/pci/azt3328.c
sound/pci/ca0106/ca0106_main.c
sound/pci/cmipci.c
sound/pci/cs46xx/cs46xx_lib.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/es1968.c
sound/pci/nm256/nm256.c
sound/pci/sonicvibes.c
sound/pci/via82xx.c
sound/pci/ymfpci/ymfpci.c
sound/pci/ymfpci/ymfpci_main.c
sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
sound/usb/usbaudio.c

index ab3dfe074fb12c8ed3c0e2414a41082a85c213f4..05ae29ac898c12b1acf9857127bac41d877f5775 100644 (file)
         <informalexample>
           <programlisting>
 <![CDATA[
-  if (chip->res_port) {
-          release_resource(chip->res_port);
-          kfree_nocheck(chip->res_port);
-  }
+  release_and_free_resource(chip->res_port);
 ]]>
           </programlisting>
         </informalexample>
-
-      As you can see, the resource pointer is also to be freed
-      via <function>kfree_nocheck()</function> after
-      <function>release_resource()</function> is called. You
-      cannot use <function>kfree()</function> here, because on ALSA,
-      <function>kfree()</function> may be a wrapper to its own
-      allocator with the memory debugging. Since the resource pointer
-      is allocated externally outside the ALSA, it must be released
-      via the native
-      <function>kfree()</function>.
-      <function>kfree_nocheck()</function> is used for that; it calls
-      the native <function>kfree()</function> without wrapper. 
       </para>
 
       <para>
index af314205635d12afe11a40130766a859d3bf3f4f..0a14885fb1d7e0d0ef39ae84f6eb62a7fcaebb89 100644 (file)
@@ -293,19 +293,13 @@ 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);
-void *snd_hidden_vmalloc(unsigned long size);
-void snd_hidden_vfree(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 vmalloc(size) snd_hidden_vmalloc(size)
-#define vfree(obj) snd_hidden_vfree(obj)
 #define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags)
-#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
 #define kfree_nocheck(obj) snd_wrapper_kfree(obj)
-#define vfree_nocheck(obj) snd_wrapper_vfree(obj)
 #define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
 #else
 #define snd_memory_init() /*NOP*/
@@ -313,9 +307,7 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags);
 #define snd_memory_info_init() /*NOP*/
 #define snd_memory_info_done() /*NOP*/
 #define kmalloc_nocheck(size, flags) kmalloc(size, flags)
-#define vmalloc_nocheck(size) vmalloc(size)
 #define kfree_nocheck(obj) kfree(obj)
-#define vfree_nocheck(obj) vfree(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);
@@ -372,6 +364,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size);
 #endif
 
 /* misc.c */
+void release_and_free_resource(struct resource *res);
 
 #ifdef CONFIG_SND_VERBOSE_PRINTK
 void snd_verbose_printk(const char *file, int line, const char *format, ...)
index 1ec2fae050a638914d98c72d0c1eaaec8073ccf8..7973e0c05ae3e3e36344877d833ff11e40c7010b 100644 (file)
@@ -55,10 +55,6 @@ void *snd_wrapper_kmalloc(size_t, gfp_t);
 #undef kmalloc
 void snd_wrapper_kfree(const void *);
 #undef kfree
-void *snd_wrapper_vmalloc(size_t);
-#undef vmalloc
-void snd_wrapper_vfree(void *);
-#undef vfree
 #endif
 
 #endif /* __SOUND_DRIVER_H */
index 7d8e2eebba5185326d0d3161a429b7758e263a3b..b99343616f81a3d26f113df1c87c5fac3da778fa 100644 (file)
@@ -47,19 +47,14 @@ struct snd_alloc_track {
 #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 long snd_alloc_vmalloc;
 static LIST_HEAD(snd_alloc_kmalloc_list);
-static LIST_HEAD(snd_alloc_vmalloc_list);
 static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock);
-static DEFINE_SPINLOCK(snd_alloc_vmalloc_lock);
 #define KMALLOC_MAGIC 0x87654321
-#define VMALLOC_MAGIC 0x87654320
 static snd_info_entry_t *snd_memory_info_entry;
 
 void __init snd_memory_init(void)
 {
        snd_alloc_kmalloc = 0;
-       snd_alloc_vmalloc = 0;
 }
 
 void snd_memory_done(void)
@@ -69,8 +64,6 @@ void snd_memory_done(void)
 
        if (snd_alloc_kmalloc > 0)
                snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
-       if (snd_alloc_vmalloc > 0)
-               snd_printk(KERN_ERR "Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc);
        list_for_each_prev(head, &snd_alloc_kmalloc_list) {
                t = list_entry(head, struct snd_alloc_track, list);
                if (t->magic != KMALLOC_MAGIC) {
@@ -79,14 +72,6 @@ void snd_memory_done(void)
                }
                snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
        }
-       list_for_each_prev(head, &snd_alloc_vmalloc_list) {
-               t = list_entry(head, struct snd_alloc_track, list);
-               if (t->magic != VMALLOC_MAGIC) {
-                       snd_printk(KERN_ERR "Corrupted vmalloc\n");
-                       break;
-               }
-               snd_printk(KERN_ERR "vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
-       }
 }
 
 static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller)
@@ -153,43 +138,6 @@ void snd_hidden_kfree(const void *obj)
        snd_wrapper_kfree(obj);
 }
 
-void *snd_hidden_vmalloc(unsigned long size)
-{
-       void *ptr;
-       ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track));
-       if (ptr) {
-               struct snd_alloc_track *t = (struct snd_alloc_track *)ptr;
-               t->magic = VMALLOC_MAGIC;
-               t->caller = __builtin_return_address(0);
-               spin_lock(&snd_alloc_vmalloc_lock);
-               list_add_tail(&t->list, &snd_alloc_vmalloc_list);
-               spin_unlock(&snd_alloc_vmalloc_lock);
-               t->size = size;
-               snd_alloc_vmalloc += size;
-               ptr = t->data;
-       }
-       return ptr;
-}
-
-void snd_hidden_vfree(void *obj)
-{
-       struct snd_alloc_track *t;
-       if (obj == NULL)
-               return;
-       t = snd_alloc_track_entry(obj);
-       if (t->magic != VMALLOC_MAGIC) {
-               snd_printk(KERN_ERR "bad vfree (called from %p)\n", __builtin_return_address(0));
-               return;
-       }
-       spin_lock(&snd_alloc_vmalloc_lock);
-       list_del(&t->list);
-       spin_unlock(&snd_alloc_vmalloc_lock);
-       t->magic = 0;
-       snd_alloc_vmalloc -= t->size;
-       obj = t;
-       snd_wrapper_vfree(obj);
-}
-
 char *snd_hidden_kstrdup(const char *s, gfp_t flags)
 {
        int len;
@@ -207,7 +155,6 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags)
 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);
-       snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc);
 }
 
 int __init snd_memory_info_init(void)
index 11a7675b719b952665d1217d5f8c389fcd301d41..3eddfdede9f3d3445df0fbb4821a382839c07051 100644 (file)
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/time.h>
+#include <linux/ioport.h>
 #include <sound/core.h>
 
+void release_and_free_resource(struct resource *res)
+{
+       if (res) {
+               release_resource(res);
+               kfree_nocheck(res);
+       }
+}
+
 #ifdef CONFIG_SND_VERBOSE_PRINTK
 void snd_verbose_printk(const char *file, int line, const char *format, ...)
 {
index bc8ad00179847bc9ea9977198978cbe419f48bef..e94eebd8ad6fafe702ee6f7881d3c4030e5134b1 100644 (file)
@@ -407,8 +407,6 @@ EXPORT_SYMBOL(snd_unregister_oss_device);
 EXPORT_SYMBOL(snd_hidden_kmalloc);
 EXPORT_SYMBOL(snd_hidden_kcalloc);
 EXPORT_SYMBOL(snd_hidden_kfree);
-EXPORT_SYMBOL(snd_hidden_vmalloc);
-EXPORT_SYMBOL(snd_hidden_vfree);
 EXPORT_SYMBOL(snd_hidden_kstrdup);
 #endif
 EXPORT_SYMBOL(copy_to_user_fromio);
@@ -487,6 +485,7 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat);
 EXPORT_SYMBOL(snd_ctl_elem_read);
 EXPORT_SYMBOL(snd_ctl_elem_write);
   /* misc.c */
+EXPORT_SYMBOL(release_and_free_resource);
 #ifdef CONFIG_SND_VERBOSE_PRINTK
 EXPORT_SYMBOL(snd_verbose_printk);
 #endif
@@ -497,6 +496,4 @@ EXPORT_SYMBOL(snd_verbose_printd);
 #ifdef CONFIG_SND_DEBUG_MEMORY
 EXPORT_SYMBOL(snd_wrapper_kmalloc);
 EXPORT_SYMBOL(snd_wrapper_kfree);
-EXPORT_SYMBOL(snd_wrapper_vmalloc);
-EXPORT_SYMBOL(snd_wrapper_vfree);
 #endif
index 296b716f1376a8f7e6ae796c2ef880d9fe3a162d..19e899089cb338682ca953d3959cb37e9cb4fc8b 100644 (file)
@@ -36,15 +36,5 @@ void snd_wrapper_kfree(const void *obj)
 {
        kfree(obj);
 }
-
-void *snd_wrapper_vmalloc(unsigned long size)
-{
-       return vmalloc(size);
-}
-
-void snd_wrapper_vfree(void *obj)
-{
-       vfree(obj);
-}
 #endif
 
index fe3f921ffbe3707137defded6690020771e641af..bdeb2c00dac5e26df9f91202cba98a0b0826e906 100644 (file)
@@ -423,10 +423,7 @@ static void snd_mpu401_uart_free(snd_rawmidi_t *rmidi)
        mpu401_t *mpu = rmidi->private_data;
        if (mpu->irq_flags && mpu->irq >= 0)
                free_irq(mpu->irq, (void *) mpu);
-       if (mpu->res) {
-               release_resource(mpu->res);
-               kfree_nocheck(mpu->res);
-       }
+       release_and_free_resource(mpu->res);
        kfree(mpu);
 }
 
index 3a25c89d2983936552b081911866a1106f72dfb7..e9d52c668edcbac31f8a6206370fbdd2377dc9d9 100644 (file)
@@ -717,10 +717,7 @@ static void free_mtpav(mtpav_t * crd)
        spin_unlock_irqrestore(&crd->spinlock, flags);
        if (crd->irq >= 0)
                free_irq(crd->irq, (void *)crd);
-       if (crd->res_port) {
-               release_resource(crd->res_port);
-               kfree_nocheck(crd->res_port);
-       }
+       release_and_free_resource(crd->res_port);
        kfree(crd);
 }
 
index 1f84d78260dea71d15e27d5859d7b673e1d4e621..06246503083c01b201831ac3d2f3bb53215725ab 100644 (file)
@@ -325,14 +325,8 @@ static int snd_opl3_free(opl3_t *opl3)
        snd_assert(opl3 != NULL, return -ENXIO);
        if (opl3->private_free)
                opl3->private_free(opl3);
-       if (opl3->res_l_port) {
-               release_resource(opl3->res_l_port);
-               kfree_nocheck(opl3->res_l_port);
-       }
-       if (opl3->res_r_port) {
-               release_resource(opl3->res_r_port);
-               kfree_nocheck(opl3->res_r_port);
-       }
+       release_and_free_resource(opl3->res_l_port);
+       release_and_free_resource(opl3->res_r_port);
        kfree(opl3);
        return 0;
 }
index 380c2c704c54342ea175115b8b6e219f4633c527..4ae5dd8f011e1acbec9bd410ddc37c11979bfa38 100644 (file)
@@ -169,14 +169,8 @@ static void snd_opl4_free(opl4_t *opl4)
 #ifdef CONFIG_PROC_FS
        snd_opl4_free_proc(opl4);
 #endif
-       if (opl4->res_fm_port) {
-               release_resource(opl4->res_fm_port);
-               kfree_nocheck(opl4->res_fm_port);
-       }
-       if (opl4->res_pcm_port) {
-               release_resource(opl4->res_pcm_port);
-               kfree_nocheck(opl4->res_pcm_port);
-       }
+       release_and_free_resource(opl4->res_fm_port);
+       release_and_free_resource(opl4->res_pcm_port);
        kfree(opl4);
 }
 
index 416172ea1f4753c6acc72b56b4bf3cdd67a36499..1ed58df42671c61d61a45281eb753ba3c3fdacea 100644 (file)
@@ -749,10 +749,7 @@ static int snd_uart16550_free(snd_uart16550_t *uart)
 {
        if (uart->irq >= 0)
                free_irq(uart->irq, (void *)uart);
-       if (uart->res_base) {
-               release_resource(uart->res_base);
-               kfree_nocheck(uart->res_base);
-       }
+       release_and_free_resource(uart->res_base);
        kfree(uart);
        return 0;
 };
index c2312d912fc7d8f1177dac0ad14a572a98385f61..2b46758fe86f4e0fef6d8e19884ded75967bf28d 100644 (file)
@@ -79,7 +79,7 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
                /* already allocated */
                if (runtime->dma_bytes >= size)
                        return 0; /* already enough large */
-               vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */
+               vfree(runtime->dma_area);
        }
        runtime->dma_area = vmalloc_32(size);
        if (! runtime->dma_area)
@@ -98,7 +98,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
 {
        snd_pcm_runtime_t *runtime = subs->runtime;
        if (runtime->dma_area) {
-               vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */
+               vfree(runtime->dma_area);
                runtime->dma_area = NULL;
        }
        return 0;
index 27a9dcfbba008cbff69860fe279b80682b12edbe..7ae02396cae2bbec83a0558479f91b7cfb2a83cf 100644 (file)
@@ -542,10 +542,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip)
 
 static int snd_ad1816a_free(ad1816a_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
        if (chip->dma1 >= 0) {
index 303861cd03cdfcc4a1396714cf7e1be60d07e672..0c2924dfefaf87e7df1d8ff4697f88c0f9a7b434 100644 (file)
@@ -846,10 +846,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream)
 
 static int snd_ad1848_free(ad1848_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
        if (chip->dma >= 0) {
index 32318258cd8ed2384b0248cbf06da7a2521faaa6..4af769030beb5751f891ea86110f1f6e29bab1ec 100644 (file)
@@ -1417,14 +1417,8 @@ static int snd_cs4231_pm_resume(snd_card_t *card)
 
 static int snd_cs4231_free(cs4231_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
-       if (chip->res_cport) {
-               release_resource(chip->res_cport);
-               kfree_nocheck(chip->res_cport);
-       }
+       release_and_free_resource(chip->res_port);
+       release_and_free_resource(chip->res_cport);
        if (chip->irq >= 0) {
                disable_irq(chip->irq);
                if (!(chip->hwshare & CS4231_HWSHARE_IRQ))
index d28315dc72f7d543a01c24622a666bd6ba6cf381..d60a55e6a0b18afdf9b89f42ea98b9bc154e578c 100644 (file)
@@ -379,12 +379,8 @@ static void snd_card_cs4236_free(snd_card_t *card)
 {
        struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data;
 
-       if (acard) {
-               if (acard->res_sb_port) {
-                       release_resource(acard->res_sb_port);
-                       kfree_nocheck(acard->res_sb_port);
-               }
-       }
+       if (acard)
+               release_and_free_resource(acard->res_sb_port);
 }
 
 #ifdef CONFIG_PNP
index aac898765c02278e99c7b8ac73efb6afb6de37f6..2edc9c9f0445c65f28c97bd5ec6272a7044373c7 100644 (file)
@@ -606,8 +606,7 @@ static int snd_es1688_free(es1688_t *chip)
 {
        if (chip->res_port) {
                snd_es1688_init(chip, 0);
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
+               release_and_free_resource(chip->res_port);
        }
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
index d0ea19f427034e886fc289f2457f457e6d8f234e..f0f8505cd1a5ef44211638f01e606bd464678110 100644 (file)
@@ -1640,18 +1640,9 @@ static int snd_es18xx_resume(snd_card_t *card)
 
 static int snd_es18xx_free(es18xx_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
-       if (chip->res_ctrl_port) {
-               release_resource(chip->res_ctrl_port);
-               kfree_nocheck(chip->res_ctrl_port);
-       }
-       if (chip->res_mpu_port) {
-               release_resource(chip->res_mpu_port);
-               kfree_nocheck(chip->res_mpu_port);
-       }
+       release_and_free_resource(chip->res_port);
+       release_and_free_resource(chip->res_ctrl_port);
+       release_and_free_resource(chip->res_mpu_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
        if (chip->dma1 >= 0) {
index 8f2872f8e8f6daae4907480b5eeb97f2c07d0a1d..5fd374f052ece4a226cd8c9772c22d823d7a08fd 100644 (file)
@@ -113,14 +113,8 @@ static int snd_gus_free(snd_gus_card_t *gus)
        snd_gf1_stop(gus);
        snd_gus_init_dma_irq(gus, 0);
       __hw_end:
-       if (gus->gf1.res_port1) {
-               release_resource(gus->gf1.res_port1);
-               kfree_nocheck(gus->gf1.res_port1);
-       }
-       if (gus->gf1.res_port2) {
-               release_resource(gus->gf1.res_port2);
-               kfree_nocheck(gus->gf1.res_port2);
-       }
+       release_and_free_resource(gus->gf1.res_port1);
+       release_and_free_resource(gus->gf1.res_port2);
        if (gus->gf1.irq >= 0)
                free_irq(gus->gf1.irq, (void *) gus);
        if (gus->gf1.dma1 >= 0) {
index 358cba9d738fa1976a1b51488f2f40ceac396b59..b101ab0a0dbfeb5293fc5839b1d093773e20f3d6 100644 (file)
@@ -638,10 +638,7 @@ static void snd_interwave_free(snd_card_t *card)
        if (iwcard == NULL)
                return;
 #ifdef SNDRV_STB
-       if (iwcard->i2c_res) {
-               release_resource(iwcard->i2c_res);
-               kfree_nocheck(iwcard->i2c_res);
-       }
+       release_and_free_resource(iwcard->i2c_res);
 #endif
        if (iwcard->irq >= 0)
                free_irq(iwcard->irq, (void *)iwcard);
index 4ba268f251e320a456d64e776b4fcca457a330c8..47cabda792b6ef66fa2d678fec346fc777acd0bd 100644 (file)
@@ -656,10 +656,7 @@ static int snd_opl3sa2_free(opl3sa2_t *chip)
 {
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
        kfree(chip);
        return 0;
 }
index 73573cb1db6a3555a2b86f20472ea32863eb0330..b94339f8306fd29620005bad3856a6d26c1027aa 100644 (file)
@@ -299,10 +299,8 @@ static char * snd_opti9xx_names[] = {
 static long snd_legacy_find_free_ioport(long *port_table, long size)
 {
        while (*port_table != -1) {
-               struct resource *res;
-               if ((res = request_region(*port_table, size, "ALSA test")) != NULL) {
-                       release_resource(res);
-                       kfree_nocheck(res);
+               if (request_region(*port_table, size, "ALSA test")) {
+                       release_region(*port_table, size);
                        return *port_table;
                }
                port_table++;
@@ -1227,10 +1225,7 @@ static int snd_opti93x_probe(opti93x_t *chip)
 
 static int snd_opti93x_free(opti93x_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
        if (chip->dma1 >= 0) {
                disable_dma(chip->dma1);
                free_dma(chip->dma1);
@@ -1656,8 +1651,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
                        if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
                                return 1;
 
-               release_resource(chip->res_mc_base);
-               kfree_nocheck(chip->res_mc_base);
+               release_and_free_resource(chip->res_mc_base);
                chip->res_mc_base = NULL;
 
        }
@@ -1683,8 +1677,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
                if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
                        return 1;
 
-               release_resource(chip->res_mc_base);
-               kfree_nocheck(chip->res_mc_base);
+               release_and_free_resource(chip->res_mc_base);
                chip->res_mc_base = NULL;
        }
 #endif /* OPTi93X */
@@ -1886,12 +1879,8 @@ static void snd_card_opti9xx_free(snd_card_t *card)
 {
        opti9xx_t *chip = (opti9xx_t *)card->private_data;
         
-       if (chip) {
-               if (chip->res_mc_base) {
-                       release_resource(chip->res_mc_base);
-                       kfree_nocheck(chip->res_mc_base);
-               }
-       }
+       if (chip)
+               release_and_free_resource(chip->res_mc_base);
 }
 
 static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
index 5375705c054bbaceece95c7cd7a9797136a688e6..95540f1331995dbfa4f71ae2b2b6443abf8efac6 100644 (file)
@@ -1054,18 +1054,9 @@ __error:
  */
 static int snd_emu8000_free(emu8000_t *hw)
 {
-       if (hw->res_port1) {
-               release_resource(hw->res_port1);
-               kfree_nocheck(hw->res_port1);
-       }
-       if (hw->res_port2) {
-               release_resource(hw->res_port2);
-               kfree_nocheck(hw->res_port2);
-       }
-       if (hw->res_port3) {
-               release_resource(hw->res_port3);
-               kfree_nocheck(hw->res_port3);
-       }
+       release_and_free_resource(hw->res_port1);
+       release_and_free_resource(hw->res_port2);
+       release_and_free_resource(hw->res_port3);
        kfree(hw);
        return 0;
 }
index 7888783d68f598ed2c1ef179834d22cbf5c17ff3..c2fa451bc8f05c293531e93cc23fdd7598957552 100644 (file)
@@ -345,10 +345,7 @@ static void snd_sb16_free(snd_card_t *card)
         
        if (acard == NULL)
                return;
-       if (acard->fm_res) {
-               release_resource(acard->fm_res);
-               kfree_nocheck(acard->fm_res);
-       }
+       release_and_free_resource(acard->fm_res);
 }
 
 #ifdef CONFIG_PNP
index c41ac25e85ca6edcb924bbb8b43f1d4179ccec04..0bc0a3afdabc0cf73b267e4477a0a1dca2bc51a4 100644 (file)
@@ -78,10 +78,7 @@ static void snd_sb8_free(snd_card_t *card)
 
        if (acard == NULL)
                return;
-       if (acard->fm_res) {
-               release_resource(acard->fm_res);
-               kfree_nocheck(acard->fm_res);
-       }
+       release_and_free_resource(acard->fm_res);
 }
 
 static int __init snd_sb8_probe(int dev)
index f0f205ae425fec52b29d0460243983c4f8f7bf40..46b9480669f936fc82ea632a6802da50d0e676b0 100644 (file)
@@ -178,10 +178,8 @@ static int snd_sbdsp_probe(sb_t * chip)
 
 static int snd_sbdsp_free(sb_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       if (chip->res_port)
+               release_and_free_resource(chip->res_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
index 9f6b58c79209cbc4f217a0b9dd700bf0270e37b0..1036876146c4e9c8460b3d1554a2055f5ebdcbc6 100644 (file)
@@ -338,8 +338,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base)
 static void soundscape_free(snd_card_t * c)
 {
        register struct soundscape *sscape = get_card_soundscape(c);
-       release_resource(sscape->io_res);
-       kfree_nocheck(sscape->io_res);
+       release_and_free_resource(sscape->io_res);
        free_dma(sscape->chip->dma1);
 }
 
@@ -1288,8 +1287,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
        free_dma(params->dma1);
 
        _release_region:
-       release_resource(io_res);
-       kfree_nocheck(io_res);
+       release_and_free_resource(io_res);
 
        return err;
 }
index 0a572e0a47e62d891f5a5e30d704cfb3f952e217..1818f1013c3f7739c3635849fc83042d7c77063d 100644 (file)
@@ -379,10 +379,7 @@ snd_wavefront_free(snd_card_t *card)
        snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
        
        if (acard) {
-               if (acard->wavefront.res_base != NULL) {
-                       release_resource(acard->wavefront.res_base);
-                       kfree_nocheck(acard->wavefront.res_base);
-               }
+               release_and_free_resource(acard->wavefront.res_base);
                if (acard->wavefront.irq > 0)
                        free_irq(acard->wavefront.irq, (void *)acard);
        }
index 3f9684f1d1d2a24e1fe7cbcf24f98d3a4ca3a5a7..b7af85f5bfb4a797342b418d860ca73bab2817d3 100644 (file)
@@ -606,8 +606,7 @@ snd_au1000_free(snd_card_t *card)
                /* put internal AC97 block into reset */
                au1000->ac97_ioport->cntrl = AC97C_RS;
                au1000->ac97_ioport = NULL;
-               release_resource(au1000->ac97_res_port);
-               kfree_nocheck(au1000->ac97_res_port);
+               release_and_free_resource(au1000->ac97_res_port);
        }
 
        if (au1000->stream[PLAYBACK]->dma >= 0)
index 196ec1c61bb4712342055924902863064e8ca200..8a32cd92f62adaf8117a05c52a7fb49b1c0bdb22 100644 (file)
@@ -594,8 +594,7 @@ static int __devinit snd_als4000_create_gameport(snd_card_als4000_t *acard, int
        acard->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "als4000: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -622,8 +621,7 @@ static void snd_als4000_free_gameport(snd_card_als4000_t *acard)
                acard->gameport = NULL;
 
                snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
index d5261bdec583d5fbac6bcfe438d35e8d4ac705c3..dc638f395c02ed39dd8b5e1c962f13d71a394772 100644 (file)
@@ -1238,8 +1238,7 @@ static int __devinit snd_azf3328_config_joystick(azf3328_t *chip, int dev)
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "azt3328: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -1267,8 +1266,7 @@ static void snd_azf3328_free_joystick(azf3328_t *chip)
                /* disable gameport */
                snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR,
                                      snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) & ~LEGACY_JOY);
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
index ba07960921d8018f92d92957275b37ccf25105d4..0d9d8923fbbbff2ca1d053e3b237a5af057e9758 100644 (file)
@@ -969,10 +969,8 @@ static int snd_ca0106_free(ca0106_t *chip)
 #endif
 
        // release the i/o port
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
+
        // release the irq
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
index 316afb78488d4500515e8f86ef683a2ad074187b..db093bca2cd0addfb15cdb20defdc2cc004a307d 100644 (file)
@@ -2683,8 +2683,7 @@ static int __devinit snd_cmipci_create_gameport(cmipci_t *cm, int dev)
        cm->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
        gameport_set_name(gp, "C-Media Gameport");
@@ -2709,8 +2708,7 @@ static void snd_cmipci_free_gameport(cmipci_t *cm)
                cm->gameport = NULL;
 
                snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
index 6e3855b8b33d9922c0cafcdb59f1fd3df99e9c9f..147836f09dcff7a020d8bc1b508d803e968f0f79 100644 (file)
@@ -2906,10 +2906,7 @@ static int snd_cs46xx_free(cs46xx_t *chip)
                snd_cs46xx_region_t *region = &chip->region.idx[idx];
                if (region->remap_addr)
                        iounmap(region->remap_addr);
-               if (region->resource) {
-                       release_resource(region->resource);
-                       kfree_nocheck(region->resource);
-               }
+               release_and_free_resource(region->resource);
        }
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
index ad15755a63c35a788bfbfea7323461713cad7f1a..cbb689474e7d12297981e62b2d23883c5a9bd57e 100644 (file)
@@ -759,10 +759,8 @@ static int snd_emu10k1x_free(emu10k1x_t *chip)
        outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
 
        // release the i/o port
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
+
        // release the irq
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
index ecdcada90ca25945923a938472e506400344fcd6..1bf094b6746996454919a041efc98e1147451c6d 100644 (file)
@@ -2461,8 +2461,7 @@ static int __devinit snd_es1968_create_gameport(es1968_t *chip, int dev)
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "es1968: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -2488,8 +2487,7 @@ static void snd_es1968_free_gameport(es1968_t *chip)
                gameport_unregister_port(chip->gameport);
                chip->gameport = NULL;
 
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
index 5c55a3b1d121b247c46cd8a5d64274a1631c847f..ebfa38b51128d09d16dcacfd5aa43797b2144908 100644 (file)
@@ -1347,14 +1347,8 @@ static int snd_nm256_free(nm256_t *chip)
                iounmap(chip->cport);
        if (chip->buffer)
                iounmap(chip->buffer);
-       if (chip->res_cport) {
-               release_resource(chip->res_cport);
-               kfree_nocheck(chip->res_cport);
-       }
-       if (chip->res_buffer) {
-               release_resource(chip->res_buffer);
-               kfree_nocheck(chip->res_buffer);
-       }
+       release_and_free_resource(chip->res_cport);
+       release_and_free_resource(chip->res_buffer);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void*)chip);
 
index 1f6c2bfd43fdef56faa85973b24e7b70f431d40d..4f64814dfef00bb98366696987139e7a2dddf0e4 100644 (file)
@@ -1205,14 +1205,8 @@ static int snd_sonicvibes_free(sonicvibes_t *sonic)
        pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port);
        if (sonic->irq >= 0)
                free_irq(sonic->irq, (void *)sonic);
-       if (sonic->res_dmaa) {
-               release_resource(sonic->res_dmaa);
-               kfree_nocheck(sonic->res_dmaa);
-       }
-       if (sonic->res_dmac) {
-               release_resource(sonic->res_dmac);
-               kfree_nocheck(sonic->res_dmac);
-       }
+       release_and_free_resource(sonic->res_dmaa);
+       release_and_free_resource(sonic->res_dmac);
        pci_release_regions(sonic->pci);
        pci_disable_device(sonic->pci);
        kfree(sonic);
index b2779fb7d1a981810907b9aa5d55d1e569f70481..b0302c369c3d2dc3608f34605b6826f94318b399 100644 (file)
@@ -1655,8 +1655,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -1682,8 +1681,7 @@ static void snd_via686_free_gameport(via82xx_t *chip)
 
                gameport_unregister_port(chip->gameport);
                chip->gameport = NULL;
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
@@ -2023,10 +2021,7 @@ static int snd_via82xx_free(via82xx_t *chip)
       __end_hw:
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
-       if (chip->mpu_res) {
-               release_resource(chip->mpu_res);
-               kfree_nocheck(chip->mpu_res);
-       }
+       release_and_free_resource(chip->mpu_res);
        pci_release_regions(chip->pci);
 
        if (chip->chip_type == TYPE_VIA686) {
index 2e69abe51aa985dbc0947689946a2659d2cd374b..e50d744ae706ae9a04d0eca08e322cbab9bcd480 100644 (file)
@@ -130,8 +130,7 @@ static int __devinit snd_ymfpci_create_gameport(ymfpci_t *chip, int dev,
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -161,8 +160,7 @@ void snd_ymfpci_free_gameport(ymfpci_t *chip)
                gameport_unregister_port(chip->gameport);
                chip->gameport = NULL;
 
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
@@ -267,14 +265,8 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
                                     old_legacy_ctrl,
                                     &chip)) < 0) {
                snd_card_free(card);
-               if (mpu_res) {
-                       release_resource(mpu_res);
-                       kfree_nocheck(mpu_res);
-               }
-               if (fm_res) {
-                       release_resource(fm_res);
-                       kfree_nocheck(fm_res);
-               }
+               release_and_free_resource(mpu_res);
+               release_and_free_resource(fm_res);
                return err;
        }
        chip->fm_res = fm_res;
index 2e671ee438c6fbbb24337e5c01ddced3a29f0a6f..c0aaade772d4cd07ad2521de8e18c22d5df769a9 100644 (file)
@@ -2151,14 +2151,8 @@ static int snd_ymfpci_free(ymfpci_t *chip)
 #ifdef CONFIG_PM
        vfree(chip->saved_regs);
 #endif
-       if (chip->mpu_res) {
-               release_resource(chip->mpu_res);
-               kfree_nocheck(chip->mpu_res);
-       }
-       if (chip->fm_res) {
-               release_resource(chip->fm_res);
-               kfree_nocheck(chip->fm_res);
-       }
+       release_and_free_resource(chip->mpu_res);
+       release_and_free_resource(chip->fm_res);
        snd_ymfpci_free_gameport(chip);
        if (chip->reg_area_virt)
                iounmap(chip->reg_area_virt);
@@ -2167,10 +2161,7 @@ static int snd_ymfpci_free(ymfpci_t *chip)
        
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
-       if (chip->res_reg_area) {
-               release_resource(chip->res_reg_area);
-               kfree_nocheck(chip->res_reg_area);
-       }
+       release_and_free_resource(chip->res_reg_area);
 
        pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
        
index 0a954dc11b7396ec65d34797bcd496c6e7387936..20b86d8df7a3066b2fcc845cc573d1483c615255 100644 (file)
@@ -50,9 +50,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
        if (runtime->dma_area) {
                if (runtime->dma_bytes >= size)
                        return 0; /* already enough large */
-               vfree_nocheck(runtime->dma_area);
+               vfree(runtime->dma_area);
        }
-       runtime->dma_area = vmalloc_nocheck(size);
+       runtime->dma_area = vmalloc_32(size);
        if (! runtime->dma_area)
                return -ENOMEM;
        runtime->dma_bytes = size;
@@ -67,7 +67,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
 {
        snd_pcm_runtime_t *runtime = subs->runtime;
        if (runtime->dma_area) {
-               vfree_nocheck(runtime->dma_area);
+               vfree(runtime->dma_area);
                runtime->dma_area = NULL;
        }
        return 0;
index 5429b169877a8b187687ef0797138eec4fa9d07e..4589c637a25eb9432bb2e6f17e58775da51d851a 100644 (file)
@@ -692,9 +692,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size)
        if (runtime->dma_area) {
                if (runtime->dma_bytes >= size)
                        return 0; /* already large enough */
-               vfree_nocheck(runtime->dma_area);
+               vfree(runtime->dma_area);
        }
-       runtime->dma_area = vmalloc_nocheck(size);
+       runtime->dma_area = vmalloc(size);
        if (! runtime->dma_area)
                return -ENOMEM;
        runtime->dma_bytes = size;
@@ -706,7 +706,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs)
 {
        snd_pcm_runtime_t *runtime = subs->runtime;
        if (runtime->dma_area) {
-               vfree_nocheck(runtime->dma_area);
+               vfree(runtime->dma_area);
                runtime->dma_area = NULL;
        }
        return 0;