提交 b1d5776d 编写于 作者: T Takashi Iwai 提交者: Jaroslav Kysela

[ALSA] Remove vmalloc wrapper, kfree_nocheck()

- Remove vmalloc wrapper
- Add release_and_free_resource() to remove kfree_nocheck() from each driver
  and simplify the code
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 93f2e378
......@@ -1433,25 +1433,10 @@
<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>
......
......@@ -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, ...)
......
......@@ -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 */
......@@ -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)
......
......@@ -23,8 +23,17 @@
#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, ...)
{
......
......@@ -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
......@@ -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
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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;
};
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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))
......
......@@ -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
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -1054,18 +1054,9 @@ snd_emu8000_create_mixer(snd_card_t *card, emu8000_t *emu)
*/
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;
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册