Commit c57fa3a0 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Linus Torvalds

[PATCH] dmasound kill MOD_{IN,DE}C_USE_COUNT

Dmasound: Use try_module_get()/module_put() instead of methods calling
MOD_{IN,DE}C_USE_COUNT (from Christoph Hellwig)
parent 372ec4e0
...@@ -115,8 +115,7 @@ typedef struct { ...@@ -115,8 +115,7 @@ typedef struct {
typedef struct { typedef struct {
const char *name; const char *name;
const char *name2; const char *name2;
void (*open)(void); struct module *owner;
void (*release)(void);
void *(*dma_alloc)(unsigned int, int); void *(*dma_alloc)(unsigned int, int);
void (*dma_free)(void *, unsigned int); void (*dma_free)(void *, unsigned int);
int (*irqinit)(void); int (*irqinit)(void);
......
...@@ -115,8 +115,6 @@ static ssize_t ata_ctx_u16le(const u_char *userPtr, size_t userCount, ...@@ -115,8 +115,6 @@ static ssize_t ata_ctx_u16le(const u_char *userPtr, size_t userCount,
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void AtaOpen(void);
static void AtaRelease(void);
static void *AtaAlloc(unsigned int size, int flags); static void *AtaAlloc(unsigned int size, int flags);
static void AtaFree(void *, unsigned int size); static void AtaFree(void *, unsigned int size);
static int AtaIrqInit(void); static int AtaIrqInit(void);
...@@ -813,16 +811,6 @@ static TRANS transFalconExpanding = { ...@@ -813,16 +811,6 @@ static TRANS transFalconExpanding = {
* Atari (TT/Falcon) * Atari (TT/Falcon)
*/ */
static void AtaOpen(void)
{
MOD_INC_USE_COUNT;
}
static void AtaRelease(void)
{
MOD_DEC_USE_COUNT;
}
static void *AtaAlloc(unsigned int size, int flags) static void *AtaAlloc(unsigned int size, int flags)
{ {
return atari_stram_alloc(size, "dmasound"); return atari_stram_alloc(size, "dmasound");
...@@ -1521,8 +1509,7 @@ static SETTINGS def_soft = { ...@@ -1521,8 +1509,7 @@ static SETTINGS def_soft = {
static MACHINE machTT = { static MACHINE machTT = {
.name = "Atari", .name = "Atari",
.name2 = "TT", .name2 = "TT",
.open = AtaOpen, .owner = THIS_MODULE,
.release = AtaRelease,
.dma_alloc = AtaAlloc, .dma_alloc = AtaAlloc,
.dma_free = AtaFree, .dma_free = AtaFree,
.irqinit = AtaIrqInit, .irqinit = AtaIrqInit,
......
...@@ -252,8 +252,6 @@ int expand_bal; /* Balance factor for expanding (not volume!) */ ...@@ -252,8 +252,6 @@ int expand_bal; /* Balance factor for expanding (not volume!) */
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void PMacOpen(void);
static void PMacRelease(void);
static void *PMacAlloc(unsigned int size, int flags); static void *PMacAlloc(unsigned int size, int flags);
static void PMacFree(void *ptr, unsigned int size); static void PMacFree(void *ptr, unsigned int size);
static int PMacIrqInit(void); static int PMacIrqInit(void);
...@@ -493,17 +491,6 @@ awacs_tumbler_cleanup(void) ...@@ -493,17 +491,6 @@ awacs_tumbler_cleanup(void)
/* /*
* PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA. * PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA.
*/ */
static void PMacOpen(void)
{
MOD_INC_USE_COUNT;
}
static void PMacRelease(void)
{
MOD_DEC_USE_COUNT;
}
static void *PMacAlloc(unsigned int size, int flags) static void *PMacAlloc(unsigned int size, int flags)
{ {
return kmalloc(size, flags); return kmalloc(size, flags);
...@@ -2428,8 +2415,7 @@ static SETTINGS def_soft = { ...@@ -2428,8 +2415,7 @@ static SETTINGS def_soft = {
static MACHINE machPMac = { static MACHINE machPMac = {
.name = awacs_name, .name = awacs_name,
.name2 = "PowerMac Built-in Sound", .name2 = "PowerMac Built-in Sound",
.open = PMacOpen, .owner = THIS_MODULE,
.release = PMacRelease,
.dma_alloc = PMacAlloc, .dma_alloc = PMacAlloc,
.dma_free = PMacFree, .dma_free = PMacFree,
.irqinit = PMacIrqInit, .irqinit = PMacIrqInit,
......
...@@ -327,7 +327,8 @@ static struct { ...@@ -327,7 +327,8 @@ static struct {
static int mixer_open(struct inode *inode, struct file *file) static int mixer_open(struct inode *inode, struct file *file)
{ {
dmasound.mach.open(); if (!try_module_get(dmasound.mach.owner))
return -ENODEV;
mixer.busy = 1; mixer.busy = 1;
return 0; return 0;
} }
...@@ -336,7 +337,7 @@ static int mixer_release(struct inode *inode, struct file *file) ...@@ -336,7 +337,7 @@ static int mixer_release(struct inode *inode, struct file *file)
{ {
lock_kernel(); lock_kernel();
mixer.busy = 0; mixer.busy = 0;
dmasound.mach.release(); module_put(dmasound.mach.owner);
unlock_kernel(); unlock_kernel();
return 0; return 0;
} }
...@@ -869,31 +870,29 @@ static int sq_open(struct inode *inode, struct file *file) ...@@ -869,31 +870,29 @@ static int sq_open(struct inode *inode, struct file *file)
{ {
int rc; int rc;
dmasound.mach.open(); if (!try_module_get(dmasound.mach.owner))
return -ENODEV;
if ((rc = write_sq_open(file))) { /* checks the f_mode */ rc = write_sq_open(file); /* checks the f_mode */
dmasound.mach.release(); if (rc)
return rc; goto out;
}
#ifdef HAS_RECORD #ifdef HAS_RECORD
if (dmasound.mach.record) { if (dmasound.mach.record) {
if ((rc = read_sq_open(file))) { /* checks the f_mode */ rc = read_sq_open(file); /* checks the f_mode */
dmasound.mach.release(); if (rc)
return rc; goto out;
}
} else { /* no record function installed; in compat mode */ } else { /* no record function installed; in compat mode */
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
/* TODO: if O_RDWR, release any resources grabbed by write part */ /* TODO: if O_RDWR, release any resources grabbed by write part */
dmasound.mach.release() ; rc = -ENXIO;
/* I think this is what is required by open(2) */ goto out;
return -ENXIO ;
} }
} }
#else /* !HAS_RECORD */ #else /* !HAS_RECORD */
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
/* TODO: if O_RDWR, release any resources grabbed by write part */ /* TODO: if O_RDWR, release any resources grabbed by write part */
dmasound.mach.release() ; rc = -ENXIO ; /* I think this is what is required by open(2) */
return -ENXIO ; /* I think this is what is required by open(2) */ goto out;
} }
#endif /* HAS_RECORD */ #endif /* HAS_RECORD */
...@@ -931,6 +930,9 @@ static int sq_open(struct inode *inode, struct file *file) ...@@ -931,6 +930,9 @@ static int sq_open(struct inode *inode, struct file *file)
#endif #endif
return 0; return 0;
out:
module_put(dmasound.mach.owner);
return rc;
} }
static void sq_reset_output(void) static void sq_reset_output(void)
...@@ -1050,7 +1052,7 @@ static int sq_release(struct inode *inode, struct file *file) ...@@ -1050,7 +1052,7 @@ static int sq_release(struct inode *inode, struct file *file)
dmasound.hard = dmasound.mach.default_hard ; dmasound.hard = dmasound.mach.default_hard ;
} }
dmasound.mach.release(); module_put(dmasound.mach.owner);
#if 0 /* blocking open() */ #if 0 /* blocking open() */
/* Wake up a process waiting for the queue being released. /* Wake up a process waiting for the queue being released.
...@@ -1447,7 +1449,8 @@ static int state_open(struct inode *inode, struct file *file) ...@@ -1447,7 +1449,8 @@ static int state_open(struct inode *inode, struct file *file)
if (state.busy) if (state.busy)
return -EBUSY; return -EBUSY;
dmasound.mach.open(); if (!try_module_get(dmasound.mach.owner))
return -ENODEV;
state.ptr = 0; state.ptr = 0;
state.busy = 1; state.busy = 1;
...@@ -1529,7 +1532,7 @@ static int state_release(struct inode *inode, struct file *file) ...@@ -1529,7 +1532,7 @@ static int state_release(struct inode *inode, struct file *file)
{ {
lock_kernel(); lock_kernel();
state.busy = 0; state.busy = 0;
dmasound.mach.release(); module_put(dmasound.mach.owner);
unlock_kernel(); unlock_kernel();
return 0; return 0;
} }
......
...@@ -69,8 +69,6 @@ static int write_sq_block_size_half, write_sq_block_size_quarter; ...@@ -69,8 +69,6 @@ static int write_sq_block_size_half, write_sq_block_size_quarter;
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void AmiOpen(void);
static void AmiRelease(void);
static void *AmiAlloc(unsigned int size, int flags); static void *AmiAlloc(unsigned int size, int flags);
static void AmiFree(void *obj, unsigned int size); static void AmiFree(void *obj, unsigned int size);
static int AmiIrqInit(void); static int AmiIrqInit(void);
...@@ -311,17 +309,6 @@ static TRANS transAmiga = { ...@@ -311,17 +309,6 @@ static TRANS transAmiga = {
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void AmiOpen(void)
{
MOD_INC_USE_COUNT;
}
static void AmiRelease(void)
{
MOD_DEC_USE_COUNT;
}
static inline void StopDMA(void) static inline void StopDMA(void)
{ {
custom.aud[0].audvol = custom.aud[1].audvol = 0; custom.aud[0].audvol = custom.aud[1].audvol = 0;
...@@ -699,8 +686,7 @@ static SETTINGS def_soft = { ...@@ -699,8 +686,7 @@ static SETTINGS def_soft = {
static MACHINE machAmiga = { static MACHINE machAmiga = {
.name = "Amiga", .name = "Amiga",
.name2 = "AMIGA", .name2 = "AMIGA",
.open = AmiOpen, .owner = THIS_MODULE,
.release = AmiRelease,
.dma_alloc = AmiAlloc, .dma_alloc = AmiAlloc,
.dma_free = AmiFree, .dma_free = AmiFree,
.irqinit = AmiIrqInit, .irqinit = AmiIrqInit,
......
...@@ -36,8 +36,6 @@ static int expand_data; /* Data for expanding */ ...@@ -36,8 +36,6 @@ static int expand_data; /* Data for expanding */
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void Q40Open(void);
static void Q40Release(void);
static void *Q40Alloc(unsigned int size, int flags); static void *Q40Alloc(unsigned int size, int flags);
static void Q40Free(void *, unsigned int); static void Q40Free(void *, unsigned int);
static int Q40IrqInit(void); static int Q40IrqInit(void);
...@@ -360,18 +358,6 @@ static TRANS transQ40Compressing = { ...@@ -360,18 +358,6 @@ static TRANS transQ40Compressing = {
/*** Low level stuff *********************************************************/ /*** Low level stuff *********************************************************/
static void Q40Open(void)
{
MOD_INC_USE_COUNT;
}
static void Q40Release(void)
{
MOD_DEC_USE_COUNT;
}
static void *Q40Alloc(unsigned int size, int flags) static void *Q40Alloc(unsigned int size, int flags)
{ {
return kmalloc(size, flags); /* change to vmalloc */ return kmalloc(size, flags); /* change to vmalloc */
...@@ -603,8 +589,7 @@ static SETTINGS def_soft = { ...@@ -603,8 +589,7 @@ static SETTINGS def_soft = {
static MACHINE machQ40 = { static MACHINE machQ40 = {
.name = "Q40", .name = "Q40",
.name2 = "Q40", .name2 = "Q40",
.open = Q40Open, .owner = THIS_MODULE,
.release = Q40Release,
.dma_alloc = Q40Alloc, .dma_alloc = Q40Alloc,
.dma_free = Q40Free, .dma_free = Q40Free,
.irqinit = Q40IrqInit, .irqinit = Q40IrqInit,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment