summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2002-12-29 03:26:34 -0800
committerLinus Torvalds <torvalds@home.transmeta.com>2002-12-29 03:26:34 -0800
commitbec7aa00ffe5b1270837b965fdfe80be3e8e6e2e (patch)
tree824e2b0659efabeb2d4306091942edc5df5eda40
parentf21caa1f52b1c9a7f07cb801745bf2b569bb3a72 (diff)
[PATCH] more module warning fixes
this is only for the module-related warning introduced by my __deprecated patch.
-rw-r--r--drivers/block/paride/paride.c15
-rw-r--r--drivers/char/busmouse.c7
-rw-r--r--drivers/hotplug/pci_hotplug_core.c52
-rw-r--r--drivers/ide/ide.c6
-rw-r--r--drivers/ieee1394/ieee1394_core.c23
-rw-r--r--drivers/isdn/capi/kcapi.c3
-rw-r--r--drivers/md/dm-target.c14
-rw-r--r--drivers/media/dvb/dvb-core/dvb_i2c.c23
-rw-r--r--drivers/media/video/cpia.c3
-rw-r--r--drivers/mtd/chips/chipreg.c6
-rw-r--r--drivers/net/irda/sir_dev.c9
-rw-r--r--drivers/net/irda/sir_dongle.c7
-rw-r--r--drivers/s390/block/dasd.c3
-rw-r--r--drivers/s390/block/dasd_ioctl.c2
-rw-r--r--drivers/s390/char/tape_core.c3
-rw-r--r--drivers/scsi/fcal.c10
-rw-r--r--drivers/scsi/pluto.c8
-rw-r--r--drivers/serial/core.c6
-rw-r--r--drivers/usb/media/ov511.c32
-rw-r--r--drivers/usb/media/usbvideo.c8
-rw-r--r--include/linux/mtd/map.h5
-rw-r--r--include/linux/mtd/mtd.h3
-rw-r--r--net/core/dev.c9
-rw-r--r--net/ipv4/xfrm_policy.c3
-rw-r--r--net/rxrpc/call.c2
-rw-r--r--sound/core/control.c10
-rw-r--r--sound/core/info.c10
-rw-r--r--sound/core/oss/mixer_oss.c8
-rw-r--r--sound/core/oss/pcm_oss.c10
-rw-r--r--sound/core/pcm_native.c12
-rw-r--r--sound/core/rawmidi.c10
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c10
-rw-r--r--sound/core/seq/seq_ports.c10
-rw-r--r--sound/core/seq/seq_virmidi.c10
-rw-r--r--sound/core/timer.c8
-rw-r--r--sound/drivers/opl3/opl3_seq.c8
-rw-r--r--sound/isa/gus/gus_main.c8
-rw-r--r--sound/isa/wavefront/wavefront_fx.c9
-rw-r--r--sound/isa/wavefront/wavefront_synth.c9
-rw-r--r--sound/oss/audio.c26
-rw-r--r--sound/oss/midibuf.c6
-rw-r--r--sound/oss/mpu401.c18
-rw-r--r--sound/oss/sequencer.c22
-rw-r--r--sound/oss/soundcard.c10
-rw-r--r--sound/synth/emux/emux_seq.c12
45 files changed, 172 insertions, 316 deletions
diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
index 3c1161767acf..0b19343f6969 100644
--- a/drivers/block/paride/paride.c
+++ b/drivers/block/paride/paride.c
@@ -175,8 +175,7 @@ void pi_release(PIA * pi)
#endif /* !CONFIG_PARPORT */
if (pi->proto->release_proto)
pi->proto->release_proto(pi);
- if (pi->proto->owner)
- __MOD_DEC_USE_COUNT(pi->proto->owner);
+ module_put(pi->proto->owner);
}
EXPORT_SYMBOL(pi_release);
@@ -238,7 +237,6 @@ int pi_register(PIP * pr)
printk("paride: protocol table full\n");
return 0;
}
- MOD_INC_USE_COUNT;
protocols[k] = pr;
pr->index = k;
printk("paride: %s registered as protocol %d\n", pr->name, k);
@@ -256,7 +254,6 @@ void pi_unregister(PIP * pr)
return;
}
protocols[pr->index] = 0;
- MOD_DEC_USE_COUNT;
}
EXPORT_SYMBOL(pi_unregister);
@@ -392,14 +389,13 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
if (!proto)
continue;
/* still racy */
- if (proto->owner)
- __MOD_INC_USE_COUNT(proto->owner);
+ if (!try_module_get(proto->owner))
+ continue;
pi->proto = proto;
pi->private = 0;
if (proto->init_proto && proto->init_proto(pi) < 0) {
pi->proto = NULL;
- if (proto->owner)
- __MOD_DEC_USE_COUNT(proto->owner);
+ module_put(proto->owner);
continue;
}
if (delay == -1)
@@ -432,8 +428,7 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
}
if (pi->proto->release_proto)
pi->proto->release_proto(pi);
- if (proto->owner)
- __MOD_DEC_USE_COUNT(proto->owner);
+ module_put(proto->owner);
}
if (!pi->port) {
diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c
index 29362e24aa4c..85baa0cdf51b 100644
--- a/drivers/char/busmouse.c
+++ b/drivers/char/busmouse.c
@@ -175,8 +175,7 @@ static int busmouse_release(struct inode *inode, struct file *file)
if (--mse->active == 0) {
if (mse->ops->release)
ret = mse->ops->release(inode, file);
- if (mse->ops->owner)
- __MOD_DEC_USE_COUNT(mse->ops->owner);
+ module_put(mse->ops->owner);
mse->ready = 0;
}
unlock_kernel();
@@ -207,8 +206,8 @@ static int busmouse_open(struct inode *inode, struct file *file)
ret = 0;
if (mse->ops->open) {
ret = mse->ops->open(inode, file);
- if (ret && mse->ops->owner)
- __MOD_DEC_USE_COUNT(mse->ops->owner);
+ if (ret)
+ module_put(mse->ops->owner);
}
if (ret)
diff --git a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c
index b03104c8edd1..5e4c1748b7d1 100644
--- a/drivers/hotplug/pci_hotplug_core.c
+++ b/drivers/hotplug/pci_hotplug_core.c
@@ -561,19 +561,19 @@ static void fs_remove_file (struct dentry *dentry)
up(&parent->d_inode->i_sem);
}
+/* yuck, WFT is this? */
#define GET_STATUS(name,type) \
static int get_##name (struct hotplug_slot *slot, type *value) \
{ \
struct hotplug_slot_ops *ops = slot->ops; \
int retval = 0; \
- if (ops->owner) \
- __MOD_INC_USE_COUNT(ops->owner); \
- if (ops->get_##name) \
- retval = ops->get_##name (slot, value); \
- else \
- *value = slot->info->name; \
- if (ops->owner) \
- __MOD_DEC_USE_COUNT(ops->owner); \
+ if (try_module_get(ops->owner)) { \
+ if (ops->get_##name) \
+ retval = ops->get_##name (slot, value); \
+ else \
+ *value = slot->info->name; \
+ module_put(ops->owner); \
+ } \
return retval; \
}
@@ -665,21 +665,19 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co
case 0:
if (!slot->ops->disable_slot)
break;
- if (slot->ops->owner)
- __MOD_INC_USE_COUNT(slot->ops->owner);
- retval = slot->ops->disable_slot(slot);
- if (slot->ops->owner)
- __MOD_DEC_USE_COUNT(slot->ops->owner);
+ if (try_module_get(slot->ops->owner)) {
+ retval = slot->ops->disable_slot(slot);
+ module_put(slot->ops->owner);
+ }
break;
case 1:
if (!slot->ops->enable_slot)
break;
- if (slot->ops->owner)
- __MOD_INC_USE_COUNT(slot->ops->owner);
- retval = slot->ops->enable_slot(slot);
- if (slot->ops->owner)
- __MOD_DEC_USE_COUNT(slot->ops->owner);
+ if (try_module_get(slot->ops->owner)) {
+ retval = slot->ops->enable_slot(slot);
+ module_put(slot->ops->owner);
+ }
break;
default:
@@ -773,11 +771,10 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_
dbg (" - attention = %d\n", attention);
if (slot->ops->set_attention_status) {
- if (slot->ops->owner)
- __MOD_INC_USE_COUNT(slot->ops->owner);
- retval = slot->ops->set_attention_status(slot, attention);
- if (slot->ops->owner)
- __MOD_DEC_USE_COUNT(slot->ops->owner);
+ if (try_module_get(slot->ops->owner)) {
+ retval = slot->ops->set_attention_status(slot, attention);
+ module_put(slot->ops->owner);
+ }
}
exit:
@@ -1011,11 +1008,10 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou
dbg ("test = %d\n", test);
if (slot->ops->hardware_test) {
- if (slot->ops->owner)
- __MOD_INC_USE_COUNT(slot->ops->owner);
- retval = slot->ops->hardware_test(slot, test);
- if (slot->ops->owner)
- __MOD_DEC_USE_COUNT(slot->ops->owner);
+ if (try_module_get(slot->ops->owner)) {
+ retval = slot->ops->hardware_test(slot, test);
+ module_put(slot->ops->owner);
+ }
}
exit:
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 3c07fbefa9bf..0ae396abfcc1 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1336,14 +1336,12 @@ int ata_attach(ide_drive_t *drive)
continue;
spin_unlock(&drivers_lock);
if (driver->attach(drive) == 0) {
- if (driver->owner)
- __MOD_DEC_USE_COUNT(driver->owner);
+ module_put(driver->owner);
drive->gendev.driver = &driver->gen_driver;
return 0;
}
spin_lock(&drivers_lock);
- if (driver->owner)
- __MOD_DEC_USE_COUNT(driver->owner);
+ module_put(driver->owner);
}
spin_unlock(&drivers_lock);
spin_lock(&drives_lock);
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 0b251ee098c1..b5e00b4b12b5 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -1135,28 +1135,19 @@ static int ieee1394_dispatch_open(struct inode *inode, struct file *file)
unloading while the file is open, and will be
dropped by the VFS when the file is released.
*/
-
- if(THIS_MODULE)
- __MOD_DEC_USE_COUNT((struct module*) THIS_MODULE);
-
- /* note that if ieee1394 is compiled into the kernel,
- THIS_MODULE will be (void*) NULL, hence the if and
- the cast are necessary */
-
+ module_put(THIS_MODULE);
} else {
-
- /* if the open() failed, then we need to drop the
- extra reference we gave to the task-specific
- driver */
-
- if(module)
- __MOD_DEC_USE_COUNT(module);
-
/* point the file's f_ops back to ieee1394. The VFS will then
decrement ieee1394's reference count immediately after this
function returns. */
file->f_op = &ieee1394_chardev_ops;
+
+ /* if the open() failed, then we need to drop the
+ extra reference we gave to the task-specific
+ driver */
+ module_put(module);
+
}
return retval;
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 949a9497b0b5..337124784e9c 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -91,8 +91,7 @@ capi_ctr_get(struct capi_ctr *card)
static inline void
capi_ctr_put(struct capi_ctr *card)
{
- if (card->owner)
- __MOD_DEC_USE_COUNT(card->owner);
+ module_put(card->owner);
DBG("MOD_COUNT DEC");
}
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 6bf8310ac1e9..886302cbd2b1 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -44,11 +44,11 @@ static struct tt_internal *get_target_type(const char *name)
read_lock(&_lock);
ti = __find_target_type(name);
-
- if (ti) {
- if (ti->use == 0 && ti->tt.module)
- __MOD_INC_USE_COUNT(ti->tt.module);
- ti->use++;
+ if (ti && ti->use == 0) {
+ if (try_module_get(ti->tt.module))
+ ti->use++;
+ else
+ ti = NULL;
}
read_unlock(&_lock);
@@ -86,8 +86,8 @@ void dm_put_target_type(struct target_type *t)
struct tt_internal *ti = (struct tt_internal *) t;
read_lock(&_lock);
- if (--ti->use == 0 && ti->tt.module)
- __MOD_DEC_USE_COUNT(ti->tt.module);
+ if (--ti->use == 0)
+ module_put(ti->tt.module);
if (ti->use < 0)
BUG();
diff --git a/drivers/media/dvb/dvb-core/dvb_i2c.c b/drivers/media/dvb/dvb-core/dvb_i2c.c
index e9a48ba1af9f..9eefbf4513d1 100644
--- a/drivers/media/dvb/dvb-core/dvb_i2c.c
+++ b/drivers/media/dvb/dvb-core/dvb_i2c.c
@@ -63,18 +63,11 @@ int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
static
void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{
- if (dev->owner) {
- if (!MOD_CAN_QUERY(dev->owner))
- return;
-
- __MOD_INC_USE_COUNT(dev->owner);
- }
-
- if (dev->attach (i2c) == 0) {
- register_i2c_client (i2c, dev);
- } else {
- if (dev->owner)
- __MOD_DEC_USE_COUNT(dev->owner);
+ if (try_module_get(dev->owner)) {
+ if (dev->attach(i2c) == 0)
+ register_i2c_client(i2c, dev);
+ else
+ module_put(dev->owner);
}
}
@@ -82,10 +75,8 @@ void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
static
void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{
- dev->detach (i2c);
-
- if (dev->owner)
- __MOD_DEC_USE_COUNT(dev->owner);
+ dev->detach(i2c);
+ module_put(dev->owner);
}
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 1abef42a5896..bcc26db53c6a 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -3158,8 +3158,7 @@ static int reset_camera(struct cam_data *cam)
static void put_cam(struct cpia_camera_ops* ops)
{
- if (ops->owner)
- __MOD_DEC_USE_COUNT(ops->owner);
+ module_put(ops->owner);
}
/* ------------------------- V4L interface --------------------- */
diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c
index da5512cd14e3..efdd7ee41d34 100644
--- a/drivers/mtd/chips/chipreg.c
+++ b/drivers/mtd/chips/chipreg.c
@@ -71,15 +71,13 @@ struct mtd_info *do_map_probe(char *name, struct map_info *map)
return NULL;
ret = drv->probe(map);
-#ifdef CONFIG_MODULES
+
/* We decrease the use count here. It may have been a
probe-only module, which is no longer required from this
point, having given us a handle on (and increased the use
count of) the actual driver code.
*/
- if(drv->module)
- __MOD_DEC_USE_COUNT(drv->module);
-#endif
+ module_put(drv->module);
if (ret)
return ret;
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index a73fe2c3db70..a27737026547 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -502,8 +502,7 @@ errout_stop:
errout_free:
sirdev_free_buffers(dev);
errout_dec:
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);
+ module_put(drv->owner);
return -EAGAIN;
}
@@ -533,11 +532,7 @@ static int sirdev_close(struct net_device *ndev)
drv->stop_dev(dev);
sirdev_free_buffers(dev);
-
- lock_kernel();
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);
- unlock_kernel();
+ module_put(drv->owner);
out:
dev->speed = 0;
diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c
index 6384215dc27e..cf7a17a002d3 100644
--- a/drivers/net/irda/sir_dongle.c
+++ b/drivers/net/irda/sir_dongle.c
@@ -121,8 +121,7 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type)
out_reject:
dev->dongle_drv = NULL;
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);
+ module_put(drv->owner);
out_unlock:
up(&dongle_list_lock);
return err;
@@ -137,9 +136,7 @@ int sirdev_put_dongle(struct sir_dev *dev)
drv->close(dev); /* close this dongle instance */
dev->dongle_drv = NULL; /* unlink the dongle driver */
-
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);/* decrement driver's module refcount */
+ module_put(drv->owner);/* decrement driver's module refcount */
}
return 0;
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 6f0cfa5c66bc..8eedee623a04 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1757,8 +1757,7 @@ dasd_release(struct inode *inp, struct file *filp)
}
if (atomic_dec_return(&device->open_count) == 0) {
invalidate_buffers(inp->i_rdev);
- if (device->discipline->owner)
- __MOD_DEC_USE_COUNT(device->discipline->owner);
+ module_put(device->discipline->owner);
}
return 0;
}
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index def999eb4334..9047d68fb20a 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -115,7 +115,7 @@ dasd_ioctl(struct inode *inp, struct file *filp,
if (try_inc_mod_count(ioctl->owner) != 0)
continue;
rc = ioctl->handler(bdev, no, data);
- __MOD_DEC_USE_COUNT(ioctl->owner);
+ module_put(ioctl->owner);
} else
rc = ioctl->handler(bdev, no, data);
return rc;
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 23c48e2e6381..af71fadf2f52 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -857,8 +857,7 @@ tape_release(struct tape_device *device)
spin_lock(get_ccwdev_lock(device->cdev));
if (device->tape_state == TS_IN_USE)
tape_state_set(device, TS_UNUSED);
- if (device->discipline->owner)
- __MOD_DEC_USE_COUNT(device->discipline->owner);
+ module_put(device->discipline->owner);
spin_unlock(get_ccwdev_lock(device->cdev));
return 0;
}
diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c
index ffeacdf56718..f8d8fa5adfb6 100644
--- a/drivers/scsi/fcal.c
+++ b/drivers/scsi/fcal.c
@@ -138,10 +138,14 @@ int __init fcal_detect(Scsi_Host_Template *tpnt)
continue;
}
+ if (!try_module_get(fc->module)) {
+ kfree(ages);
+ scsi_unregister(host);
+ continue;
+ }
+
nfcals++;
- if (fc->module) __MOD_INC_USE_COUNT(fc->module);
-
fcal = (struct fcal *)host->hostdata;
fc->fcp_register(fc, TYPE_SCSI_FCP, 0);
@@ -193,7 +197,7 @@ int fcal_release(struct Scsi_Host *host)
struct fcal *fcal = (struct fcal *)host->hostdata;
fc_channel *fc = fcal->fc;
- if (fc->module) __MOD_DEC_USE_COUNT(fc->module);
+ module_put(fc->module);
fc->fcp_register(fc, TYPE_SCSI_FCP, 1);
FCALND((" releasing fcal.\n"));
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index 84024bc0adb9..3c3452557f8b 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -232,10 +232,14 @@ int __init pluto_detect(Scsi_Host_Template *tpnt)
continue;
}
+ if (!try_module_get(fc->module)) {
+ kfree(ages);
+ scsi_unregister(host);
+ continue;
+ }
+
nplutos++;
- if (fc->module) __MOD_INC_USE_COUNT(fc->module);
-
pluto = (struct pluto *)host->hostdata;
host->max_id = inq->targets;
diff --git a/drivers/serial/core.c b/drivers/serial/core.c
index aacb4225f2e6..4e4c736318bb 100644
--- a/drivers/serial/core.c
+++ b/drivers/serial/core.c
@@ -1294,8 +1294,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
wake_up_interruptible(&info->open_wait);
done:
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);
+ module_put(drv->owner);
}
static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
@@ -1665,8 +1664,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
return retval;
out:
- if (drv->owner)
- __MOD_DEC_USE_COUNT(drv->owner);
+ module_put(drv->owner);
fail:
return retval;
}
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index 272b32873d7e..6d3c093afa1d 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -3278,19 +3278,23 @@ request_decompressor(struct usb_ov511 *ov)
err("Unknown bridge");
}
- if (ov->decomp_ops) {
- if (!ov->decomp_ops->owner) {
- ov->decomp_ops = NULL;
- unlock_kernel();
- return -ENOSYS;
- }
- __MOD_INC_USE_COUNT(ov->decomp_ops->owner);
- unlock_kernel();
- return 0;
- } else {
- unlock_kernel();
- return -ENOSYS;
+ if (!ov->decomp_ops)
+ goto nosys;
+
+ if (!ov->decomp_ops->owner) {
+ ov->decomp_ops = NULL;
+ goto nosys;
}
+
+ if (!try_module_get(ov->decomp_ops->owner))
+ goto nosys;
+
+ unlock_kernel();
+ return 0;
+
+ nosys:
+ unlock_kernel();
+ return -ENOSYS;
}
/* Unlocks decompression module and nulls ov->decomp_ops. Safe to call even
@@ -3306,8 +3310,8 @@ release_decompressor(struct usb_ov511 *ov)
lock_kernel();
- if (ov->decomp_ops && ov->decomp_ops->owner) {
- __MOD_DEC_USE_COUNT(ov->decomp_ops->owner);
+ if (ov->decomp_ops) {
+ module_put(ov->decomp_ops->owner);
released = 1;
}
diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
index 6620d403ba9c..4c81b621ff76 100644
--- a/drivers/usb/media/usbvideo.c
+++ b/drivers/usb/media/usbvideo.c
@@ -730,6 +730,7 @@ EXPORT_SYMBOL(usbvideo_SayAndWait);
/* ******************************************************************** */
+/* XXX: this piece of crap really wants some error handling.. */
static void usbvideo_ClientIncModCount(struct uvd *uvd)
{
if (uvd == NULL) {
@@ -744,7 +745,10 @@ static void usbvideo_ClientIncModCount(struct uvd *uvd)
err("%s: uvd->handle->md_module == NULL", __FUNCTION__);
return;
}
- __MOD_INC_USE_COUNT(uvd->handle->md_module);
+ if (!try_module_get(uvd->handle->md_module)) {
+ err("%s: try_module_get() == 0", __FUNCTION__);
+ return;
+ }
}
static void usbvideo_ClientDecModCount(struct uvd *uvd)
@@ -761,7 +765,7 @@ static void usbvideo_ClientDecModCount(struct uvd *uvd)
err("%s: uvd->handle->md_module == NULL", __FUNCTION__);
return;
}
- __MOD_DEC_USE_COUNT(uvd->handle->md_module);
+ module_put(uvd->handle->md_module);
}
int usbvideo_register(
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index 94ffed22315b..ad8dfcbda17d 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -81,10 +81,7 @@ static inline void map_destroy(struct mtd_info *mtd)
if (map->fldrv->destroy)
map->fldrv->destroy(mtd);
-#ifdef CONFIG_MODULES
- if (map->fldrv->module)
- __MOD_DEC_USE_COUNT(map->fldrv->module);
-#endif
+ module_put(map->fldrv->module);
kfree(mtd);
}
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ae5bfe3e10fb..52d38241e91e 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -224,8 +224,7 @@ static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
static inline void put_mtd_device(struct mtd_info *mtd)
{
- if (mtd->module)
- __MOD_DEC_USE_COUNT(mtd->module);
+ module_put(mtd->module);
}
diff --git a/net/core/dev.c b/net/core/dev.c
index e48cb774fe0f..97e772ff5f82 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -703,8 +703,7 @@ int dev_open(struct net_device *dev)
ret = dev->open(dev);
if (ret) {
clear_bit(__LINK_STATE_START, &dev->state);
- if (dev->owner)
- __MOD_DEC_USE_COUNT(dev->owner);
+ module_put(dev->owner);
}
}
} else {
@@ -829,16 +828,14 @@ int dev_close(struct net_device *dev)
#endif
/*
- * Tell people we are down
+ * Tell people we are down
*/
notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev);
/*
* Drop the module refcount
*/
- if (dev->owner)
- __MOD_DEC_USE_COUNT(dev->owner);
-
+ module_put(dev->owner);
return 0;
}
diff --git a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c
index d21d597e7be1..fe30556f78d6 100644
--- a/net/ipv4/xfrm_policy.c
+++ b/net/ipv4/xfrm_policy.c
@@ -200,8 +200,7 @@ struct xfrm_type *xfrm_get_type(u8 proto)
void xfrm_put_type(struct xfrm_type *type)
{
- if (type->owner)
- __MOD_DEC_USE_COUNT(type->owner);
+ module_put(type->owner);
}
static inline unsigned long make_jiffies(long secs)
diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c
index 6bba546eece7..a0e81b58191d 100644
--- a/net/rxrpc/call.c
+++ b/net/rxrpc/call.c
@@ -435,7 +435,7 @@ void rxrpc_put_call(struct rxrpc_call *call)
rxrpc_put_message(msg);
}
- if (call->owner) __MOD_DEC_USE_COUNT(call->owner);
+ module_put(call->owner);
down_write(&rxrpc_calls_sem);
list_del(&call->call_link);
diff --git a/sound/core/control.c b/sound/core/control.c
index 6dce340429ff..7de5256c19fc 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -40,12 +40,6 @@ typedef struct _snd_kctl_ioctl {
static DECLARE_RWSEM(snd_ioctl_rwsem);
static LIST_HEAD(snd_control_ioctls);
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
static int snd_ctl_open(struct inode *inode, struct file *file)
{
int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
@@ -88,7 +82,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
return 0;
__error:
- dec_mod_count(card->module);
+ module_put(card->module);
__error2:
snd_card_file_remove(card, file);
__error1:
@@ -135,7 +129,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
up_write(&card->controls_rwsem);
snd_ctl_empty_read_queue(ctl);
snd_magic_kfree(ctl);
- dec_mod_count(card->module);
+ module_put(card->module);
snd_card_file_remove(card, file);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
diff --git a/sound/core/info.c b/sound/core/info.c
index 808f46456976..0ae2541810a6 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -36,12 +36,6 @@
*
*/
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
int snd_info_check_reserved_words(const char *str)
{
static char *reserved[] =
@@ -407,7 +401,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
return 0;
__error:
- dec_mod_count(entry->module);
+ module_put(entry->module);
__error1:
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
@@ -450,7 +444,7 @@ static int snd_info_entry_release(struct inode *inode, struct file *file)
data->file_private_data);
break;
}
- dec_mod_count(entry->module);
+ module_put(entry->module);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
#endif
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 0d6aecd9016c..088bf5ea33c1 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -34,12 +34,6 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("Mixer OSS emulation for ALSA.");
MODULE_LICENSE("GPL");
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
static int snd_mixer_oss_open(struct inode *inode, struct file *file)
{
int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
@@ -82,7 +76,7 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file)
if (file->private_data) {
fmixer = (snd_mixer_oss_file_t *) file->private_data;
- dec_mod_count(fmixer->card->module);
+ module_put(fmixer->card->module);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
#endif
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index c6e18a7e0d0a..4febec2769c2 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -71,12 +71,6 @@ static inline void snd_leave_user(mm_segment_t fs)
set_fs(fs);
}
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream)
{
snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1617,7 +1611,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
return err;
__error:
- dec_mod_count(pcm->card->module);
+ module_put(pcm->card->module);
__error2:
snd_card_file_remove(pcm->card, file);
__error1:
@@ -1644,7 +1638,7 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
snd_pcm_oss_release_file(pcm_oss_file);
up(&pcm->open_mutex);
wake_up(&pcm->open_wait);
- dec_mod_count(pcm->card->module);
+ module_put(pcm->card->module);
snd_card_file_remove(pcm->card, file);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 773d3a10c567..57f2a9c0f4a2 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -76,14 +76,6 @@ static inline void snd_leave_user(mm_segment_t fs)
set_fs(fs);
}
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
-
-
int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info)
{
snd_pcm_runtime_t * runtime;
@@ -1833,7 +1825,7 @@ int snd_pcm_open(struct inode *inode, struct file *file)
return err;
__error:
- dec_mod_count(pcm->card->module);
+ module_put(pcm->card->module);
__error2:
snd_card_file_remove(pcm->card, file);
__error1:
@@ -1863,7 +1855,7 @@ int snd_pcm_release(struct inode *inode, struct file *file)
snd_pcm_release_file(pcm_file);
up(&pcm->open_mutex);
wake_up(&pcm->open_wait);
- dec_mod_count(pcm->card->module);
+ module_put(pcm->card->module);
snd_card_file_remove(pcm->card, file);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 18dc962f094d..a03924780f93 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -58,12 +58,6 @@ snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES];
static DECLARE_MUTEX(register_mutex);
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
static inline unsigned short snd_rawmidi_file_flags(struct file *file)
{
switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) {
@@ -345,7 +339,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice,
snd_rawmidi_done_buffer(output);
kfree(output);
}
- dec_mod_count(rmidi->card->module);
+ module_put(rmidi->card->module);
up(&rmidi->open_mutex);
__error1:
#ifdef LINUX_2_2
@@ -504,7 +498,7 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile)
rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--;
}
up(&rmidi->open_mutex);
- dec_mod_count(rmidi->card->module);
+ module_put(rmidi->card->module);
#ifdef LINUX_2_2
MOD_DEC_USE_COUNT;
#endif
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index 9cc61a3cd426..837ef15abb69 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -83,12 +83,6 @@ static spinlock_t register_lock = SPIN_LOCK_UNLOCKED;
static seq_oss_synth_t *get_synthdev(seq_oss_devinfo_t *dp, int dev);
static void reset_channels(seq_oss_synthinfo_t *info);
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
/*
* global initialization
*/
@@ -245,7 +239,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp)
continue;
}
if (rec->oper.open(&info->arg, rec->private_data) < 0) {
- dec_mod_count(rec->oper.owner);
+ module_put(rec->oper.owner);
snd_use_lock_free(&rec->use_lock);
continue;
}
@@ -322,7 +316,7 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp)
if (rec->opened) {
debug_printk(("synth %d closed\n", i));
rec->oper.close(&info->arg);
- dec_mod_count(rec->oper.owner);
+ module_put(rec->oper.owner);
rec->opened--;
}
snd_use_lock_free(&rec->use_lock);
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 8f5d7ed2b4d8..14943f8fecb8 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -55,12 +55,6 @@ much elements are in array.
*/
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
/* return pointer to port structure - port is locked if found */
client_port_t *snd_seq_port_use_ptr(client_t *client, int num)
{
@@ -413,7 +407,7 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_
if (grp->open && (port->callback_all || grp->count == 1)) {
err = grp->open(port->private_data, info);
if (err < 0) {
- dec_mod_count(port->owner);
+ module_put(port->owner);
grp->count--;
}
}
@@ -438,7 +432,7 @@ static int unsubscribe_port(client_t *client, client_port_t *port,
if (send_ack && client->type == USER_CLIENT)
snd_seq_client_notify_subscription(port->addr.client, port->addr.port,
info, SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED);
- dec_mod_count(port->owner);
+ module_put(port->owner);
return err;
}
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index d4fcb6aa085c..0719b6ad0ee8 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -53,12 +53,6 @@ MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("Virtual Raw MIDI client on Sequencer");
MODULE_LICENSE("GPL");
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
/*
* initialize an event record
*/
@@ -303,7 +297,7 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t
rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL);
rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE;
- dec_mod_count(rdev->card->module);
+ module_put(rdev->card->module);
return 0;
}
@@ -331,7 +325,7 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info)
rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL);
rdev->flags &= ~SNDRV_VIRMIDI_USE;
- dec_mod_count(rdev->card->module);
+ module_put(rdev->card->module);
return 0;
}
diff --git a/sound/core/timer.c b/sound/core/timer.c
index e16dfdda8a95..1b571b00728d 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -80,12 +80,6 @@ static int snd_timer_dev_unregister(snd_device_t *device);
static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left);
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
/*
* create a timer instance with the given owner string.
* when timer is not NULL, increments the module counter
@@ -325,7 +319,7 @@ int snd_timer_close(snd_timer_instance_t * timeri)
kfree(timeri->owner);
kfree(timeri);
if (timer && timer->card)
- dec_mod_count(timer->card->module);
+ module_put(timer->card->module);
return 0;
}
diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
index 2651522d72e5..c622456c6136 100644
--- a/sound/drivers/opl3/opl3_seq.c
+++ b/sound/drivers/opl3/opl3_seq.c
@@ -35,12 +35,6 @@ int use_internal_drums = 0;
MODULE_PARM(use_internal_drums, "i");
MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums.");
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
int snd_opl3_synth_use_inc(opl3_t * opl3)
{
if (!try_inc_mod_count(opl3->card->module))
@@ -51,7 +45,7 @@ int snd_opl3_synth_use_inc(opl3_t * opl3)
void snd_opl3_synth_use_dec(opl3_t * opl3)
{
- dec_mod_count(opl3->card->module);
+ module_put(opl3->card->module);
}
int snd_opl3_synth_setup(opl3_t * opl3)
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 04fa4a649ab6..a3473afd0118 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -39,12 +39,6 @@ MODULE_LICENSE("GPL");
static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches);
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
int snd_gus_use_inc(snd_gus_card_t * gus)
{
MOD_INC_USE_COUNT;
@@ -57,7 +51,7 @@ int snd_gus_use_inc(snd_gus_card_t * gus)
void snd_gus_use_dec(snd_gus_card_t * gus)
{
- dec_mod_count(gus->card->module);
+ module_put(gus->card->module);
MOD_DEC_USE_COUNT;
}
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index 75aaca8a9fb9..817b6d807a86 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -33,13 +33,6 @@
#define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */
#define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */
-static inline void
-dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
static int
wavefront_fx_idle (snd_wavefront_t *dev)
@@ -164,7 +157,7 @@ int
snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file)
{
- dec_mod_count(hw->card->module);
+ module_put(hw->card->module);
MOD_DEC_USE_COUNT;
return 0;
}
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index 5f0058dc08ca..f3e26ef9473f 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -233,13 +233,6 @@ static wavefront_command wavefront_commands[] = {
{ 0x00 }
};
-static inline void
-dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
static const char *
wavefront_errorstr (int errnum)
@@ -1623,7 +1616,7 @@ int
snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file)
{
- dec_mod_count(hw->card->module);
+ module_put(hw->card->module);
MOD_DEC_USE_COUNT;
return 0;
}
diff --git a/sound/oss/audio.c b/sound/oss/audio.c
index 74e3c282c14f..91101d990e49 100644
--- a/sound/oss/audio.c
+++ b/sound/oss/audio.c
@@ -88,19 +88,20 @@ int audio_open(int dev, struct file *file)
return -ENXIO;
driver = audio_devs[dev]->d;
- if (driver->owner)
- __MOD_INC_USE_COUNT(driver->owner);
+
+ if (!try_module_get(driver->owner))
+ return -ENODEV;
if ((ret = DMAbuf_open(dev, mode)) < 0)
goto error_1;
if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) {
- if (coprocessor->owner)
- __MOD_INC_USE_COUNT(coprocessor->owner);
+ if (!try_module_get(coprocessor->owner))
+ goto error_2;
if ((ret = coprocessor->open(coprocessor->devc, COPR_PCM)) < 0) {
printk(KERN_WARNING "Sound: Can't access coprocessor device\n");
- goto error_2;
+ goto error_3;
}
}
@@ -119,14 +120,14 @@ int audio_open(int dev, struct file *file)
* Clean-up stack: this is what needs (un)doing if
* we can't open the audio device ...
*/
+ error_3:
+ module_put(coprocessor->owner);
+
error_2:
- if (coprocessor->owner)
- __MOD_DEC_USE_COUNT(coprocessor->owner);
DMAbuf_release(dev, mode);
error_1:
- if (driver->owner)
- __MOD_DEC_USE_COUNT(driver->owner);
+ module_put(driver->owner);
return ret;
}
@@ -200,14 +201,11 @@ void audio_release(int dev, struct file *file)
if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) {
coprocessor->close(coprocessor->devc, COPR_PCM);
-
- if (coprocessor->owner)
- __MOD_DEC_USE_COUNT(coprocessor->owner);
+ module_put(coprocessor->owner);
}
DMAbuf_release(dev, mode);
- if (audio_devs[dev]->d->owner)
- __MOD_DEC_USE_COUNT (audio_devs[dev]->d->owner);
+ module_put(audio_devs[dev]->d->owner);
}
static void translate_bytes(const unsigned char *table, unsigned char *buff, int n)
diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c
index 58b330ecad1f..30f8c7f67971 100644
--- a/sound/oss/midibuf.c
+++ b/sound/oss/midibuf.c
@@ -170,8 +170,7 @@ int MIDIbuf_open(int dev, struct file *file)
* Interrupts disabled. Be careful
*/
- if (midi_devs[dev]->owner)
- __MOD_INC_USE_COUNT (midi_devs[dev]->owner);
+ module_put(midi_devs[dev]->owner);
if ((err = midi_devs[dev]->open(dev, mode,
midi_input_intr, midi_output_intr)) < 0)
@@ -254,8 +253,7 @@ void MIDIbuf_release(int dev, struct file *file)
midi_in_buf[dev] = NULL;
midi_out_buf[dev] = NULL;
- if (midi_devs[dev]->owner)
- __MOD_DEC_USE_COUNT (midi_devs[dev]->owner);
+ module_put(midi_devs[dev]->owner);
}
int MIDIbuf_write(int dev, struct file *file, const char *buf, int count)
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
index a8817a2d8d02..c8d9d59ef915 100644
--- a/sound/oss/mpu401.c
+++ b/sound/oss/mpu401.c
@@ -498,8 +498,10 @@ static int mpu401_open(int dev, int mode,
if ( (coprocessor = midi_devs[dev]->coproc) != NULL )
{
- if (coprocessor->owner)
- __MOD_INC_USE_COUNT(coprocessor->owner);
+ if (!try_module_get(coprocessor->owner)) {
+ mpu401_close(dev);
+ return err;
+ }
if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0)
{
@@ -537,9 +539,7 @@ static void mpu401_close(int dev)
coprocessor = midi_devs[dev]->coproc;
if (coprocessor) {
coprocessor->close(coprocessor->devc, COPR_MIDI);
-
- if (coprocessor->owner)
- __MOD_DEC_USE_COUNT(coprocessor->owner);
+ module_put(coprocessor->owner);
}
devc->opened = 0;
}
@@ -838,8 +838,8 @@ static int mpu_synth_open(int dev, int mode)
coprocessor = midi_devs[midi_dev]->coproc;
if (coprocessor) {
- if (coprocessor->owner)
- __MOD_INC_USE_COUNT(coprocessor->owner);
+ if (!try_module_get(coprocessor->owner))
+ return err;
if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0)
{
@@ -876,9 +876,7 @@ static void mpu_synth_close(int dev)
coprocessor = midi_devs[midi_dev]->coproc;
if (coprocessor) {
coprocessor->close(coprocessor->devc, COPR_MIDI);
-
- if (coprocessor->owner)
- __MOD_DEC_USE_COUNT(coprocessor->owner);
+ module_put(coprocessor->owner);
}
devc->opened = 0;
devc->mode = 0;
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 860e21734e9e..8a2f0055f1ac 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -1041,8 +1041,8 @@ int sequencer_open(int dev, struct file *file)
if (synth_devs[i]==NULL)
continue;
- if (synth_devs[i]->owner)
- __MOD_INC_USE_COUNT (synth_devs[i]->owner);
+ if (!try_module_get(synth_devs[i]->owner))
+ continue;
if ((tmp = synth_devs[i]->open(i, mode)) < 0)
{
@@ -1072,8 +1072,8 @@ int sequencer_open(int dev, struct file *file)
for (i = 0; i < max_mididev; i++)
if (!midi_opened[i] && midi_devs[i])
{
- if (midi_devs[i]->owner)
- __MOD_INC_USE_COUNT (midi_devs[i]->owner);
+ if (!try_module_get(midi_devs[i]->owner))
+ continue;
if ((retval = midi_devs[i]->open(i, mode,
sequencer_midi_input, sequencer_midi_output)) >= 0)
@@ -1084,9 +1084,8 @@ int sequencer_open(int dev, struct file *file)
}
if (seq_mode == SEQ_2) {
- if (tmr->owner)
- __MOD_INC_USE_COUNT (tmr->owner);
- tmr->open(tmr_no, seq_mode);
+ if (try_module_get(tmr->owner))
+ tmr->open(tmr_no, seq_mode);
}
init_waitqueue_head(&seq_sleeper);
@@ -1169,8 +1168,7 @@ void sequencer_release(int dev, struct file *file)
{
synth_devs[i]->close(i);
- if (synth_devs[i]->owner)
- __MOD_DEC_USE_COUNT (synth_devs[i]->owner);
+ module_put(synth_devs[i]->owner);
if (synth_devs[i]->midi_dev)
midi_opened[synth_devs[i]->midi_dev] = 0;
@@ -1181,15 +1179,13 @@ void sequencer_release(int dev, struct file *file)
{
if (midi_opened[i]) {
midi_devs[i]->close(i);
- if (midi_devs[i]->owner)
- __MOD_DEC_USE_COUNT (midi_devs[i]->owner);
+ module_put(midi_devs[i]->owner);
}
}
if (seq_mode == SEQ_2) {
tmr->close(tmr_no);
- if (tmr->owner)
- __MOD_DEC_USE_COUNT (tmr->owner);
+ module_put(tmr->owner);
}
if (obsolete_api_used)
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 4d29d0ec11a5..89988a1b3814 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -222,9 +222,9 @@ static int sound_open(struct inode *inode, struct file *file)
}
if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL))
return -ENXIO;
-
- if (mixer_devs[dev]->owner)
- __MOD_INC_USE_COUNT (mixer_devs[dev]->owner);
+
+ if (!try_module_get(mixer_devs[dev]->owner))
+ return -ENXIO;
break;
case SND_DEV_SEQ:
@@ -261,9 +261,7 @@ static int sound_release(struct inode *inode, struct file *file)
DEB(printk("sound_release(dev=%d)\n", dev));
switch (dev & 0x0f) {
case SND_DEV_CTL:
- dev >>= 4;
- if (mixer_devs[dev]->owner)
- __MOD_DEC_USE_COUNT (mixer_devs[dev]->owner);
+ module_put(mixer_devs[dev >> 4]->owner);
break;
case SND_DEV_SEQ:
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index 3175511d87f9..0dd6ef8c376c 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -61,12 +61,6 @@ static snd_midi_op_t emux_ops = {
/*
*/
-static inline void dec_mod_count(struct module *module)
-{
- if (module)
- __MOD_DEC_USE_COUNT(module);
-}
-
/*
* Initialise the EMUX Synth by creating a client and registering
* a series of ports.
@@ -283,7 +277,7 @@ snd_emux_inc_count(snd_emux_t *emu)
if (!try_inc_mod_count(emu->ops.owner))
goto __error;
if (!try_inc_mod_count(emu->card->module)) {
- dec_mod_count(emu->ops.owner);
+ module_put(emu->ops.owner);
__error:
emu->used--;
return 0;
@@ -298,11 +292,11 @@ snd_emux_inc_count(snd_emux_t *emu)
void
snd_emux_dec_count(snd_emux_t *emu)
{
- dec_mod_count(emu->ops.owner);
+ module_put(emu->ops.owner);
emu->used--;
if (emu->used <= 0)
snd_emux_terminate_all(emu);
- dec_mod_count(emu->card->module);
+ module_put(emu->card->module);
}