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