diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 21:49:54 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 21:49:54 +0400 |
commit | c37927d4359e81b85de644f8fb08878717cf5f3f (patch) | |
tree | 25dabf2d905e1410819d1bdaba0bf5f779100d3c | |
parent | 5704e44d283e907623e3775c1262f206a2c48cf3 (diff) | |
parent | 2a48fc0ab24241755dc93bfd4f01d68efab47f5a (diff) | |
download | linux-c37927d4359e81b85de644f8fb08878717cf5f3f.tar.xz |
Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl
* 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl:
block: autoconvert trivial BKL users to private mutex
drivers: autoconvert trivial BKL users to private mutex
ipmi: autoconvert trivial BKL users to private mutex
mac: autoconvert trivial BKL users to private mutex
mtd: autoconvert trivial BKL users to private mutex
scsi: autoconvert trivial BKL users to private mutex
Fix up trivial conflicts (due to addition of private mutex right next to
deletion of a version string) in drivers/char/pcmcia/cm40[04]0_cs.c
100 files changed, 614 insertions, 556 deletions
diff --git a/block/bsg.c b/block/bsg.c index 0c00870553a3..d3afe702ede7 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -20,7 +20,6 @@ #include <linux/uio.h> #include <linux/idr.h> #include <linux/bsg.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <scsi/scsi.h> @@ -843,9 +842,7 @@ static int bsg_open(struct inode *inode, struct file *file) { struct bsg_device *bd; - lock_kernel(); bd = bsg_get_device(inode, file); - unlock_kernel(); if (IS_ERR(bd)) return PTR_ERR(bd); diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 4e2c367fec11..da0f6ddd7621 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -36,7 +36,7 @@ #include <linux/ioport.h> #include <linux/mm.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/reboot.h> @@ -54,6 +54,7 @@ #define DAC960_GAM_MINOR 252 +static DEFINE_MUTEX(DAC960_mutex); static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; static int DAC960_ControllerCount; static struct proc_dir_entry *DAC960_ProcDirectoryEntry; @@ -81,7 +82,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) int drive_nr = (long)disk->private_data; int ret = -ENXIO; - lock_kernel(); + mutex_lock(&DAC960_mutex); if (p->FirmwareType == DAC960_V1_Controller) { if (p->V1.LogicalDriveInformation[drive_nr]. LogicalDriveState == DAC960_V1_LogicalDrive_Offline) @@ -99,7 +100,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) goto out; ret = 0; out: - unlock_kernel(); + mutex_unlock(&DAC960_mutex); return ret; } @@ -6625,7 +6626,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, long ErrorCode = 0; if (!capable(CAP_SYS_ADMIN)) return -EACCES; - lock_kernel(); + mutex_lock(&DAC960_mutex); switch (Request) { case DAC960_IOCTL_GET_CONTROLLER_COUNT: @@ -7056,7 +7057,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, default: ErrorCode = -ENOTTY; } - unlock_kernel(); + mutex_unlock(&DAC960_mutex); return ErrorCode; } diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 76f114f0bba3..4b852c962266 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -60,7 +60,7 @@ #include <linux/hdreg.h> #include <linux/delay.h> #include <linux/init.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/amifdreg.h> #include <linux/amifd.h> #include <linux/buffer_head.h> @@ -109,6 +109,7 @@ #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ +static DEFINE_MUTEX(amiflop_mutex); static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ module_param(fd_def_df0, ulong, 0); @@ -1506,9 +1507,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&amiflop_mutex); ret = fd_locked_ioctl(bdev, mode, cmd, param); - unlock_kernel(); + mutex_unlock(&amiflop_mutex); return ret; } @@ -1555,11 +1556,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) int old_dev; unsigned long flags; - lock_kernel(); + mutex_lock(&amiflop_mutex); old_dev = fd_device[drive]; if (fd_ref[drive] && old_dev != system) { - unlock_kernel(); + mutex_unlock(&amiflop_mutex); return -EBUSY; } @@ -1575,7 +1576,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) rel_fdc(); if (wrprot) { - unlock_kernel(); + mutex_unlock(&amiflop_mutex); return -EROFS; } } @@ -1594,7 +1595,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, unit[drive].type->name, data_types[system].name); - unlock_kernel(); + mutex_unlock(&amiflop_mutex); return 0; } @@ -1603,7 +1604,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) struct amiga_floppy_struct *p = disk->private_data; int drive = p - unit; - lock_kernel(); + mutex_lock(&amiflop_mutex); if (unit[drive].dirty == 1) { del_timer (flush_track_timer + drive); non_int_flush_track (drive); @@ -1617,7 +1618,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) /* the mod_use counter is handled this way */ floppy_off (drive | 0x40000000); #endif - unlock_kernel(); + mutex_unlock(&amiflop_mutex); return 0; } diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index a946929735a5..f21c237a9e5e 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -12,9 +12,10 @@ #include <linux/slab.h> #include <linux/genhd.h> #include <linux/netdevice.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include "aoe.h" +static DEFINE_MUTEX(aoeblk_mutex); static struct kmem_cache *buf_pool_cache; static ssize_t aoedisk_show_state(struct device *dev, @@ -125,16 +126,16 @@ aoeblk_open(struct block_device *bdev, fmode_t mode) struct aoedev *d = bdev->bd_disk->private_data; ulong flags; - lock_kernel(); + mutex_lock(&aoeblk_mutex); spin_lock_irqsave(&d->lock, flags); if (d->flags & DEVFL_UP) { d->nopen++; spin_unlock_irqrestore(&d->lock, flags); - unlock_kernel(); + mutex_unlock(&aoeblk_mutex); return 0; } spin_unlock_irqrestore(&d->lock, flags); - unlock_kernel(); + mutex_unlock(&aoeblk_mutex); return -ENODEV; } diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index 4a1b9e7464aa..05d5ef172ca5 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c @@ -9,7 +9,7 @@ #include <linux/completion.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/skbuff.h> #include "aoe.h" @@ -37,6 +37,7 @@ struct ErrMsg { char *msg; }; +static DEFINE_MUTEX(aoechr_mutex); static struct ErrMsg emsgs[NMSG]; static int emsgs_head_idx, emsgs_tail_idx; static struct completion emsgs_comp; @@ -183,16 +184,16 @@ aoechr_open(struct inode *inode, struct file *filp) { int n, i; - lock_kernel(); + mutex_lock(&aoechr_mutex); n = iminor(inode); filp->private_data = (void *) (unsigned long) n; for (i = 0; i < ARRAY_SIZE(chardevs); ++i) if (chardevs[i].minor == n) { - unlock_kernel(); + mutex_unlock(&aoechr_mutex); return 0; } - unlock_kernel(); + mutex_unlock(&aoechr_mutex); return -EINVAL; } diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index aceb96476524..8c021bb7a991 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -67,7 +67,7 @@ #include <linux/delay.h> #include <linux/init.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/atafd.h> #include <asm/atafdreg.h> @@ -79,6 +79,7 @@ #undef DEBUG +static DEFINE_MUTEX(ataflop_mutex); static struct request_queue *floppy_queue; static struct request *fd_request; @@ -1671,9 +1672,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&ataflop_mutex); ret = fd_locked_ioctl(bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&ataflop_mutex); return ret; } @@ -1854,9 +1855,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&ataflop_mutex); ret = floppy_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&ataflop_mutex); return ret; } @@ -1864,14 +1865,14 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) static int floppy_release(struct gendisk *disk, fmode_t mode) { struct atari_floppy_struct *p = disk->private_data; - lock_kernel(); + mutex_lock(&ataflop_mutex); if (p->ref < 0) p->ref = 0; else if (!p->ref--) { printk(KERN_ERR "floppy_release with fd_ref == 0"); p->ref = 0; } - unlock_kernel(); + mutex_unlock(&ataflop_mutex); return 0; } diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 1c7f63792ff8..82bfd5bb4a97 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -15,7 +15,7 @@ #include <linux/blkdev.h> #include <linux/bio.h> #include <linux/highmem.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/radix-tree.h> #include <linux/buffer_head.h> /* invalidate_bh_lrus() */ #include <linux/slab.h> @@ -55,6 +55,7 @@ struct brd_device { /* * Look up and return a brd's page for a given sector. */ +static DEFINE_MUTEX(brd_mutex); static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) { pgoff_t idx; @@ -402,7 +403,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode, * ram device BLKFLSBUF has special semantics, we want to actually * release and destroy the ramdisk data. */ - lock_kernel(); + mutex_lock(&brd_mutex); mutex_lock(&bdev->bd_mutex); error = -EBUSY; if (bdev->bd_openers <= 1) { @@ -419,7 +420,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode, error = 0; } mutex_unlock(&bdev->bd_mutex); - unlock_kernel(); + mutex_unlock(&brd_mutex); return error; } diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 5e4fadcdece9..c484c96e22a6 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -26,7 +26,6 @@ #include <linux/pci.h> #include <linux/kernel.h> #include <linux/slab.h> -#include <linux/smp_lock.h> #include <linux/delay.h> #include <linux/major.h> #include <linux/fs.h> @@ -66,6 +65,7 @@ MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers"); MODULE_VERSION("3.6.26"); MODULE_LICENSE("GPL"); +static DEFINE_MUTEX(cciss_mutex); static int cciss_allow_hpsa; module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(cciss_allow_hpsa, @@ -1059,9 +1059,9 @@ static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&cciss_mutex); ret = cciss_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&cciss_mutex); return ret; } @@ -1074,13 +1074,13 @@ static int cciss_release(struct gendisk *disk, fmode_t mode) ctlr_info_t *h; drive_info_struct *drv; - lock_kernel(); + mutex_lock(&cciss_mutex); h = get_host(disk); drv = get_drv(disk); dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); drv->usage_count--; h->usage_count--; - unlock_kernel(); + mutex_unlock(&cciss_mutex); return 0; } @@ -1088,9 +1088,9 @@ static int do_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&cciss_mutex); ret = cciss_ioctl(bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&cciss_mutex); return ret; } diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index d53b0291c44b..946dad4caef3 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -35,7 +35,7 @@ #include <linux/seq_file.h> #include <linux/init.h> #include <linux/hdreg.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/spinlock.h> #include <linux/blkdev.h> #include <linux/genhd.h> @@ -68,6 +68,7 @@ MODULE_LICENSE("GPL"); #define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ +static DEFINE_MUTEX(cpqarray_mutex); static int nr_ctlr; static ctlr_info_t *hba[MAX_CTLR]; @@ -845,9 +846,9 @@ static int ida_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&cpqarray_mutex); ret = ida_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&cpqarray_mutex); return ret; } @@ -859,10 +860,10 @@ static int ida_release(struct gendisk *disk, fmode_t mode) { ctlr_info_t *host; - lock_kernel(); + mutex_lock(&cpqarray_mutex); host = get_host(disk); host->usage_count--; - unlock_kernel(); + mutex_unlock(&cpqarray_mutex); return 0; } @@ -1217,9 +1218,9 @@ static int ida_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&cpqarray_mutex); ret = ida_locked_ioctl(bdev, mode, cmd, param); - unlock_kernel(); + mutex_unlock(&cpqarray_mutex); return ret; } diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index fa650dd85b90..e4b56119866e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -32,7 +32,7 @@ #include <asm/types.h> #include <net/sock.h> #include <linux/ctype.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/fs.h> #include <linux/file.h> #include <linux/proc_fs.h> @@ -64,6 +64,7 @@ struct after_state_chg_work { struct completion *done; }; +static DEFINE_MUTEX(drbd_main_mutex); int drbdd_init(struct drbd_thread *); int drbd_worker(struct drbd_thread *); int drbd_asender(struct drbd_thread *); @@ -2536,7 +2537,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) unsigned long flags; int rv = 0; - lock_kernel(); + mutex_lock(&drbd_main_mutex); spin_lock_irqsave(&mdev->req_lock, flags); /* to have a stable mdev->state.role * and no race with updating open_cnt */ @@ -2551,7 +2552,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) if (!rv) mdev->open_cnt++; spin_unlock_irqrestore(&mdev->req_lock, flags); - unlock_kernel(); + mutex_unlock(&drbd_main_mutex); return rv; } @@ -2559,9 +2560,9 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) static int drbd_release(struct gendisk *gd, fmode_t mode) { struct drbd_conf *mdev = gd->private_data; - lock_kernel(); + mutex_lock(&drbd_main_mutex); mdev->open_cnt--; - unlock_kernel(); + mutex_unlock(&drbd_main_mutex); return 0; } diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index cf04c1b234ed..3b57459bb745 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -178,7 +178,6 @@ static int print_unex = 1; #include <linux/slab.h> #include <linux/mm.h> #include <linux/bio.h> -#include <linux/smp_lock.h> #include <linux/string.h> #include <linux/jiffies.h> #include <linux/fcntl.h> @@ -199,6 +198,7 @@ static int print_unex = 1; * It's been recommended that take about 1/4 of the default speed * in some more extreme cases. */ +static DEFINE_MUTEX(floppy_mutex); static int slow_floppy; #include <asm/dma.h> @@ -3553,9 +3553,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&floppy_mutex); ret = fd_locked_ioctl(bdev, mode, cmd, param); - unlock_kernel(); + mutex_unlock(&floppy_mutex); return ret; } @@ -3616,7 +3616,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) { int drive = (long)disk->private_data; - lock_kernel(); + mutex_lock(&floppy_mutex); mutex_lock(&open_lock); if (UDRS->fd_ref < 0) UDRS->fd_ref = 0; @@ -3627,7 +3627,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) if (!UDRS->fd_ref) opened_bdev[drive] = NULL; mutex_unlock(&open_lock); - unlock_kernel(); + mutex_unlock(&floppy_mutex); return 0; } @@ -3645,7 +3645,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) int res = -EBUSY; char *tmp; - lock_kernel(); + mutex_lock(&floppy_mutex); mutex_lock(&open_lock); old_dev = UDRS->fd_device; if (opened_bdev[drive] && opened_bdev[drive] != bdev) @@ -3722,7 +3722,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) goto out; } mutex_unlock(&open_lock); - unlock_kernel(); + mutex_unlock(&floppy_mutex); return 0; out: if (UDRS->fd_ref < 0) @@ -3733,7 +3733,7 @@ out: opened_bdev[drive] = NULL; out2: mutex_unlock(&open_lock); - unlock_kernel(); + mutex_unlock(&floppy_mutex); return res; } diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 91797bbbe702..a10c8c9b6b78 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -67,7 +67,7 @@ #include <linux/compat.h> #include <linux/suspend.h> #include <linux/freezer.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/writeback.h> #include <linux/buffer_head.h> /* for invalidate_bdev() */ #include <linux/completion.h> @@ -77,6 +77,7 @@ #include <asm/uaccess.h> +static DEFINE_MUTEX(loop_mutex); static LIST_HEAD(loop_devices); static DEFINE_MUTEX(loop_devices_mutex); @@ -1409,11 +1410,11 @@ static int lo_open(struct block_device *bdev, fmode_t mode) { struct loop_device *lo = bdev->bd_disk->private_data; - lock_kernel(); + mutex_lock(&loop_mutex); mutex_lock(&lo->lo_ctl_mutex); lo->lo_refcnt++; mutex_unlock(&lo->lo_ctl_mutex); - unlock_kernel(); + mutex_unlock(&loop_mutex); return 0; } @@ -1423,7 +1424,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode) struct loop_device *lo = disk->private_data; int err; - lock_kernel(); + mutex_lock(&loop_mutex); mutex_lock(&lo->lo_ctl_mutex); if (--lo->lo_refcnt) @@ -1448,7 +1449,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode) out: mutex_unlock(&lo->lo_ctl_mutex); out_unlocked: - lock_kernel(); + mutex_unlock(&loop_mutex); return 0; } diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 0daa422aa281..a32fb41246f8 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -24,7 +24,7 @@ #include <linux/errno.h> #include <linux/file.h> #include <linux/ioctl.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/compiler.h> #include <linux/err.h> #include <linux/kernel.h> @@ -53,6 +53,7 @@ #define DBG_BLKDEV 0x0100 #define DBG_RX 0x0200 #define DBG_TX 0x0400 +static DEFINE_MUTEX(nbd_mutex); static unsigned int debugflags; #endif /* NDEBUG */ @@ -717,11 +718,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode, dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); - lock_kernel(); + mutex_lock(&nbd_mutex); mutex_lock(&lo->tx_lock); error = __nbd_ioctl(bdev, lo, cmd, arg); mutex_unlock(&lo->tx_lock); - unlock_kernel(); + mutex_unlock(&nbd_mutex); return error; } diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 76f8565e1e8d..62cec6afd7ad 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -138,9 +138,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY}; #include <linux/cdrom.h> #include <linux/spinlock.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> +static DEFINE_MUTEX(pcd_mutex); static DEFINE_SPINLOCK(pcd_lock); module_param(verbose, bool, 0644); @@ -227,9 +228,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) struct pcd_unit *cd = bdev->bd_disk->private_data; int ret; - lock_kernel(); + mutex_lock(&pcd_mutex); ret = cdrom_open(&cd->info, bdev, mode); - unlock_kernel(); + mutex_unlock(&pcd_mutex); return ret; } @@ -237,9 +238,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) static int pcd_block_release(struct gendisk *disk, fmode_t mode) { struct pcd_unit *cd = disk->private_data; - lock_kernel(); + mutex_lock(&pcd_mutex); cdrom_release(&cd->info, mode); - unlock_kernel(); + mutex_unlock(&pcd_mutex); return 0; } @@ -249,9 +250,9 @@ static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode, struct pcd_unit *cd = bdev->bd_disk->private_data; int ret; - lock_kernel(); + mutex_lock(&pcd_mutex); ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&pcd_mutex); return ret; } diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 985f0d4f1d1e..c0ee1558b9bb 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -153,10 +153,11 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV}; #include <linux/blkdev.h> #include <linux/blkpg.h> #include <linux/kernel.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> #include <linux/workqueue.h> +static DEFINE_MUTEX(pd_mutex); static DEFINE_SPINLOCK(pd_lock); module_param(verbose, bool, 0); @@ -736,14 +737,14 @@ static int pd_open(struct block_device *bdev, fmode_t mode) { struct pd_unit *disk = bdev->bd_disk->private_data; - lock_kernel(); + mutex_lock(&pd_mutex); disk->access++; if (disk->removable) { pd_special_command(disk, pd_media_check); pd_special_command(disk, pd_door_lock); } - unlock_kernel(); + mutex_unlock(&pd_mutex); return 0; } @@ -771,10 +772,10 @@ static int pd_ioctl(struct block_device *bdev, fmode_t mode, switch (cmd) { case CDROMEJECT: - lock_kernel(); + mutex_lock(&pd_mutex); if (disk->access == 1) pd_special_command(disk, pd_eject); - unlock_kernel(); + mutex_unlock(&pd_mutex); return 0; default: return -EINVAL; @@ -785,10 +786,10 @@ static int pd_release(struct gendisk *p, fmode_t mode) { struct pd_unit *disk = p->private_data; - lock_kernel(); + mutex_lock(&pd_mutex); if (!--disk->access && disk->removable) pd_special_command(disk, pd_door_unlock); - unlock_kernel(); + mutex_unlock(&pd_mutex); return 0; } diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 4457b494882a..635f25dd9e10 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -152,9 +152,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY}; #include <linux/spinlock.h> #include <linux/blkdev.h> #include <linux/blkpg.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> +static DEFINE_MUTEX(pf_mutex); static DEFINE_SPINLOCK(pf_spin_lock); module_param(verbose, bool, 0644); @@ -302,7 +303,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode) struct pf_unit *pf = bdev->bd_disk->private_data; int ret; - lock_kernel(); + mutex_lock(&pf_mutex); pf_identify(pf); ret = -ENODEV; @@ -318,7 +319,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode) if (pf->removable) pf_lock(pf, 1); out: - unlock_kernel(); + mutex_unlock(&pf_mutex); return ret; } @@ -349,9 +350,9 @@ static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, u if (pf->access != 1) return -EBUSY; - lock_kernel(); + mutex_lock(&pf_mutex); pf_eject(pf); - unlock_kernel(); + mutex_unlock(&pf_mutex); return 0; } @@ -360,9 +361,9 @@ static int pf_release(struct gendisk *disk, fmode_t mode) { struct pf_unit *pf = disk->private_data; - lock_kernel(); + mutex_lock(&pf_mutex); if (pf->access <= 0) { - unlock_kernel(); + mutex_unlock(&pf_mutex); return -EINVAL; } @@ -371,7 +372,7 @@ static int pf_release(struct gendisk *disk, fmode_t mode) if (!pf->access && pf->removable) pf_lock(pf, 0); - unlock_kernel(); + mutex_unlock(&pf_mutex); return 0; } diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c index c397b3ddba9b..bed29cb9e6d9 100644 --- a/drivers/block/paride/pg.c +++ b/drivers/block/paride/pg.c @@ -162,7 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY}; #include <linux/pg.h> #include <linux/device.h> #include <linux/sched.h> /* current, TASK_* */ -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/jiffies.h> #include <asm/uaccess.h> @@ -193,6 +193,7 @@ module_param_array(drive3, int, NULL, 0); #define ATAPI_IDENTIFY 0x12 +static DEFINE_MUTEX(pg_mutex); static int pg_open(struct inode *inode, struct file *file); static int pg_release(struct inode *inode, struct file *file); static ssize_t pg_read(struct file *filp, char __user *buf, @@ -518,7 +519,7 @@ static int pg_open(struct inode *inode, struct file *file) struct pg *dev = &devices[unit]; int ret = 0; - lock_kernel(); + mutex_lock(&pg_mutex); if ((unit >= PG_UNITS) || (!dev->present)) { ret = -ENODEV; goto out; @@ -547,7 +548,7 @@ static int pg_open(struct inode *inode, struct file *file) file->private_data = dev; out: - unlock_kernel(); + mutex_unlock(&pg_mutex); return ret; } diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index bc5825fdeaab..e4dda282e0a6 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -146,7 +146,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3}; #include <linux/mtio.h> #include <linux/device.h> #include <linux/sched.h> /* current, TASK_*, schedule_timeout() */ -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> @@ -189,6 +189,7 @@ module_param_array(drive3, int, NULL, 0); #define ATAPI_MODE_SENSE 0x1a #define ATAPI_LOG_SENSE 0x4d +static DEFINE_MUTEX(pt_mutex); static int pt_open(struct inode *inode, struct file *file); static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static int pt_release(struct inode *inode, struct file *file); @@ -650,9 +651,9 @@ static int pt_open(struct inode *inode, struct file *file) struct pt_unit *tape = pt + unit; int err; - lock_kernel(); + mutex_lock(&pt_mutex); if (unit >= PT_UNITS || (!tape->present)) { - unlock_kernel(); + mutex_unlock(&pt_mutex); return -ENODEV; } @@ -681,12 +682,12 @@ static int pt_open(struct inode *inode, struct file *file) } file->private_data = tape; - unlock_kernel(); + mutex_unlock(&pt_mutex); return 0; out: atomic_inc(&tape->available); - unlock_kernel(); + mutex_unlock(&pt_mutex); return err; } @@ -704,15 +705,15 @@ static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch (mtop.mt_op) { case MTREW: - lock_kernel(); + mutex_lock(&pt_mutex); pt_rewind(tape); - unlock_kernel(); + mutex_unlock(&pt_mutex); return 0; case MTWEOF: - lock_kernel(); + mutex_lock(&pt_mutex); pt_write_fm(tape); - unlock_kernel(); + mutex_unlock(&pt_mutex); return 0; default: diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 37a2bb595076..044b84e6f147 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -57,7 +57,6 @@ #include <linux/seq_file.h> #include <linux/miscdevice.h> #include <linux/freezer.h> -#include <linux/smp_lock.h> #include <linux/mutex.h> #include <linux/slab.h> #include <scsi/scsi_cmnd.h> @@ -86,6 +85,7 @@ #define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) +static DEFINE_MUTEX(pktcdvd_mutex); static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; static struct proc_dir_entry *pkt_proc; static int pktdev_major; @@ -2383,7 +2383,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode) VPRINTK(DRIVER_NAME": entering open\n"); - lock_kernel(); + mutex_lock(&pktcdvd_mutex); mutex_lock(&ctl_mutex); pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); if (!pd) { @@ -2411,7 +2411,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode) } mutex_unlock(&ctl_mutex); - unlock_kernel(); + mutex_unlock(&pktcdvd_mutex); return 0; out_dec: @@ -2419,7 +2419,7 @@ out_dec: out: VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); mutex_unlock(&ctl_mutex); - unlock_kernel(); + mutex_unlock(&pktcdvd_mutex); return ret; } @@ -2428,7 +2428,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode) struct pktcdvd_device *pd = disk->private_data; int ret = 0; - lock_kernel(); + mutex_lock(&pktcdvd_mutex); mutex_lock(&ctl_mutex); pd->refcnt--; BUG_ON(pd->refcnt < 0); @@ -2437,7 +2437,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode) pkt_release_dev(pd, flush); } mutex_unlock(&ctl_mutex); - unlock_kernel(); + mutex_unlock(&pktcdvd_mutex); return ret; } @@ -2773,7 +2773,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); - lock_kernel(); + mutex_lock(&pktcdvd_mutex); switch (cmd) { case CDROMEJECT: /* @@ -2798,7 +2798,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); ret = -ENOTTY; } - unlock_kernel(); + mutex_unlock(&pktcdvd_mutex); return ret; } diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 2e46815876df..75333d0a3327 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -20,7 +20,7 @@ #include <linux/fd.h> #include <linux/slab.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/hdreg.h> #include <linux/kernel.h> #include <linux/delay.h> @@ -222,6 +222,7 @@ extern int swim_read_sector_header(struct swim __iomem *base, extern int swim_read_sector_data(struct swim __iomem *base, unsigned char *data); +static DEFINE_MUTEX(swim_mutex); static inline void set_swim_mode(struct swim __iomem *base, int enable) { struct iwm __iomem *iwm_base; @@ -666,9 +667,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&swim_mutex); ret = floppy_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&swim_mutex); return ret; } @@ -678,7 +679,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) struct floppy_state *fs = disk->private_data; struct swim __iomem *base = fs->swd->base; - lock_kernel(); + mutex_lock(&swim_mutex); if (fs->ref_count < 0) fs->ref_count = 0; else if (fs->ref_count > 0) @@ -686,7 +687,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) if (fs->ref_count == 0) swim_motor(base, OFF); - unlock_kernel(); + mutex_unlock(&swim_mutex); return 0; } @@ -704,9 +705,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, case FDEJECT: if (fs->ref_count != 1) return -EBUSY; - lock_kernel(); + mutex_lock(&swim_mutex); err = floppy_eject(fs); - unlock_kernel(); + mutex_unlock(&swim_mutex); return err; case FDGETPRM: diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index cc6a3864822c..bf3a5b859299 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -25,7 +25,7 @@ #include <linux/ioctl.h> #include <linux/blkdev.h> #include <linux/interrupt.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/module.h> #include <linux/spinlock.h> #include <asm/io.h> @@ -36,6 +36,7 @@ #include <asm/machdep.h> #include <asm/pmac_feature.h> +static DEFINE_MUTEX(swim3_mutex); static struct request_queue *swim3_queue; static struct gendisk *disks[2]; static struct request *fd_req; @@ -873,9 +874,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&swim3_mutex); ret = floppy_locked_ioctl(bdev, mode, cmd, param); - unlock_kernel(); + mutex_unlock(&swim3_mutex); return ret; } @@ -953,9 +954,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&swim3_mutex); ret = floppy_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&swim3_mutex); return ret; } @@ -964,13 +965,13 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) { struct floppy_state *fs = disk->private_data; struct swim3 __iomem *sw = fs->swim3; - lock_kernel(); + mutex_lock(&swim3_mutex); if (fs->ref_count > 0 && --fs->ref_count == 0) { swim3_action(fs, MOTOR_OFF); out_8(&sw->control_bic, 0xff); swim3_select(fs, RELAX); } - unlock_kernel(); + mutex_unlock(&swim3_mutex); return 0; } diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c48e14878582..b5690a045a01 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -28,7 +28,7 @@ #include <linux/timer.h> #include <linux/scatterlist.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <scsi/scsi.h> #define DRV_NAME "ub" @@ -248,6 +248,7 @@ struct ub_completion { spinlock_t lock; }; +static DEFINE_MUTEX(ub_mutex); static inline void ub_init_completion(struct ub_completion *x) { x->done = 0; @@ -1715,9 +1716,9 @@ static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&ub_mutex); ret = ub_bd_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&ub_mutex); return ret; } @@ -1730,9 +1731,9 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode) struct ub_lun *lun = disk->private_data; struct ub_dev *sc = lun->udev; - lock_kernel(); + mutex_lock(&ub_mutex); ub_put(sc); - unlock_kernel(); + mutex_unlock(&ub_mutex); return 0; } @@ -1747,9 +1748,9 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode, void __user *usermem = (void __user *) arg; int ret; - lock_kernel(); + mutex_lock(&ub_mutex); ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); - unlock_kernel(); + mutex_unlock(&ub_mutex); return ret; } diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index f651e51a3319..e2ff697697c2 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c @@ -41,7 +41,7 @@ #include <linux/errno.h> #include <linux/init.h> #include <linux/string.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/dma-mapping.h> #include <linux/completion.h> #include <linux/device.h> @@ -73,6 +73,7 @@ enum { MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) }; +static DEFINE_MUTEX(viodasd_mutex); static DEFINE_SPINLOCK(viodasd_spinlock); #define VIOMAXREQ 16 @@ -180,9 +181,9 @@ static int viodasd_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&viodasd_mutex); ret = viodasd_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&viodasd_mutex); return ret; } @@ -196,7 +197,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode) struct viodasd_device *d = disk->private_data; HvLpEvent_Rc hvrc; - lock_kernel(); + mutex_lock(&viodasd_mutex); /* Send the event to OS/400. We DON'T expect a response */ hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, HvLpEvent_Type_VirtualIo, @@ -210,7 +211,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode) if (hvrc != 0) pr_warning("HV close call failed %d\n", (int)hvrc); - unlock_kernel(); + mutex_unlock(&viodasd_mutex); return 0; } diff --git a/drivers/block/xd.c b/drivers/block/xd.c index d5a3cd750561..4abd2bcd20fb 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c @@ -46,7 +46,7 @@ #include <linux/init.h> #include <linux/wait.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/blkpg.h> #include <linux/delay.h> #include <linux/io.h> @@ -58,6 +58,7 @@ #include "xd.h" +static DEFINE_MUTEX(xd_mutex); static void __init do_xd_setup (int *integers); #ifdef MODULE static int xd[5] = { -1,-1,-1,-1, }; @@ -381,9 +382,9 @@ static int xd_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&xd_mutex); ret = xd_locked_ioctl(bdev, mode, cmd, param); - unlock_kernel(); + mutex_unlock(&xd_mutex); return ret; } diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index ab735a605cf3..3ff06f475eef 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -41,7 +41,7 @@ #include <linux/cdrom.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/scatterlist.h> #include <xen/xen.h> @@ -69,6 +69,7 @@ struct blk_shadow { unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; }; +static DEFINE_MUTEX(blkfront_mutex); static const struct block_device_operations xlvbd_block_fops; #define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) @@ -1201,7 +1202,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode) struct blkfront_info *info; int err = 0; - lock_kernel(); + mutex_lock(&blkfront_mutex); info = disk->private_data; if (!info) { @@ -1219,7 +1220,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode) mutex_unlock(&info->mutex); out: - unlock_kernel(); + mutex_unlock(&blkfront_mutex); return err; } @@ -1229,7 +1230,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode) struct block_device *bdev; struct xenbus_device *xbdev; - lock_kernel(); + mutex_lock(&blkfront_mutex); bdev = bdget_disk(disk, 0); bdput(bdev); @@ -1263,7 +1264,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode) } out: - unlock_kernel(); + mutex_unlock(&blkfront_mutex); return 0; } diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 057413bb16e2..6e968cd4893c 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -89,7 +89,7 @@ #include <linux/delay.h> #include <linux/slab.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/ata.h> #include <linux/hdreg.h> #include <linux/platform_device.h> @@ -214,6 +214,7 @@ struct ace_device { u16 cf_id[ATA_ID_WORDS]; }; +static DEFINE_MUTEX(xsysace_mutex); static int ace_major; /* --------------------------------------------------------------------- @@ -903,13 +904,13 @@ static int ace_open(struct block_device *bdev, fmode_t mode) dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); - lock_kernel(); + mutex_lock(&xsysace_mutex); spin_lock_irqsave(&ace->lock, flags); ace->users++; spin_unlock_irqrestore(&ace->lock, flags); check_disk_change(bdev); - unlock_kernel(); + mutex_unlock(&xsysace_mutex); return 0; } @@ -922,7 +923,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode) dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); - lock_kernel(); + mutex_lock(&xsysace_mutex); spin_lock_irqsave(&ace->lock, flags); ace->users--; if (ace->users == 0) { @@ -930,7 +931,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode) ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); } spin_unlock_irqrestore(&ace->lock, flags); - unlock_kernel(); + mutex_unlock(&xsysace_mutex); return 0; } diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index d75b2bb601ad..dcd4cfcf4126 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -33,7 +33,7 @@ #include <linux/module.h> #include <linux/blkdev.h> #include <linux/bitops.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <asm/setup.h> @@ -57,6 +57,7 @@ extern struct mem_info m68k_memory[NUM_MEMINFO]; #define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 ) +static DEFINE_MUTEX(z2ram_mutex); static u_long *z2ram_map = NULL; static u_long z2ram_size = 0; static int z2_count = 0; @@ -154,7 +155,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) device = MINOR(bdev->bd_dev); - lock_kernel(); + mutex_lock(&z2ram_mutex); if ( current_device != -1 && current_device != device ) { rc = -EBUSY; @@ -296,25 +297,25 @@ static int z2_open(struct block_device *bdev, fmode_t mode) set_capacity(z2ram_gendisk, z2ram_size >> 9); } - unlock_kernel(); + mutex_unlock(&z2ram_mutex); return 0; err_out_kfree: kfree(z2ram_map); err_out: - unlock_kernel(); + mutex_unlock(&z2ram_mutex); return rc; } static int z2_release(struct gendisk *disk, fmode_t mode) { - lock_kernel(); + mutex_lock(&z2ram_mutex); if ( current_device == -1 ) { - unlock_kernel(); + mutex_unlock(&z2ram_mutex); return 0; } - unlock_kernel(); + mutex_unlock(&z2ram_mutex); /* * FIXME: unmap memory */ diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 261107d1457c..3af6516919b7 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -34,7 +34,7 @@ #include <linux/blkdev.h> #include <linux/interrupt.h> #include <linux/device.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/wait.h> #include <linux/workqueue.h> #include <linux/platform_device.h> @@ -81,6 +81,7 @@ #define GDROM_DEFAULT_TIMEOUT (HZ * 7) +static DEFINE_MUTEX(gdrom_mutex); static const struct { int sense_key; const char * const text; @@ -494,17 +495,17 @@ static struct cdrom_device_ops gdrom_ops = { static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&gdrom_mutex); ret = cdrom_open(gd.cd_info, bdev, mode); - unlock_kernel(); + mutex_unlock(&gdrom_mutex); return ret; } static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) { - lock_kernel(); + mutex_lock(&gdrom_mutex); cdrom_release(gd.cd_info, mode); - unlock_kernel(); + mutex_unlock(&gdrom_mutex); return 0; } @@ -518,9 +519,9 @@ static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&gdrom_mutex); ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&gdrom_mutex); return ret; } diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 56bf9f44700c..be73a9b493a6 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c @@ -42,7 +42,7 @@ #include <linux/module.h> #include <linux/completion.h> #include <linux/proc_fs.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/seq_file.h> #include <linux/scatterlist.h> @@ -61,6 +61,7 @@ */ #define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS +static DEFINE_MUTEX(viocd_mutex); static const struct vio_error_entry viocd_err_table[] = { {0x0201, EINVAL, "Invalid Range"}, {0x0202, EINVAL, "Invalid Token"}, @@ -156,9 +157,9 @@ static int viocd_blk_open(struct block_device *bdev, fmode_t mode) struct disk_info *di = bdev->bd_disk->private_data; int ret; - lock_kernel(); + mutex_lock(&viocd_mutex); ret = cdrom_open(&di->viocd_info, bdev, mode); - unlock_kernel(); + mutex_unlock(&viocd_mutex); return ret; } @@ -166,9 +167,9 @@ static int viocd_blk_open(struct block_device *bdev, fmode_t mode) static int viocd_blk_release(struct gendisk *disk, fmode_t mode) { struct disk_info *di = disk->private_data; - lock_kernel(); + mutex_lock(&viocd_mutex); cdrom_release(&di->viocd_info, mode); - unlock_kernel(); + mutex_unlock(&viocd_mutex); return 0; } @@ -178,9 +179,9 @@ static int viocd_blk_ioctl(struct block_device *bdev, fmode_t mode, struct disk_info *di = bdev->bd_disk->private_data; int ret; - lock_kernel(); + mutex_lock(&viocd_mutex); ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&viocd_mutex); return ret; } diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index 033e1505fca9..6a420baea268 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c @@ -13,7 +13,7 @@ #include <linux/module.h> #include <linux/poll.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/miscdevice.h> @@ -126,6 +126,7 @@ struct apm_user { /* * Local variables */ +static DEFINE_MUTEX(apm_mutex); static atomic_t suspend_acks_pending = ATOMIC_INIT(0); static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); static int apm_disabled; @@ -274,7 +275,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg) if (!as->suser || !as->writer) return -EPERM; - lock_kernel(); + mutex_lock(&apm_mutex); switch (cmd) { case APM_IOC_SUSPEND: mutex_lock(&state_lock); @@ -335,7 +336,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg) mutex_unlock(&state_lock); break; } - unlock_kernel(); + mutex_unlock(&apm_mutex); return err; } @@ -370,7 +371,7 @@ static int apm_open(struct inode * inode, struct file * filp) { struct apm_user *as; - lock_kernel(); + mutex_lock(&apm_mutex); as = kzalloc(sizeof(*as), GFP_KERNEL); if (as) { /* @@ -390,7 +391,7 @@ static int apm_open(struct inode * inode, struct file * filp) filp->private_data = as; } - unlock_kernel(); + mutex_unlock(&apm_mutex); return as ? 0 : -ENOMEM; } diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index f4ae0e0fb631..e7ba774beda6 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c @@ -26,7 +26,7 @@ #include <linux/sched.h> #include <linux/slab.h> #include <linux/errno.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/miscdevice.h> #include <linux/pci.h> #include <linux/wait.h> @@ -60,6 +60,7 @@ #define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 #endif +static DEFINE_MUTEX(ac_mutex); static char *applicom_pci_devnames[] = { "PCI board", "PCI2000IBS / PCI2000CAN", @@ -707,7 +708,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (IS_ERR(adgl)) return PTR_ERR(adgl); - lock_kernel(); + mutex_lock(&ac_mutex); IndexCard = adgl->num_card-1; if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { @@ -717,7 +718,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg) warncount--; } kfree(adgl); - unlock_kernel(); + mutex_unlock(&ac_mutex); return -EINVAL; } @@ -835,7 +836,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } Dummy = readb(apbs[IndexCard].RamIO + VERS); kfree(adgl); - unlock_kernel(); + mutex_unlock(&ac_mutex); return 0; } diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c index 170693c93c73..e3d72aa3cbd2 100644 --- a/drivers/char/ds1302.c +++ b/drivers/char/ds1302.c @@ -20,7 +20,7 @@ #include <linux/miscdevice.h> #include <linux/delay.h> #include <linux/bcd.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/uaccess.h> #include <linux/io.h> @@ -32,6 +32,7 @@ #define RTC_MAJOR_NR 121 /* local major, change later */ +static DEFINE_MUTEX(rtc_mutex); static const char ds1302_name[] = "ds1302"; /* Send 8 bits. */ @@ -164,9 +165,9 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct rtc_time rtc_tm; memset(&rtc_tm, 0, sizeof (struct rtc_time)); - lock_kernel(); + mutex_lock(&rtc_mutex); get_rtc_time(&rtc_tm); - unlock_kernel(); + mutex_unlock(&rtc_mutex); if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) return -EFAULT; return 0; @@ -218,7 +219,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mon = bin2bcd(mon); yrs = bin2bcd(yrs); - lock_kernel(); + mutex_lock(&rtc_mutex); local_irq_save(flags); CMOS_WRITE(yrs, RTC_YEAR); CMOS_WRITE(mon, RTC_MONTH); @@ -227,7 +228,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) CMOS_WRITE(min, RTC_MINUTES); CMOS_WRITE(sec, RTC_SECONDS); local_irq_restore(flags); - unlock_kernel(); + mutex_unlock(&rtc_mutex); /* Notice that at this point, the RTC is updated but * the kernel is still running with the old time. @@ -247,10 +248,10 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) return -EFAULT; - lock_kernel(); + mutex_lock(&rtc_mutex); tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); - unlock_kernel(); + mutex_unlock(&rtc_mutex); return 0; } default: diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index dbee8688f75c..9aa1fd059aea 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c @@ -8,7 +8,7 @@ #include <linux/proc_fs.h> #include <linux/capability.h> #include <linux/init.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <mach/hardware.h> #include <asm/mach-types.h> @@ -34,6 +34,7 @@ #define CFG_CPU 2 #define CFG_1SHOT 1 +static DEFINE_MUTEX(ds1620_mutex); static const char *fan_state[] = { "off", "on", "on (hardwired)" }; /* @@ -210,7 +211,6 @@ static void ds1620_read_state(struct therm *therm) static int ds1620_open(struct inode *inode, struct file *file) { - cycle_kernel_lock(); return nonseekable_open(inode, file); } @@ -321,9 +321,9 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&ds1620_mutex); ret = ds1620_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&ds1620_mutex); return ret; } diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 8a1b28a10ef0..b3c756227e39 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -32,7 +32,7 @@ #include <linux/mm.h> #include <linux/init.h> #include <linux/device.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/firmware.h> #include <linux/platform_device.h> #include <linux/uaccess.h> /* For put_user and get_user */ @@ -94,6 +94,7 @@ } \ } +static DEFINE_MUTEX(dsp56k_mutex); static struct dsp56k_device { unsigned long in_use; long maxio, timeout; @@ -330,9 +331,9 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, if (len > DSP56K_MAX_BINARY_LENGTH) { return -EINVAL; } - lock_kernel(); + mutex_lock(&dsp56k_mutex); r = dsp56k_upload(bin, len); - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); if (r < 0) { return r; } @@ -342,16 +343,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, case DSP56K_SET_TX_WSIZE: if (arg > 4 || arg < 1) return -EINVAL; - lock_kernel(); + mutex_lock(&dsp56k_mutex); dsp56k.tx_wsize = (int) arg; - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); break; case DSP56K_SET_RX_WSIZE: if (arg > 4 || arg < 1) return -EINVAL; - lock_kernel(); + mutex_lock(&dsp56k_mutex); dsp56k.rx_wsize = (int) arg; - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); break; case DSP56K_HOST_FLAGS: { @@ -363,7 +364,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, if(get_user(out, &hf->out) < 0) return -EFAULT; - lock_kernel(); + mutex_lock(&dsp56k_mutex); if ((dir & 0x1) && (out & 0x1)) dsp56k_host_interface.icr |= DSP56K_ICR_HF0; else if (dir & 0x1) @@ -378,16 +379,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); return put_user(status, &hf->status); } case DSP56K_HOST_CMD: if (arg > 31 || arg < 0) return -EINVAL; - lock_kernel(); + mutex_lock(&dsp56k_mutex); dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | DSP56K_CVR_HC); - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); break; default: return -EINVAL; @@ -427,7 +428,7 @@ static int dsp56k_open(struct inode *inode, struct file *file) int dev = iminor(inode) & 0x0f; int ret = 0; - lock_kernel(); + mutex_lock(&dsp56k_mutex); switch(dev) { case DSP56K_DEV_56001: @@ -454,7 +455,7 @@ static int dsp56k_open(struct inode *inode, struct file *file) ret = -ENODEV; } out: - unlock_kernel(); + mutex_unlock(&dsp56k_mutex); return ret; } diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c index e3859d4eaead..8dd040a945d4 100644 --- a/drivers/char/dtlk.c +++ b/drivers/char/dtlk.c @@ -57,7 +57,7 @@ #include <linux/ioport.h> /* for request_region */ #include <linux/delay.h> /* for loops_per_jiffy */ #include <linux/sched.h> -#include <linux/smp_lock.h> /* cycle_kernel_lock() */ +#include <linux/mutex.h> #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ #include <asm/uaccess.h> /* for get_user, etc. */ #include <linux/wait.h> /* for wait_queue */ @@ -73,6 +73,7 @@ #define TRACE_RET ((void) 0) #endif /* TRACING */ +static DEFINE_MUTEX(dtlk_mutex); static void dtlk_timer_tick(unsigned long data); static int dtlk_major; @@ -275,9 +276,9 @@ static long dtlk_ioctl(struct file *file, switch (cmd) { case DTLK_INTERROGATE: - lock_kernel(); + mutex_lock(&dtlk_mutex); sp = dtlk_interrogate(); - unlock_kernel(); + mutex_unlock(&dtlk_mutex); if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) return -EINVAL; return 0; @@ -296,7 +297,6 @@ static int dtlk_open(struct inode *inode, struct file *file) { TRACE_TEXT("(dtlk_open"); - cycle_kernel_lock(); nonseekable_open(inode, file); switch (iminor(inode)) { case DTLK_MINOR: diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c index 82b5a88a82d7..0e941b57482e 100644 --- a/drivers/char/generic_nvram.c +++ b/drivers/char/generic_nvram.c @@ -19,7 +19,7 @@ #include <linux/miscdevice.h> #include <linux/fcntl.h> #include <linux/init.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> #include <asm/nvram.h> #ifdef CONFIG_PPC_PMAC @@ -28,6 +28,7 @@ #define NVRAM_SIZE 8192 +static DEFINE_MUTEX(nvram_mutex); static ssize_t nvram_len; static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) @@ -120,9 +121,9 @@ static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned l { int ret; - lock_kernel(); + mutex_lock(&nvram_mutex); ret = nvram_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&nvram_mutex); return ret; } diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index b6c2cc167c11..2aa69f97360d 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c @@ -52,7 +52,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/proc_fs.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/workqueue.h> #include <asm/uaccess.h> @@ -66,6 +66,7 @@ * ioctls. */ +static DEFINE_MUTEX(gen_rtc_mutex); static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); /* @@ -337,9 +338,9 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd, { int ret; - lock_kernel(); + mutex_lock(&gen_rtc_mutex); ret = gen_rtc_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&gen_rtc_mutex); return ret; } @@ -352,16 +353,16 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd, static int gen_rtc_open(struct inode *inode, struct file *file) { - lock_kernel(); + mutex_lock(&gen_rtc_mutex); if (gen_rtc_status & RTC_IS_OPEN) { - unlock_kernel(); + mutex_unlock(&gen_rtc_mutex); return -EBUSY; } gen_rtc_status |= RTC_IS_OPEN; gen_rtc_irq_data = 0; irq_active = 0; - unlock_kernel(); + mutex_unlock(&gen_rtc_mutex); return 0; } diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index 4cd8b227c11f..3bc0eef88717 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c @@ -23,7 +23,7 @@ #include <linux/seq_file.h> #include <linux/dmi.h> #include <linux/capability.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -56,6 +56,7 @@ #define I8K_TEMPERATURE_BUG 1 +static DEFINE_MUTEX(i8k_mutex); static char bios_version[4]; MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); @@ -399,9 +400,9 @@ static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&i8k_mutex); ret = i8k_ioctl_unlocked(fp, cmd, arg); - unlock_kernel(); + mutex_unlock(&i8k_mutex); return ret; } diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index d4b71e8d0d23..dfbdf49d1e80 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -98,7 +98,7 @@ #include <linux/major.h> #include <linux/wait.h> #include <linux/device.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/firmware.h> #include <linux/platform_device.h> @@ -138,6 +138,7 @@ #include <linux/proc_fs.h> #include <linux/seq_file.h> +static DEFINE_MUTEX(ip2_mutex); static const struct file_operations ip2mem_proc_fops; static const struct file_operations ip2_proc_fops; @@ -2897,7 +2898,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg ) printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); #endif - lock_kernel(); + mutex_lock(&ip2_mutex); switch ( iplminor ) { case 0: // IPL device @@ -2961,7 +2962,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg ) rc = -ENODEV; break; } - unlock_kernel(); + mutex_unlock(&ip2_mutex); return rc; } @@ -2982,7 +2983,6 @@ ip2_ipl_open( struct inode *pInode, struct file *pFile ) #ifdef IP2DEBUG_IPL printk (KERN_DEBUG "IP2IPL: open\n" ); #endif - cycle_kernel_lock(); return 0; } diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index d8ec92a38980..44833de47728 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -44,7 +44,6 @@ #include <linux/init.h> #include <linux/device.h> #include <linux/compat.h> -#include <linux/smp_lock.h> struct ipmi_file_private { @@ -59,6 +58,7 @@ struct ipmi_file_private unsigned int default_retry_time_ms; }; +static DEFINE_MUTEX(ipmi_mutex); static void file_receive_handler(struct ipmi_recv_msg *msg, void *handler_data) { @@ -102,9 +102,9 @@ static int ipmi_fasync(int fd, struct file *file, int on) struct ipmi_file_private *priv = file->private_data; int result; - lock_kernel(); /* could race against open() otherwise */ + mutex_lock(&ipmi_mutex); /* could race against open() otherwise */ result = fasync_helper(fd, file, on, &priv->fasync_queue); - unlock_kernel(); + mutex_unlock(&ipmi_mutex); return (result); } @@ -125,7 +125,7 @@ static int ipmi_open(struct inode *inode, struct file *file) if (!priv) return -ENOMEM; - lock_kernel(); + mutex_lock(&ipmi_mutex); priv->file = file; rv = ipmi_create_user(if_num, @@ -150,7 +150,7 @@ static int ipmi_open(struct inode *inode, struct file *file) priv->default_retry_time_ms = 0; out: - unlock_kernel(); + mutex_unlock(&ipmi_mutex); return rv; } @@ -639,9 +639,9 @@ static long ipmi_unlocked_ioctl(struct file *file, { int ret; - lock_kernel(); + mutex_lock(&ipmi_mutex); ret = ipmi_ioctl(file, cmd, data); - unlock_kernel(); + mutex_unlock(&ipmi_mutex); return ret; } diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 654d566ca57c..ed10b741962d 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -35,7 +35,7 @@ #include <linux/moduleparam.h> #include <linux/ipmi.h> #include <linux/ipmi_smi.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/watchdog.h> #include <linux/miscdevice.h> #include <linux/init.h> @@ -149,6 +149,7 @@ #define WDIOC_GET_PRETIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 22, int) #endif +static DEFINE_MUTEX(ipmi_watchdog_mutex); static int nowayout = WATCHDOG_NOWAYOUT; static ipmi_user_t watchdog_user; @@ -748,9 +749,9 @@ static long ipmi_unlocked_ioctl(struct file *file, { int ret; - lock_kernel(); + mutex_lock(&ipmi_watchdog_mutex); ret = ipmi_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&ipmi_watchdog_mutex); return ret; } @@ -844,7 +845,6 @@ static int ipmi_open(struct inode *ino, struct file *filep) if (test_and_set_bit(0, &ipmi_wdog_open)) return -EBUSY; - cycle_kernel_lock(); /* * Don't start the timer now, let it start on the diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 938a3a273886..598d278db058 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -126,7 +126,7 @@ #include <linux/device.h> #include <linux/wait.h> #include <linux/jiffies.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/compat.h> #include <linux/parport.h> @@ -140,6 +140,7 @@ /* if you have more than 8 printers, remember to increase LP_NO */ #define LP_NO 8 +static DEFINE_MUTEX(lp_mutex); static struct lp_struct lp_table[LP_NO]; static unsigned int lp_count = 0; @@ -493,7 +494,7 @@ static int lp_open(struct inode * inode, struct file * file) unsigned int minor = iminor(inode); int ret = 0; - lock_kernel(); + mutex_lock(&lp_mutex); if (minor >= LP_NO) { ret = -ENXIO; goto out; @@ -554,7 +555,7 @@ static int lp_open(struct inode * inode, struct file * file) lp_release_parport (&lp_table[minor]); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; out: - unlock_kernel(); + mutex_unlock(&lp_mutex); return ret; } @@ -680,7 +681,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd, int ret; minor = iminor(file->f_path.dentry->d_inode); - lock_kernel(); + mutex_lock(&lp_mutex); switch (cmd) { case LPSETTIMEOUT: if (copy_from_user(&par_timeout, (void __user *)arg, @@ -694,7 +695,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd, ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); break; } - unlock_kernel(); + mutex_unlock(&lp_mutex); return ret; } @@ -709,7 +710,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd, int ret; minor = iminor(file->f_path.dentry->d_inode); - lock_kernel(); + mutex_lock(&lp_mutex); switch (cmd) { case LPSETTIMEOUT: tc = compat_ptr(arg); @@ -730,7 +731,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd, ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); break; } - unlock_kernel(); + mutex_unlock(&lp_mutex); return ret; } diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c index 83bef4efe376..1aeaaba680d2 100644 --- a/drivers/char/mbcs.c +++ b/drivers/char/mbcs.c @@ -25,7 +25,6 @@ #include <linux/mm.h> #include <linux/uio.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <asm/io.h> #include <asm/uaccess.h> @@ -42,6 +41,7 @@ #else #define DBG(fmt...) #endif +static DEFINE_MUTEX(mbcs_mutex); static int mbcs_major; static LIST_HEAD(soft_list); @@ -385,19 +385,19 @@ static int mbcs_open(struct inode *ip, struct file *fp) struct mbcs_soft *soft; int minor; - lock_kernel(); + mutex_lock(&mbcs_mutex); minor = iminor(ip); /* Nothing protects access to this list... */ list_for_each_entry(soft, &soft_list, list) { if (soft->nasid == minor) { fp->private_data = soft->cxdev; - unlock_kernel(); + mutex_unlock(&mbcs_mutex); return 0; } } - unlock_kernel(); + mutex_unlock(&mbcs_mutex); return -ENODEV; } diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index ea7c99fa978f..fe4697844ec1 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -32,7 +32,7 @@ #include <linux/interrupt.h> #include <linux/time.h> #include <linux/math64.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <asm/uaccess.h> @@ -59,6 +59,7 @@ extern unsigned long sn_rtc_cycles_per_second; #define rtc_time() (*RTC_COUNTER_ADDR) +static DEFINE_MUTEX(mmtimer_mutex); static long mmtimer_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); @@ -371,7 +372,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd, { int ret = 0; - lock_kernel(); + mutex_lock(&mmtimer_mutex); switch (cmd) { case MMTIMER_GETOFFSET: /* offset of the counter */ @@ -414,7 +415,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd, ret = -ENOTTY; break; } - unlock_kernel(); + mutex_unlock(&mmtimer_mutex); return ret; } diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index a4ec50c95072..e5df26b56d59 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c @@ -56,7 +56,7 @@ #include <linux/serial.h> #include <linux/sched.h> #include <linux/spinlock.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/delay.h> #include <linux/serial_8250.h> #include "smapi.h" @@ -73,6 +73,7 @@ MODULE_LICENSE("GPL"); * checks are made against other devices (ie. superio) for conflicts. * We'll depend on users using the tpctl utility to do that for now */ +static DEFINE_MUTEX(mwave_mutex); int mwave_debug = 0; int mwave_3780i_irq = 0; int mwave_3780i_io = 0; @@ -101,7 +102,6 @@ static int mwave_open(struct inode *inode, struct file *file) PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_open, exit return retval %x\n", retval); - cycle_kernel_lock(); return retval; } @@ -136,9 +136,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_ioctl, IOCTL_MW_RESET" " calling tp3780I_ResetDSP\n"); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_ResetDSP(&pDrvData->rBDData); - unlock_kernel(); + mutex_unlock(&mwave_mutex); PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, IOCTL_MW_RESET" " retval %x from tp3780I_ResetDSP\n", @@ -149,9 +149,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_ioctl, IOCTL_MW_RUN" " calling tp3780I_StartDSP\n"); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_StartDSP(&pDrvData->rBDData); - unlock_kernel(); + mutex_unlock(&mwave_mutex); PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, IOCTL_MW_RUN" " retval %x from tp3780I_StartDSP\n", @@ -165,10 +165,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, "mwavedd::mwave_ioctl," " IOCTL_MW_DSP_ABILITIES calling" " tp3780I_QueryAbilities\n"); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_QueryAbilities(&pDrvData->rBDData, &rAbilities); - unlock_kernel(); + mutex_unlock(&mwave_mutex); PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" " retval %x from tp3780I_QueryAbilities\n", @@ -199,13 +199,13 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," " size %lx, ioarg %lx pusBuffer %p\n", rReadData.ulDataLength, ioarg, pusBuffer); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, iocmd, pusBuffer, rReadData.ulDataLength, rReadData.usDspAddress); - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; @@ -223,12 +223,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, " size %lx, ioarg %lx pusBuffer %p\n", rReadData.ulDataLength / 2, ioarg, pusBuffer); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, iocmd, pusBuffer, rReadData.ulDataLength / 2, rReadData.usDspAddress); - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; @@ -246,12 +246,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, " size %lx, ioarg %lx pusBuffer %p\n", rWriteData.ulDataLength, ioarg, pusBuffer); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, iocmd, pusBuffer, rWriteData.ulDataLength, rWriteData.usDspAddress); - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; @@ -269,12 +269,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, " size %lx, ioarg %lx pusBuffer %p\n", rWriteData.ulDataLength, ioarg, pusBuffer); - lock_kernel(); + mutex_lock(&mwave_mutex); retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, iocmd, pusBuffer, rWriteData.ulDataLength, rWriteData.usDspAddress); - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; @@ -295,10 +295,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, ipcnum, pDrvData->IPCs[ipcnum].usIntCount); - lock_kernel(); + mutex_lock(&mwave_mutex); pDrvData->IPCs[ipcnum].bIsHere = FALSE; pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; - unlock_kernel(); + mutex_unlock(&mwave_mutex); PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" @@ -323,7 +323,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, ipcnum, pDrvData->IPCs[ipcnum].usIntCount); - lock_kernel(); + mutex_lock(&mwave_mutex); if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { DECLARE_WAITQUEUE(wait, current); @@ -364,7 +364,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, " processing\n", ipcnum); } - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; @@ -383,14 +383,14 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd, ipcnum); return -EINVAL; } - lock_kernel(); + mutex_lock(&mwave_mutex); if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); } } - unlock_kernel(); + mutex_unlock(&mwave_mutex); } break; diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 66d2917b003f..166f1e7aaa7e 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c @@ -109,10 +109,11 @@ #include <linux/spinlock.h> #include <linux/io.h> #include <linux/uaccess.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/system.h> +static DEFINE_MUTEX(nvram_mutex); static DEFINE_SPINLOCK(nvram_state_lock); static int nvram_open_cnt; /* #times opened */ static int nvram_open_mode; /* special open modes */ @@ -308,7 +309,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - lock_kernel(); + mutex_lock(&nvram_mutex); spin_lock_irq(&rtc_lock); for (i = 0; i < NVRAM_BYTES; ++i) @@ -316,7 +317,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd, __nvram_set_checksum(); spin_unlock_irq(&rtc_lock); - unlock_kernel(); + mutex_unlock(&nvram_mutex); return 0; case NVRAM_SETCKS: @@ -325,11 +326,11 @@ static long nvram_ioctl(struct file *file, unsigned int cmd, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - lock_kernel(); + mutex_lock(&nvram_mutex); spin_lock_irq(&rtc_lock); __nvram_set_checksum(); spin_unlock_irq(&rtc_lock); - unlock_kernel(); + mutex_unlock(&nvram_mutex); return 0; default: diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index 043a1c7b86be..a12f52400dbc 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c @@ -25,7 +25,6 @@ #include <linux/spinlock.h> #include <linux/rwsem.h> #include <linux/init.h> -#include <linux/smp_lock.h> #include <linux/mutex.h> #include <linux/jiffies.h> @@ -41,6 +40,7 @@ #define NWFLASH_VERSION "6.4" +static DEFINE_MUTEX(flash_mutex); static void kick_open(void); static int get_flash_id(void); static int erase_block(int nBlock); @@ -96,7 +96,7 @@ static int get_flash_id(void) static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - lock_kernel(); + mutex_lock(&flash_mutex); switch (cmd) { case CMD_WRITE_DISABLE: gbWriteBase64Enable = 0; @@ -114,10 +114,10 @@ static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) default: gbWriteBase64Enable = 0; gbWriteEnable = 0; - unlock_kernel(); + mutex_unlock(&flash_mutex); return -EINVAL; } - unlock_kernel(); + mutex_unlock(&flash_mutex); return 0; } @@ -282,7 +282,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig) { loff_t ret; - lock_kernel(); + mutex_lock(&flash_mutex); if (flashdebug) printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", (unsigned int) offset, orig); @@ -317,7 +317,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig) default: ret = -EINVAL; } - unlock_kernel(); + mutex_unlock(&flash_mutex); return ret; } diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index c7b482d15e2a..c4e52ec85c6e 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -30,7 +30,7 @@ #include <linux/fs.h> #include <linux/delay.h> #include <linux/bitrev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/uaccess.h> #include <linux/io.h> @@ -54,6 +54,8 @@ __func__ , ## args); \ } while (0) +static DEFINE_MUTEX(cmm_mutex); + #define T_1SEC (HZ) #define T_10MSEC msecs_to_jiffies(10) #define T_20MSEC msecs_to_jiffies(20) @@ -1415,7 +1417,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) iminor(inode), ioctl_names[_IOC_NR(cmd)]); #endif - lock_kernel(); + mutex_lock(&cmm_mutex); rc = -ENODEV; link = dev_table[iminor(inode)]; if (!pcmcia_dev_present(link)) { @@ -1623,7 +1625,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) rc = -ENOTTY; } out: - unlock_kernel(); + mutex_unlock(&cmm_mutex); return rc; } @@ -1637,7 +1639,7 @@ static int cmm_open(struct inode *inode, struct file *filp) if (minor >= CM4000_MAX_DEV) return -ENODEV; - lock_kernel(); + mutex_lock(&cmm_mutex); link = dev_table[minor]; if (link == NULL || !pcmcia_dev_present(link)) { ret = -ENODEV; @@ -1682,7 +1684,7 @@ static int cmm_open(struct inode *inode, struct file *filp) DEBUGP(2, dev, "<- cmm_open\n"); ret = nonseekable_open(inode, filp); out: - unlock_kernel(); + mutex_unlock(&cmm_mutex); return ret; } diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index bf2f046fc2c1..d7c32cb40ca3 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -24,7 +24,7 @@ #include <linux/fs.h> #include <linux/delay.h> #include <linux/poll.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/wait.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -48,6 +48,8 @@ __func__ , ## args); \ } while (0) +static DEFINE_MUTEX(cm4040_mutex); + #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) #define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ) @@ -440,7 +442,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) if (minor >= CM_MAX_DEV) return -ENODEV; - lock_kernel(); + mutex_lock(&cm4040_mutex); link = dev_table[minor]; if (link == NULL || !pcmcia_dev_present(link)) { ret = -ENODEV; @@ -469,7 +471,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); ret = nonseekable_open(inode, filp); out: - unlock_kernel(); + mutex_unlock(&cm4040_mutex); return ret; } diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 02abfddce45a..723152d978a9 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -67,7 +67,7 @@ #include <linux/slab.h> #include <linux/major.h> #include <linux/ppdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/uaccess.h> #define PP_VERSION "ppdev: user-space parallel port driver" @@ -97,6 +97,7 @@ struct pp_struct { /* ROUND_UP macro from fs/select.c */ #define ROUND_UP(x,y) (((x)+(y)-1)/(y)) +static DEFINE_MUTEX(pp_do_mutex); static inline void pp_enable_irq (struct pp_struct *pp) { struct parport *port = pp->pdev->port; @@ -630,9 +631,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&pp_do_mutex); ret = pp_do_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&pp_do_mutex); return ret; } @@ -641,7 +642,6 @@ static int pp_open (struct inode * inode, struct file * file) unsigned int minor = iminor(inode); struct pp_struct *pp; - cycle_kernel_lock(); if (minor >= PARPORT_MAX) return -ENXIO; diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index d58c2eb07f07..e06a5977fdb2 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -44,7 +44,7 @@ #include <linux/delay.h> #include <linux/pci.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/miscdevice.h> #include <linux/init.h> @@ -122,6 +122,7 @@ more than 512 ports.... */ /* These constants are derived from SCO Source */ +static DEFINE_MUTEX(rio_fw_mutex); static struct Conf RIOConf = { /* locator */ "RIO Config here", @@ -566,9 +567,9 @@ static long rio_fw_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) func_enter(); /* The "dev" argument isn't used. */ - lock_kernel(); + mutex_lock(&rio_fw_mutex); rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); - unlock_kernel(); + mutex_unlock(&rio_fw_mutex); func_exit(); return rc; diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 32b74de18f5f..208e25731dfe 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c @@ -21,7 +21,7 @@ #include <linux/poll.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/sn/io.h> #include <asm/sn/sn_sal.h> #include <asm/sn/module.h> @@ -34,6 +34,7 @@ #define SCDRV_BUFSZ 2048 #define SCDRV_TIMEOUT 1000 +static DEFINE_MUTEX(scdrv_mutex); static irqreturn_t scdrv_interrupt(int irq, void *subch_data) { @@ -105,7 +106,7 @@ scdrv_open(struct inode *inode, struct file *file) file->private_data = sd; /* hook this subchannel up to the system controller interrupt */ - lock_kernel(); + mutex_lock(&scdrv_mutex); rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, IRQF_SHARED | IRQF_DISABLED, SYSCTL_BASENAME, sd); @@ -113,10 +114,10 @@ scdrv_open(struct inode *inode, struct file *file) ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); kfree(sd); printk("%s: irq request failed (%d)\n", __func__, rv); - unlock_kernel(); + mutex_unlock(&scdrv_mutex); return -EBUSY; } - unlock_kernel(); + mutex_unlock(&scdrv_mutex); return 0; } diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c index f8bc79f6de34..f8f09ab0b170 100644 --- a/drivers/char/toshiba.c +++ b/drivers/char/toshiba.c @@ -68,7 +68,7 @@ #include <linux/stat.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/toshiba.h> #define TOSH_MINOR_DEV 181 @@ -78,6 +78,7 @@ MODULE_AUTHOR("Jonathan Buzzard <jonathan@buzzard.org.uk>"); MODULE_DESCRIPTION("Toshiba laptop SMM driver"); MODULE_SUPPORTED_DEVICE("toshiba"); +static DEFINE_MUTEX(tosh_mutex); static int tosh_fn; module_param_named(fn, tosh_fn, int, 0); MODULE_PARM_DESC(fn, "User specified Fn key detection port"); @@ -274,16 +275,16 @@ static long tosh_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return -EINVAL; /* do we need to emulate the fan ? */ - lock_kernel(); + mutex_lock(&tosh_mutex); if (tosh_fan==1) { if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { err = tosh_emulate_fan(®s); - unlock_kernel(); + mutex_unlock(&tosh_mutex); break; } } err = tosh_smm(®s); - unlock_kernel(); + mutex_unlock(&tosh_mutex); break; default: return -EINVAL; diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index 42f7fa442ff8..6f954a808b65 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c @@ -46,7 +46,7 @@ #include <linux/completion.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <asm/uaccess.h> @@ -64,6 +64,7 @@ #define VIOTAPE_KERN_WARN KERN_WARNING "viotape: " #define VIOTAPE_KERN_INFO KERN_INFO "viotape: " +static DEFINE_MUTEX(proc_viotape_mutex); static int viotape_numdev; /* @@ -684,9 +685,9 @@ static long viotap_unlocked_ioctl(struct file *file, { long rc; - lock_kernel(); + mutex_lock(&proc_viotape_mutex); rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); - unlock_kernel(); + mutex_unlock(&proc_viotape_mutex); return rc; } @@ -700,7 +701,7 @@ static int viotap_open(struct inode *inode, struct file *file) if (op == NULL) return -ENOMEM; - lock_kernel(); + mutex_lock(&proc_viotape_mutex); get_dev_info(file->f_path.dentry->d_inode, &devi); /* Note: We currently only support one mode! */ @@ -731,7 +732,7 @@ static int viotap_open(struct inode *inode, struct file *file) free_op: free_op_struct(op); - unlock_kernel(); + mutex_unlock(&proc_viotape_mutex); return ret; } diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index b663d573aad9..d985204d76fe 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -81,7 +81,6 @@ #include <linux/poll.h> #include <linux/proc_fs.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/sysctl.h> #include <linux/fs.h> #include <linux/cdev.h> @@ -112,6 +111,7 @@ #define HWICAP_DEVICES 1 /* An array, which is set to true when the device is registered. */ +static DEFINE_MUTEX(hwicap_mutex); static bool probed_devices[HWICAP_DEVICES]; static struct mutex icap_sem; @@ -502,7 +502,7 @@ static int hwicap_open(struct inode *inode, struct file *file) struct hwicap_drvdata *drvdata; int status; - lock_kernel(); + mutex_lock(&hwicap_mutex); drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); status = mutex_lock_interruptible(&drvdata->sem); @@ -528,7 +528,7 @@ static int hwicap_open(struct inode *inode, struct file *file) error: mutex_unlock(&drvdata->sem); out: - unlock_kernel(); + mutex_unlock(&hwicap_mutex); return status; } diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index b7ca2a9676cf..d4d4ca65d371 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c @@ -38,7 +38,6 @@ #include <linux/i2c.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> -#include <linux/smp_lock.h> #include <linux/err.h> #include <linux/mutex.h> #include <linux/sysfs.h> @@ -50,6 +49,7 @@ #include <linux/kref.h> /* Addresses to scan */ +static DEFINE_MUTEX(watchdog_mutex); static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; /* Insmod parameters */ @@ -858,7 +858,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long ar int i, ret = 0; struct fschmd_data *data = filp->private_data; - lock_kernel(); + mutex_lock(&watchdog_mutex); switch (cmd) { case WDIOC_GETSUPPORT: ident.firmware_version = data->revision; @@ -915,7 +915,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long ar default: ret = -ENOTTY; } - unlock_kernel(); + mutex_unlock(&watchdog_mutex); return ret; } diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 697202e27891..8e540ada47d2 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c @@ -35,7 +35,6 @@ #include <linux/slab.h> #include <linux/i2c.h> #include <linux/hwmon.h> -#include <linux/smp_lock.h> #include <linux/hwmon-vid.h> #include <linux/hwmon-sysfs.h> #include <linux/err.h> @@ -52,6 +51,7 @@ #define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */ /* Addresses to scan */ +static DEFINE_MUTEX(watchdog_mutex); static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; @@ -1333,7 +1333,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, int val, ret = 0; struct w83793_data *data = filp->private_data; - lock_kernel(); + mutex_lock(&watchdog_mutex); switch (cmd) { case WDIOC_GETSUPPORT: if (!nowayout) @@ -1387,7 +1387,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, default: ret = -ENOTTY; } - unlock_kernel(); + mutex_unlock(&watchdog_mutex); return ret; } diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 31fc76960a8f..0c73fe39a236 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -31,7 +31,6 @@ #include <linux/delay.h> #include <linux/timer.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/errno.h> @@ -52,6 +51,7 @@ #include "ide-cd.h" +static DEFINE_MUTEX(ide_cd_mutex); static DEFINE_MUTEX(idecd_ref_mutex); static void ide_cd_release(struct device *); @@ -1602,7 +1602,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode) struct cdrom_info *info; int rc = -ENXIO; - lock_kernel(); + mutex_lock(&ide_cd_mutex); info = ide_cd_get(bdev->bd_disk); if (!info) goto out; @@ -1611,7 +1611,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode) if (rc < 0) ide_cd_put(info); out: - unlock_kernel(); + mutex_unlock(&ide_cd_mutex); return rc; } @@ -1619,11 +1619,11 @@ static int idecd_release(struct gendisk *disk, fmode_t mode) { struct cdrom_info *info = ide_drv_g(disk, cdrom_info); - lock_kernel(); + mutex_lock(&ide_cd_mutex); cdrom_release(&info->devinfo, mode); ide_cd_put(info); - unlock_kernel(); + mutex_unlock(&ide_cd_mutex); return 0; } @@ -1694,9 +1694,9 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode, { int ret; - lock_kernel(); + mutex_lock(&ide_cd_mutex); ret = idecd_locked_ioctl(bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&ide_cd_mutex); return ret; } diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c index ec94c66918f6..da36f729ff32 100644 --- a/drivers/ide/ide-disk_ioctl.c +++ b/drivers/ide/ide-disk_ioctl.c @@ -1,10 +1,11 @@ #include <linux/kernel.h> #include <linux/ide.h> #include <linux/hdreg.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include "ide-disk.h" +static DEFINE_MUTEX(ide_disk_ioctl_mutex); static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, @@ -19,13 +20,13 @@ int ide_disk_ioctl(ide_drive_t *drive, struct block_device *bdev, fmode_t mode, { int err; - lock_kernel(); + mutex_lock(&ide_disk_ioctl_mutex); err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); if (err != -EOPNOTSUPP) goto out; err = generic_ide_ioctl(drive, bdev, cmd, arg); out: - unlock_kernel(); + mutex_unlock(&ide_disk_ioctl_mutex); return err; } diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index fd3d05ab3417..d267b7affad6 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c @@ -5,7 +5,7 @@ #include <linux/kernel.h> #include <linux/ide.h> #include <linux/cdrom.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/unaligned.h> @@ -32,6 +32,7 @@ * On exit we set nformats to the number of records we've actually initialized. */ +static DEFINE_MUTEX(ide_floppy_ioctl_mutex); static int ide_floppy_get_format_capacities(ide_drive_t *drive, struct ide_atapi_pc *pc, int __user *arg) @@ -276,7 +277,7 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev, void __user *argp = (void __user *)arg; int err; - lock_kernel(); + mutex_lock(&ide_floppy_ioctl_mutex); if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { err = ide_floppy_lockdoor(drive, &pc, arg, cmd); goto out; @@ -298,6 +299,6 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev, err = generic_ide_ioctl(drive, bdev, cmd, arg); out: - unlock_kernel(); + mutex_unlock(&ide_floppy_ioctl_mutex); return err; } diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 70aeeb18833e..35c4b43585e3 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c @@ -1,4 +1,3 @@ -#include <linux/smp_lock.h> #include <linux/module.h> #include <linux/types.h> #include <linux/string.h> @@ -23,6 +22,7 @@ #define IDE_GD_VERSION "1.18" /* module parameters */ +static DEFINE_MUTEX(ide_gd_mutex); static unsigned long debug_mask; module_param(debug_mask, ulong, 0644); @@ -242,9 +242,9 @@ static int ide_gd_unlocked_open(struct block_device *bdev, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&ide_gd_mutex); ret = ide_gd_open(bdev, mode); - unlock_kernel(); + mutex_unlock(&ide_gd_mutex); return ret; } @@ -257,7 +257,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode) ide_debug_log(IDE_DBG_FUNC, "enter"); - lock_kernel(); + mutex_lock(&ide_gd_mutex); if (idkp->openers == 1) drive->disk_ops->flush(drive); @@ -269,7 +269,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode) idkp->openers--; ide_disk_put(idkp); - unlock_kernel(); + mutex_unlock(&ide_gd_mutex); return 0; } diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 6d622cb5ac81..65f0bcfb42ca 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -32,11 +32,9 @@ #include <linux/errno.h> #include <linux/genhd.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/ide.h> -#include <linux/smp_lock.h> #include <linux/completion.h> #include <linux/bitops.h> #include <linux/mutex.h> @@ -220,6 +218,7 @@ typedef struct ide_tape_obj { char write_prot; } idetape_tape_t; +static DEFINE_MUTEX(ide_tape_mutex); static DEFINE_MUTEX(idetape_ref_mutex); static DEFINE_MUTEX(idetape_chrdev_mutex); @@ -1426,9 +1425,9 @@ static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&ide_tape_mutex); ret = do_idetape_chrdev_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return ret; } @@ -1909,9 +1908,9 @@ static int idetape_open(struct block_device *bdev, fmode_t mode) { struct ide_tape_obj *tape; - lock_kernel(); + mutex_lock(&ide_tape_mutex); tape = ide_tape_get(bdev->bd_disk, false, 0); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); if (!tape) return -ENXIO; @@ -1923,9 +1922,9 @@ static int idetape_release(struct gendisk *disk, fmode_t mode) { struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); - lock_kernel(); + mutex_lock(&ide_tape_mutex); ide_tape_put(tape); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return 0; } @@ -1937,11 +1936,11 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode, ide_drive_t *drive = tape->drive; int err; - lock_kernel(); + mutex_lock(&ide_tape_mutex); err = generic_ide_ioctl(drive, bdev, cmd, arg); if (err == -EINVAL) err = idetape_blkdev_ioctl(drive, cmd, arg); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return err; } diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 7e2c12a5b839..0b4f54265f62 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -43,7 +43,7 @@ #include <linux/proc_fs.h> #include <linux/poll.h> #include <linux/rtc.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/semaphore.h> MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); @@ -52,6 +52,7 @@ MODULE_LICENSE("Dual BSD/GPL"); #define RTC_VERSION "1.10d" +static DEFINE_MUTEX(hp_sdc_rtc_mutex); static unsigned long epoch = 2000; static struct semaphore i8042tregs; @@ -665,9 +666,9 @@ static long hp_sdc_rtc_unlocked_ioctl(struct file *file, { int ret; - lock_kernel(); + mutex_lock(&hp_sdc_rtc_mutex); ret = hp_sdc_rtc_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&hp_sdc_rtc_mutex); return ret; } diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index bf64e49d996a..75049e765191 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -24,7 +24,6 @@ #include <linux/fs.h> #include <linux/mm.h> #include <linux/sched.h> -#include <linux/smp_lock.h> #include <linux/adb.h> #include <linux/cuda.h> #include <linux/pmu.h> @@ -55,6 +54,7 @@ extern struct adb_driver adb_iop_driver; extern struct adb_driver via_pmu_driver; extern struct adb_driver macio_adb_driver; +static DEFINE_MUTEX(adb_mutex); static struct adb_driver *adb_driver_list[] = { #ifdef CONFIG_ADB_MACII &via_macii_driver, @@ -647,7 +647,7 @@ static int adb_open(struct inode *inode, struct file *file) struct adbdev_state *state; int ret = 0; - lock_kernel(); + mutex_lock(&adb_mutex); if (iminor(inode) > 0 || adb_controller == NULL) { ret = -ENXIO; goto out; @@ -665,7 +665,7 @@ static int adb_open(struct inode *inode, struct file *file) state->inuse = 1; out: - unlock_kernel(); + mutex_unlock(&adb_mutex); return ret; } @@ -674,7 +674,7 @@ static int adb_release(struct inode *inode, struct file *file) struct adbdev_state *state = file->private_data; unsigned long flags; - lock_kernel(); + mutex_lock(&adb_mutex); if (state) { file->private_data = NULL; spin_lock_irqsave(&state->lock, flags); @@ -687,7 +687,7 @@ static int adb_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&state->lock, flags); } } - unlock_kernel(); + mutex_unlock(&adb_mutex); return 0; } diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index e58c3d33e035..290cb325a94c 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -19,7 +19,6 @@ * the userland interface */ -#include <linux/smp_lock.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/device.h> @@ -97,6 +96,7 @@ struct smu_device { * I don't think there will ever be more than one SMU, so * for now, just hard code that */ +static DEFINE_MUTEX(smu_mutex); static struct smu_device *smu; static DEFINE_MUTEX(smu_part_access); static int smu_irq_inited; @@ -1095,12 +1095,12 @@ static int smu_open(struct inode *inode, struct file *file) pp->mode = smu_file_commands; init_waitqueue_head(&pp->wait); - lock_kernel(); + mutex_lock(&smu_mutex); spin_lock_irqsave(&smu_clist_lock, flags); list_add(&pp->list, &smu_clist); spin_unlock_irqrestore(&smu_clist_lock, flags); file->private_data = pp; - unlock_kernel(); + mutex_unlock(&smu_mutex); return 0; } diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 2d17e76066bd..7b8b1de03db4 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -18,7 +18,7 @@ * */ #include <stdarg.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/kernel.h> @@ -73,6 +73,7 @@ /* How many iterations between battery polls */ #define BATTERY_POLLING_COUNT 2 +static DEFINE_MUTEX(pmu_info_proc_mutex); static volatile unsigned char __iomem *via; /* VIA registers - spaced 0x200 bytes apart */ @@ -2078,7 +2079,7 @@ pmu_open(struct inode *inode, struct file *file) pp->rb_get = pp->rb_put = 0; spin_lock_init(&pp->lock); init_waitqueue_head(&pp->wait); - lock_kernel(); + mutex_lock(&pmu_info_proc_mutex); spin_lock_irqsave(&all_pvt_lock, flags); #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) pp->backlight_locker = 0; @@ -2086,7 +2087,7 @@ pmu_open(struct inode *inode, struct file *file) list_add(&pp->list, &all_pmu_pvt); spin_unlock_irqrestore(&all_pvt_lock, flags); file->private_data = pp; - unlock_kernel(); + mutex_unlock(&pmu_info_proc_mutex); return 0; } @@ -2343,9 +2344,9 @@ static long pmu_unlocked_ioctl(struct file *filp, { int ret; - lock_kernel(); + mutex_lock(&pmu_info_proc_mutex); ret = pmu_ioctl(filp, cmd, arg); - unlock_kernel(); + mutex_unlock(&pmu_info_proc_mutex); return ret; } diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ac384b2a6a33..7967eca5a2d5 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -15,7 +15,6 @@ #include <linux/blkpg.h> #include <linux/bio.h> #include <linux/buffer_head.h> -#include <linux/smp_lock.h> #include <linux/mempool.h> #include <linux/slab.h> #include <linux/idr.h> @@ -33,6 +32,7 @@ #define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" #define DM_COOKIE_LENGTH 24 +static DEFINE_MUTEX(dm_mutex); static const char *_name = DM_NAME; static unsigned int major = 0; @@ -344,7 +344,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode) { struct mapped_device *md; - lock_kernel(); + mutex_lock(&dm_mutex); spin_lock(&_minor_lock); md = bdev->bd_disk->private_data; @@ -362,7 +362,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode) out: spin_unlock(&_minor_lock); - unlock_kernel(); + mutex_unlock(&dm_mutex); return md ? 0 : -ENXIO; } @@ -371,10 +371,10 @@ static int dm_blk_close(struct gendisk *disk, fmode_t mode) { struct mapped_device *md = disk->private_data; - lock_kernel(); + mutex_lock(&dm_mutex); atomic_dec(&md->open_count); dm_put(md); - unlock_kernel(); + mutex_unlock(&dm_mutex); return 0; } diff --git a/drivers/md/md.c b/drivers/md/md.c index f20d13e717d5..dbf822df942a 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -36,7 +36,7 @@ #include <linux/blkdev.h> #include <linux/sysctl.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/buffer_head.h> /* for invalidate_bdev */ #include <linux/poll.h> #include <linux/ctype.h> @@ -57,6 +57,7 @@ #define DEBUG 0 #define dprintk(x...) ((void)(DEBUG && printk(x))) +static DEFINE_MUTEX(md_mutex); #ifndef MODULE static void autostart_arrays(int part); @@ -5951,7 +5952,7 @@ static int md_open(struct block_device *bdev, fmode_t mode) mddev_t *mddev = mddev_find(bdev->bd_dev); int err; - lock_kernel(); + mutex_lock(&md_mutex); if (mddev->gendisk != bdev->bd_disk) { /* we are racing with mddev_put which is discarding this * bd_disk. @@ -5960,7 +5961,7 @@ static int md_open(struct block_device *bdev, fmode_t mode) /* Wait until bdev->bd_disk is definitely gone */ flush_scheduled_work(); /* Then retry the open from the top */ - unlock_kernel(); + mutex_unlock(&md_mutex); return -ERESTARTSYS; } BUG_ON(mddev != bdev->bd_disk->private_data); @@ -5974,7 +5975,7 @@ static int md_open(struct block_device *bdev, fmode_t mode) check_disk_size_change(mddev->gendisk, bdev); out: - unlock_kernel(); + mutex_unlock(&md_mutex); return err; } @@ -5983,10 +5984,10 @@ static int md_release(struct gendisk *disk, fmode_t mode) mddev_t *mddev = disk->private_data; BUG_ON(!mddev); - lock_kernel(); + mutex_lock(&md_mutex); atomic_dec(&mddev->openers); mddev_put(mddev); - unlock_kernel(); + mutex_unlock(&md_mutex); return 0; } diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index d3f1a087eced..02362eccc588 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -18,11 +18,12 @@ #include <linux/kthread.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/memstick.h> #define DRIVER_NAME "mspro_block" +static DEFINE_MUTEX(mspro_block_mutex); static int major; module_param(major, int, 0644); @@ -180,7 +181,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode) struct mspro_block_data *msb = disk->private_data; int rc = -ENXIO; - lock_kernel(); + mutex_lock(&mspro_block_mutex); mutex_lock(&mspro_block_disk_lock); if (msb && msb->card) { @@ -192,7 +193,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode) } mutex_unlock(&mspro_block_disk_lock); - unlock_kernel(); + mutex_unlock(&mspro_block_mutex); return rc; } @@ -225,9 +226,9 @@ static int mspro_block_disk_release(struct gendisk *disk) static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) { int ret; - lock_kernel(); + mutex_lock(&mspro_block_mutex); ret = mspro_block_disk_release(disk); - unlock_kernel(); + mutex_unlock(&mspro_block_mutex); return ret; } diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index d8ddfdf8be14..a3856ed90aef 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -54,7 +54,7 @@ #include <linux/pci.h> #include <linux/delay.h> /* for mdelay */ #include <linux/miscdevice.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/compat.h> #include <asm/io.h> @@ -83,6 +83,7 @@ MODULE_VERSION(my_VERSION); /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +static DEFINE_MUTEX(mpctl_mutex); static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; @@ -601,12 +602,12 @@ mptctl_fasync(int fd, struct file *filep, int mode) MPT_ADAPTER *ioc; int ret; - lock_kernel(); + mutex_lock(&mpctl_mutex); list_for_each_entry(ioc, &ioc_list, list) ioc->aen_event_read_flag=0; ret = fasync_helper(fd, filep, mode, &async_queue); - unlock_kernel(); + mutex_unlock(&mpctl_mutex); return ret; } @@ -698,9 +699,9 @@ static long mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&mpctl_mutex); ret = __mptctl_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&mpctl_mutex); return ret; } @@ -2926,7 +2927,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&mpctl_mutex); switch (cmd) { case MPTIOCINFO: case MPTIOCINFO1: @@ -2951,7 +2952,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a ret = -ENOIOCTLCMD; break; } - unlock_kernel(); + mutex_unlock(&mpctl_mutex); return ret; } diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index f0f1e667000f..f87a9d405a5e 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -53,7 +53,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/i2o.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/mempool.h> @@ -69,6 +69,7 @@ #define OSM_VERSION "1.325" #define OSM_DESCRIPTION "I2O Block Device OSM" +static DEFINE_MUTEX(i2o_block_mutex); static struct i2o_driver i2o_block_driver; /* global Block OSM request mempool */ @@ -578,7 +579,7 @@ static int i2o_block_open(struct block_device *bdev, fmode_t mode) if (!dev->i2o_dev) return -ENODEV; - lock_kernel(); + mutex_lock(&i2o_block_mutex); if (dev->power > 0x1f) i2o_block_device_power(dev, 0x02); @@ -587,7 +588,7 @@ static int i2o_block_open(struct block_device *bdev, fmode_t mode) i2o_block_device_lock(dev->i2o_dev, -1); osm_debug("Ready.\n"); - unlock_kernel(); + mutex_unlock(&i2o_block_mutex); return 0; }; @@ -618,7 +619,7 @@ static int i2o_block_release(struct gendisk *disk, fmode_t mode) if (!dev->i2o_dev) return 0; - lock_kernel(); + mutex_lock(&i2o_block_mutex); i2o_block_device_flush(dev->i2o_dev); i2o_block_device_unlock(dev->i2o_dev, -1); @@ -629,7 +630,7 @@ static int i2o_block_release(struct gendisk *disk, fmode_t mode) operation = 0x24; i2o_block_device_power(dev, operation); - unlock_kernel(); + mutex_unlock(&i2o_block_mutex); return 0; } @@ -664,7 +665,7 @@ static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode, if (!capable(CAP_SYS_ADMIN)) return -EPERM; - lock_kernel(); + mutex_lock(&i2o_block_mutex); switch (cmd) { case BLKI2OGRSTRAT: ret = put_user(dev->rcache, (int __user *)arg); @@ -688,7 +689,7 @@ static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode, ret = 0; break; } - unlock_kernel(); + mutex_unlock(&i2o_block_mutex); return ret; }; diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 068ba0785bb4..7d3cc575c361 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c @@ -31,7 +31,7 @@ */ #include <linux/miscdevice.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/compat.h> #include <linux/slab.h> @@ -41,6 +41,7 @@ #define SG_TABLESIZE 30 +static DEFINE_MUTEX(i2o_cfg_mutex); static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long); static spinlock_t i2o_config_lock; @@ -741,7 +742,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&i2o_cfg_mutex); switch (cmd) { case I2OGETIOPS: ret = i2o_cfg_ioctl(file, cmd, arg); @@ -753,7 +754,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, ret = -ENOIOCTLCMD; break; } - unlock_kernel(); + mutex_unlock(&i2o_cfg_mutex); return ret; } @@ -981,7 +982,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&i2o_cfg_mutex); switch (cmd) { case I2OGETIOPS: ret = i2o_cfg_getiops(arg); @@ -1037,7 +1038,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) osm_debug("unknown ioctl called!\n"); ret = -EINVAL; } - unlock_kernel(); + mutex_unlock(&i2o_cfg_mutex); return ret; } @@ -1051,7 +1052,7 @@ static int cfg_open(struct inode *inode, struct file *file) if (!tmp) return -ENOMEM; - lock_kernel(); + mutex_lock(&i2o_cfg_mutex); file->private_data = (void *)(i2o_cfg_info_id++); tmp->fp = file; tmp->fasync = NULL; @@ -1065,7 +1066,7 @@ static int cfg_open(struct inode *inode, struct file *file) spin_lock_irqsave(&i2o_config_lock, flags); open_files = tmp; spin_unlock_irqrestore(&i2o_config_lock, flags); - unlock_kernel(); + mutex_unlock(&i2o_cfg_mutex); return 0; } @@ -1076,14 +1077,14 @@ static int cfg_fasync(int fd, struct file *fp, int on) struct i2o_cfg_info *p; int ret = -EBADF; - lock_kernel(); + mutex_lock(&i2o_cfg_mutex); for (p = open_files; p; p = p->next) if (p->q_id == id) break; if (p) ret = fasync_helper(fd, fp, on, &p->fasync); - unlock_kernel(); + mutex_unlock(&i2o_cfg_mutex); return ret; } @@ -1093,7 +1094,7 @@ static int cfg_release(struct inode *inode, struct file *file) struct i2o_cfg_info *p, **q; unsigned long flags; - lock_kernel(); + mutex_lock(&i2o_cfg_mutex); spin_lock_irqsave(&i2o_config_lock, flags); for (q = &open_files; (p = *q) != NULL; q = &p->next) { if (p->q_id == id) { @@ -1103,7 +1104,7 @@ static int cfg_release(struct inode *inode, struct file *file) } } spin_unlock_irqrestore(&i2o_config_lock, flags); - unlock_kernel(); + mutex_unlock(&i2o_cfg_mutex); return 0; } diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 75ee0d3f6f45..3712e5077e25 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c @@ -24,7 +24,7 @@ #include <linux/slab.h> #include <linux/phantom.h> #include <linux/sched.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/atomic.h> #include <asm/io.h> @@ -38,6 +38,7 @@ #define PHB_RUNNING 1 #define PHB_NOT_OH 2 +static DEFINE_MUTEX(phantom_mutex); static struct class *phantom_class; static int phantom_major; @@ -215,17 +216,17 @@ static int phantom_open(struct inode *inode, struct file *file) struct phantom_device *dev = container_of(inode->i_cdev, struct phantom_device, cdev); - lock_kernel(); + mutex_lock(&phantom_mutex); nonseekable_open(inode, file); if (mutex_lock_interruptible(&dev->open_lock)) { - unlock_kernel(); + mutex_unlock(&phantom_mutex); return -ERESTARTSYS; } if (dev->opened) { mutex_unlock(&dev->open_lock); - unlock_kernel(); + mutex_unlock(&phantom_mutex); return -EINVAL; } @@ -236,7 +237,7 @@ static int phantom_open(struct inode *inode, struct file *file) atomic_set(&dev->counter, 0); dev->opened++; mutex_unlock(&dev->open_lock); - unlock_kernel(); + mutex_unlock(&phantom_mutex); return 0; } diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index d545f79f6000..00073b7c0368 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -29,7 +29,6 @@ #include <linux/kdev_t.h> #include <linux/blkdev.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/scatterlist.h> #include <linux/string_helpers.h> @@ -51,6 +50,7 @@ MODULE_ALIAS("mmc:block"); #define MMC_SHIFT 3 #define MMC_NUM_MINORS (256 >> MMC_SHIFT) +static DEFINE_MUTEX(block_mutex); static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); /* @@ -108,7 +108,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode) struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); int ret = -ENXIO; - lock_kernel(); + mutex_lock(&block_mutex); if (md) { if (md->usage == 2) check_disk_change(bdev); @@ -119,7 +119,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode) ret = -EROFS; } } - unlock_kernel(); + mutex_unlock(&block_mutex); return ret; } @@ -128,9 +128,9 @@ static int mmc_blk_release(struct gendisk *disk, fmode_t mode) { struct mmc_blk_data *md = disk->private_data; - lock_kernel(); + mutex_lock(&block_mutex); mmc_blk_put(md); - unlock_kernel(); + mutex_unlock(&block_mutex); return 0; } diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 62e68707b07f..50ab431b24eb 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -29,7 +29,6 @@ #include <linux/blkdev.h> #include <linux/blkpg.h> #include <linux/spinlock.h> -#include <linux/smp_lock.h> #include <linux/hdreg.h> #include <linux/init.h> #include <linux/mutex.h> @@ -38,6 +37,7 @@ #include "mtdcore.h" +static DEFINE_MUTEX(mtd_blkdevs_mutex); static LIST_HEAD(blktrans_majors); static DEFINE_MUTEX(blktrans_ref_mutex); @@ -181,7 +181,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) if (!dev) return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ - lock_kernel(); + mutex_lock(&mtd_blkdevs_mutex); mutex_lock(&dev->lock); if (!dev->mtd) { @@ -198,7 +198,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) unlock: mutex_unlock(&dev->lock); blktrans_dev_put(dev); - unlock_kernel(); + mutex_unlock(&mtd_blkdevs_mutex); return ret; } @@ -210,7 +210,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode) if (!dev) return ret; - lock_kernel(); + mutex_lock(&mtd_blkdevs_mutex); mutex_lock(&dev->lock); /* Release one reference, we sure its not the last one here*/ @@ -223,7 +223,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode) unlock: mutex_unlock(&dev->lock); blktrans_dev_put(dev); - unlock_kernel(); + mutex_unlock(&mtd_blkdevs_mutex); return ret; } @@ -256,7 +256,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode, if (!dev) return ret; - lock_kernel(); + mutex_lock(&mtd_blkdevs_mutex); mutex_lock(&dev->lock); if (!dev->mtd) @@ -271,7 +271,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode, } unlock: mutex_unlock(&dev->lock); - unlock_kernel(); + mutex_unlock(&mtd_blkdevs_mutex); blktrans_dev_put(dev); return ret; } diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index a825002123c8..5ef45487b65f 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -26,7 +26,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/sched.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/backing-dev.h> #include <linux/compat.h> #include <linux/mount.h> @@ -37,6 +37,7 @@ #include <asm/uaccess.h> #define MTD_INODE_FS_MAGIC 0x11307854 +static DEFINE_MUTEX(mtd_mutex); static struct vfsmount *mtd_inode_mnt __read_mostly; /* @@ -90,7 +91,7 @@ static int mtd_open(struct inode *inode, struct file *file) if ((file->f_mode & FMODE_WRITE) && (minor & 1)) return -EACCES; - lock_kernel(); + mutex_lock(&mtd_mutex); mtd = get_mtd_device(NULL, devnum); if (IS_ERR(mtd)) { @@ -138,7 +139,7 @@ static int mtd_open(struct inode *inode, struct file *file) file->private_data = mfi; out: - unlock_kernel(); + mutex_unlock(&mtd_mutex); return ret; } /* mtd_open */ @@ -866,9 +867,9 @@ static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) { int ret; - lock_kernel(); + mutex_lock(&mtd_mutex); ret = mtd_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&mtd_mutex); return ret; } @@ -892,7 +893,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd, void __user *argp = compat_ptr(arg); int ret = 0; - lock_kernel(); + mutex_lock(&mtd_mutex); switch (cmd) { case MEMWRITEOOB32: @@ -927,7 +928,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd, ret = mtd_ioctl(file, cmd, (unsigned long)argp); } - unlock_kernel(); + mutex_unlock(&mtd_mutex); return ret; } diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index 56215322930a..4cb30447a486 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c @@ -34,10 +34,11 @@ #include <linux/workqueue.h> #include <linux/pci.h> #include <linux/pci_hotplug.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/debugfs.h> #include "cpqphp.h" +static DEFINE_MUTEX(cpqphp_mutex); static int show_ctrl (struct controller *ctrl, char *buf) { char *out = buf; @@ -147,7 +148,7 @@ static int open(struct inode *inode, struct file *file) struct ctrl_dbg *dbg; int retval = -ENOMEM; - lock_kernel(); + mutex_lock(&cpqphp_mutex); dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); if (!dbg) goto exit; @@ -160,7 +161,7 @@ static int open(struct inode *inode, struct file *file) file->private_data = dbg; retval = 0; exit: - unlock_kernel(); + mutex_unlock(&cpqphp_mutex); return retval; } @@ -169,7 +170,7 @@ static loff_t lseek(struct file *file, loff_t off, int whence) struct ctrl_dbg *dbg; loff_t new = -1; - lock_kernel(); + mutex_lock(&cpqphp_mutex); dbg = file->private_data; switch (whence) { @@ -181,10 +182,10 @@ static loff_t lseek(struct file *file, loff_t off, int whence) break; } if (new < 0 || new > dbg->size) { - unlock_kernel(); + mutex_unlock(&cpqphp_mutex); return -EINVAL; } - unlock_kernel(); + mutex_unlock(&cpqphp_mutex); return (file->f_pos = new); } diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index d60557cae8ef..512dca16a42c 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c @@ -20,7 +20,7 @@ #include <linux/module.h> #include <linux/rtc.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/string.h> #ifdef CONFIG_RTC_DRV_M41T80_WDT #include <linux/fs.h> @@ -68,6 +68,7 @@ #define DRV_VERSION "0.05" +static DEFINE_MUTEX(m41t80_rtc_mutex); static const struct i2c_device_id m41t80_id[] = { { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, @@ -677,9 +678,9 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd, { int ret; - lock_kernel(); + mutex_lock(&m41t80_rtc_mutex); ret = wdt_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&m41t80_rtc_mutex); return ret; } @@ -693,16 +694,16 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd, static int wdt_open(struct inode *inode, struct file *file) { if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { - lock_kernel(); + mutex_lock(&m41t80_rtc_mutex); if (test_and_set_bit(0, &wdt_is_open)) { - unlock_kernel(); + mutex_unlock(&m41t80_rtc_mutex); return -EBUSY; } /* * Activate */ wdt_is_open = 1; - unlock_kernel(); + mutex_unlock(&m41t80_rtc_mutex); return nonseekable_open(inode, file); } return -ENODEV; diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c index 85cf607fc78f..f0fa9ca5cb2c 100644 --- a/drivers/s390/char/tape_block.c +++ b/drivers/s390/char/tape_block.c @@ -16,7 +16,7 @@ #include <linux/fs.h> #include <linux/module.h> #include <linux/blkdev.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/interrupt.h> #include <linux/buffer_head.h> #include <linux/kernel.h> @@ -45,6 +45,7 @@ /* * file operation structure for tape block frontend */ +static DEFINE_MUTEX(tape_block_mutex); static int tapeblock_open(struct block_device *, fmode_t); static int tapeblock_release(struct gendisk *, fmode_t); static int tapeblock_medium_changed(struct gendisk *); @@ -361,7 +362,7 @@ tapeblock_open(struct block_device *bdev, fmode_t mode) struct tape_device * device; int rc; - lock_kernel(); + mutex_lock(&tape_block_mutex); device = tape_get_device(disk->private_data); if (device->required_tapemarks) { @@ -385,14 +386,14 @@ tapeblock_open(struct block_device *bdev, fmode_t mode) * is called. */ tape_state_set(device, TS_BLKUSE); - unlock_kernel(); + mutex_unlock(&tape_block_mutex); return 0; release: tape_release(device); put_device: tape_put_device(device); - unlock_kernel(); + mutex_unlock(&tape_block_mutex); return rc; } @@ -407,11 +408,11 @@ tapeblock_release(struct gendisk *disk, fmode_t mode) { struct tape_device *device = disk->private_data; - lock_kernel(); + mutex_lock(&tape_block_mutex); tape_state_set(device, TS_IN_USE); tape_release(device); tape_put_device(device); - unlock_kernel(); + mutex_unlock(&tape_block_mutex); return 0; } diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 4942050dc5b6..13f48e28a1e1 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -27,7 +27,7 @@ */ #include <linux/module.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/miscdevice.h> @@ -68,6 +68,8 @@ #define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */ #define JSF_PART_MASK 0x3 /* 2 bits mask */ +static DEFINE_MUTEX(jsf_mutex); + /* * Access functions. * We could ioremap(), but it's easier this way. @@ -225,7 +227,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig) { loff_t ret; - lock_kernel(); + mutex_lock(&jsf_mutex); switch (orig) { case 0: file->f_pos = offset; @@ -238,7 +240,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig) default: ret = -EINVAL; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return ret; } @@ -384,18 +386,18 @@ static int jsf_ioctl_program(void __user *arg) static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) { - lock_kernel(); + mutex_lock(&jsf_mutex); int error = -ENOTTY; void __user *argp = (void __user *)arg; if (!capable(CAP_SYS_ADMIN)) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EPERM; } switch (cmd) { case JSFLASH_IDENT: if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EFAULT; } break; @@ -407,7 +409,7 @@ static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) break; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return error; } @@ -418,17 +420,17 @@ static int jsf_mmap(struct file * file, struct vm_area_struct * vma) static int jsf_open(struct inode * inode, struct file * filp) { - lock_kernel(); + mutex_lock(&jsf_mutex); if (jsf0.base == 0) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -ENXIO; } if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EBUSY; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return 0; /* XXX What security? */ } diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index e20b7bdd4c78..09a139f61ca4 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -92,7 +92,6 @@ #include <linux/pci.h> #include <linux/time.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <asm/io.h> #include <asm/irq.h> @@ -105,6 +104,7 @@ /* Globals */ #define TW_DRIVER_VERSION "2.26.02.014" +static DEFINE_MUTEX(twa_chrdev_mutex); static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; static unsigned int twa_device_extension_count; static int twa_major = -1; @@ -658,7 +658,7 @@ static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long int retval = TW_IOCTL_ERROR_OS_EFAULT; void __user *argp = (void __user *)arg; - lock_kernel(); + mutex_lock(&twa_chrdev_mutex); /* Only let one of these through at a time */ if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { @@ -879,7 +879,7 @@ out3: out2: mutex_unlock(&tw_dev->ioctl_lock); out: - unlock_kernel(); + mutex_unlock(&twa_chrdev_mutex); return retval; } /* End twa_chrdev_ioctl() */ @@ -890,7 +890,6 @@ static int twa_chrdev_open(struct inode *inode, struct file *file) unsigned int minor_number; int retval = TW_IOCTL_ERROR_OS_ENODEV; - cycle_kernel_lock(); minor_number = iminor(inode); if (minor_number >= twa_device_extension_count) goto out; diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index f481e734aad4..7e5f2385e3e6 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -64,7 +64,6 @@ #include <linux/pci.h> #include <linux/time.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <asm/io.h> #include <asm/irq.h> @@ -77,6 +76,7 @@ /* Globals */ #define TW_DRIVER_VERSION "3.26.02.000" +static DEFINE_MUTEX(twl_chrdev_mutex); static TW_Device_Extension *twl_device_extension_list[TW_MAX_SLOT]; static unsigned int twl_device_extension_count; static int twl_major = -1; @@ -764,7 +764,7 @@ static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long int retval = -EFAULT; void __user *argp = (void __user *)arg; - lock_kernel(); + mutex_lock(&twl_chrdev_mutex); /* Only let one of these through at a time */ if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { @@ -861,7 +861,7 @@ out3: out2: mutex_unlock(&tw_dev->ioctl_lock); out: - unlock_kernel(); + mutex_unlock(&twl_chrdev_mutex); return retval; } /* End twl_chrdev_ioctl() */ @@ -876,7 +876,6 @@ static int twl_chrdev_open(struct inode *inode, struct file *file) goto out; } - cycle_kernel_lock(); minor_number = iminor(inode); if (minor_number >= twl_device_extension_count) goto out; diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 30d735ad35b5..081c864c11d2 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -199,7 +199,6 @@ #include <linux/module.h> #include <linux/reboot.h> -#include <linux/smp_lock.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/moduleparam.h> @@ -221,6 +220,7 @@ /* Globals */ #define TW_DRIVER_VERSION "1.26.02.003" +static DEFINE_MUTEX(tw_mutex); static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT]; static int tw_device_extension_count = 0; static int twe_major = -1; @@ -900,10 +900,10 @@ static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long a dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); - lock_kernel(); + mutex_lock(&tw_mutex); /* Only let one of these through at a time */ if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { - unlock_kernel(); + mutex_unlock(&tw_mutex); return -EINTR; } @@ -1034,7 +1034,7 @@ out2: dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); out: mutex_unlock(&tw_dev->ioctl_lock); - unlock_kernel(); + mutex_unlock(&tw_mutex); return retval; } /* End tw_chrdev_ioctl() */ @@ -1044,7 +1044,6 @@ static int tw_chrdev_open(struct inode *inode, struct file *file) { unsigned int minor_number; - cycle_kernel_lock(); dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); minor_number = iminor(inode); diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index cad6f9abaeb9..6e233362dd7b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -38,7 +38,7 @@ #include <linux/moduleparam.h> #include <linux/pci.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/spinlock.h> #include <linux/syscalls.h> #include <linux/delay.h> @@ -76,6 +76,7 @@ MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, " MODULE_LICENSE("GPL"); MODULE_VERSION(AAC_DRIVER_FULL_VERSION); +static DEFINE_MUTEX(aac_mutex); static LIST_HEAD(aac_devices); static int aac_cfg_major = -1; char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; @@ -678,7 +679,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) unsigned minor_number = iminor(inode); int err = -ENODEV; - lock_kernel(); /* BKL pushdown: nothing else protects this list */ + mutex_lock(&aac_mutex); /* BKL pushdown: nothing else protects this list */ list_for_each_entry(aac, &aac_devices, entry) { if (aac->id == minor_number) { file->private_data = aac; @@ -686,7 +687,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) break; } } - unlock_kernel(); + mutex_unlock(&aac_mutex); return err; } @@ -711,9 +712,9 @@ static long aac_cfg_ioctl(struct file *file, int ret; if (!capable(CAP_SYS_RAWIO)) return -EPERM; - lock_kernel(); + mutex_lock(&aac_mutex); ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg); - unlock_kernel(); + mutex_unlock(&aac_mutex); return ret; } @@ -722,7 +723,7 @@ static long aac_cfg_ioctl(struct file *file, static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&aac_mutex); switch (cmd) { case FSACTL_MINIPORT_REV_CHECK: case FSACTL_SENDFIB: @@ -756,7 +757,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long ret = -ENOIOCTLCMD; break; } - unlock_kernel(); + mutex_unlock(&aac_mutex); return ret; } diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index d6532187f616..e805c8fda239 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -22,7 +22,6 @@ #include <linux/chio.h> /* here are all the ioctls */ #include <linux/mutex.h> #include <linux/idr.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <scsi/scsi.h> @@ -44,6 +43,7 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR); MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER); +static DEFINE_MUTEX(ch_mutex); static int init = 1; module_param(init, int, 0444); MODULE_PARM_DESC(init, \ @@ -581,19 +581,19 @@ ch_open(struct inode *inode, struct file *file) scsi_changer *ch; int minor = iminor(inode); - lock_kernel(); + mutex_lock(&ch_mutex); spin_lock(&ch_index_lock); ch = idr_find(&ch_index_idr, minor); if (NULL == ch || scsi_device_get(ch->device)) { spin_unlock(&ch_index_lock); - unlock_kernel(); + mutex_unlock(&ch_mutex); return -ENXIO; } spin_unlock(&ch_index_lock); file->private_data = ch; - unlock_kernel(); + mutex_unlock(&ch_mutex); return 0; } diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index ffc1edf5e80d..410ac1def8a6 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -49,7 +49,6 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); #include <linux/kernel.h> /* for printk */ #include <linux/sched.h> #include <linux/reboot.h> -#include <linux/smp_lock.h> #include <linux/spinlock.h> #include <linux/dma-mapping.h> @@ -76,6 +75,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); * Needed for our management apps *============================================================================ */ +static DEFINE_MUTEX(adpt_mutex); static dpt_sig_S DPTI_sig = { {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION, #ifdef __i386__ @@ -1732,12 +1732,12 @@ static int adpt_open(struct inode *inode, struct file *file) int minor; adpt_hba* pHba; - lock_kernel(); + mutex_lock(&adpt_mutex); //TODO check for root access // minor = iminor(inode); if (minor >= hba_count) { - unlock_kernel(); + mutex_unlock(&adpt_mutex); return -ENXIO; } mutex_lock(&adpt_configuration_lock); @@ -1748,7 +1748,7 @@ static int adpt_open(struct inode *inode, struct file *file) } if (pHba == NULL) { mutex_unlock(&adpt_configuration_lock); - unlock_kernel(); + mutex_unlock(&adpt_mutex); return -ENXIO; } @@ -1759,7 +1759,7 @@ static int adpt_open(struct inode *inode, struct file *file) pHba->in_use = 1; mutex_unlock(&adpt_configuration_lock); - unlock_kernel(); + mutex_unlock(&adpt_mutex); return 0; } @@ -2160,9 +2160,9 @@ static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg) inode = file->f_dentry->d_inode; - lock_kernel(); + mutex_lock(&adpt_mutex); ret = adpt_ioctl(inode, file, cmd, arg); - unlock_kernel(); + mutex_unlock(&adpt_mutex); return ret; } @@ -2176,7 +2176,7 @@ static long compat_adpt_ioctl(struct file *file, inode = file->f_dentry->d_inode; - lock_kernel(); + mutex_lock(&adpt_mutex); switch(cmd) { case DPT_SIGNATURE: @@ -2194,7 +2194,7 @@ static long compat_adpt_ioctl(struct file *file, ret = -ENOIOCTLCMD; } - unlock_kernel(); + mutex_unlock(&adpt_mutex); return ret; } diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index b860d650a563..e927607bbf89 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -120,7 +120,7 @@ #include <linux/timer.h> #include <linux/dma-mapping.h> #include <linux/list.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #ifdef GDTH_RTC @@ -140,6 +140,7 @@ #include <scsi/scsi_host.h> #include "gdth.h" +static DEFINE_MUTEX(gdth_mutex); static void gdth_delay(int milliseconds); static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); static irqreturn_t gdth_interrupt(int irq, void *dev_id); @@ -4042,12 +4043,12 @@ static int gdth_open(struct inode *inode, struct file *filep) { gdth_ha_str *ha; - lock_kernel(); + mutex_lock(&gdth_mutex); list_for_each_entry(ha, &gdth_instances, list) { if (!ha->sdev) ha->sdev = scsi_get_host_dev(ha->shost); } - unlock_kernel(); + mutex_unlock(&gdth_mutex); TRACE(("gdth_open()\n")); return 0; @@ -4615,9 +4616,9 @@ static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd, { int ret; - lock_kernel(); + mutex_lock(&gdth_mutex); ret = gdth_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&gdth_mutex); return ret; } diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 0b6e3228610a..4d0cf5cd82cc 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -46,7 +46,7 @@ #include <linux/pci.h> #include <linux/init.h> #include <linux/dma-mapping.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <scsi/scsicam.h> @@ -62,6 +62,7 @@ MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver"); MODULE_LICENSE ("GPL"); MODULE_VERSION(MEGARAID_MODULE_VERSION); +static DEFINE_MUTEX(megadev_mutex); static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; module_param(max_cmd_per_lun, uint, 0); MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); @@ -3282,7 +3283,6 @@ mega_init_scb(adapter_t *adapter) static int megadev_open (struct inode *inode, struct file *filep) { - cycle_kernel_lock(); /* * Only allow superuser to access private ioctl interface */ @@ -3701,9 +3701,9 @@ megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&megadev_mutex); ret = megadev_ioctl(filep, cmd, arg); - unlock_kernel(); + mutex_unlock(&megadev_mutex); return ret; } diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 41f82f76d884..42770a1e7b8a 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c @@ -16,11 +16,12 @@ */ #include <linux/sched.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include "megaraid_mm.h" // Entry points for char node driver +static DEFINE_MUTEX(mraid_mm_mutex); static int mraid_mm_open(struct inode *, struct file *); static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long); @@ -98,7 +99,6 @@ mraid_mm_open(struct inode *inode, struct file *filep) */ if (!capable(CAP_SYS_ADMIN)) return (-EACCES); - cycle_kernel_lock(); return 0; } @@ -224,9 +224,9 @@ mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd, int err; /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */ - lock_kernel(); + mutex_lock(&mraid_mm_mutex); err = mraid_mm_ioctl(filep, cmd, arg); - unlock_kernel(); + mutex_unlock(&mraid_mm_mutex); return err; } diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 99e4478c3f3e..c4a595d8d23a 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c @@ -33,7 +33,6 @@ #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/delay.h> -#include <linux/smp_lock.h> #include <linux/uio.h> #include <linux/slab.h> #include <asm/uaccess.h> @@ -3557,7 +3556,6 @@ static void megasas_shutdown(struct pci_dev *pdev) */ static int megasas_mgmt_open(struct inode *inode, struct file *filep) { - cycle_kernel_lock(); /* * Allow only those users with admin rights */ diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index b774973f0765..31cf126ed440 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c @@ -51,7 +51,7 @@ #include <linux/types.h> #include <linux/pci.h> #include <linux/delay.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/compat.h> #include <linux/poll.h> @@ -61,6 +61,7 @@ #include "mpt2sas_base.h" #include "mpt2sas_ctl.h" +static DEFINE_MUTEX(_ctl_mutex); static struct fasync_struct *async_queue; static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); @@ -2238,9 +2239,9 @@ _ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&_ctl_mutex); ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); - unlock_kernel(); + mutex_unlock(&_ctl_mutex); return ret; } @@ -2309,12 +2310,12 @@ _ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&_ctl_mutex); if (cmd == MPT2COMMAND32) ret = _ctl_compat_mpt_command(file, cmd, arg); else ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); - unlock_kernel(); + mutex_unlock(&_ctl_mutex); return ret; } #endif diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 278b352ae78d..54de1d1af1a7 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -51,7 +51,7 @@ static const char * osst_version = "0.99.4"; #include <linux/moduleparam.h> #include <linux/delay.h> #include <linux/jiffies.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <asm/uaccess.h> #include <asm/dma.h> #include <asm/system.h> @@ -80,6 +80,7 @@ static const char * osst_version = "0.99.4"; #include "osst_options.h" #include "osst_detect.h" +static DEFINE_MUTEX(osst_int_mutex); static int max_dev = 0; static int write_threshold_kbs = 0; static int max_sg_segs = 0; @@ -4807,9 +4808,9 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) { int ret; - lock_kernel(); + mutex_lock(&osst_int_mutex); ret = __os_scsi_tape_open(inode, filp); - unlock_kernel(); + mutex_unlock(&osst_int_mutex); return ret; } @@ -4943,9 +4944,9 @@ static long osst_ioctl(struct file * file, char * name = tape_name(STp); void __user * p = (void __user *)arg; - lock_kernel(); + mutex_lock(&osst_int_mutex); if (mutex_lock_interruptible(&STp->lock)) { - unlock_kernel(); + mutex_unlock(&osst_int_mutex); return -ERESTARTSYS; } @@ -5260,14 +5261,14 @@ static long osst_ioctl(struct file * file, mutex_unlock(&STp->lock); retval = scsi_ioctl(STp->device, cmd_in, p); - unlock_kernel(); + mutex_unlock(&osst_int_mutex); return retval; out: if (SRpnt) osst_release_request(SRpnt); mutex_unlock(&STp->lock); - unlock_kernel(); + mutex_unlock(&osst_int_mutex); return retval; } diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c index a87e21c35ef2..02034460babb 100644 --- a/drivers/scsi/scsi_tgt_if.c +++ b/drivers/scsi/scsi_tgt_if.c @@ -22,7 +22,6 @@ #include <linux/miscdevice.h> #include <linux/gfp.h> #include <linux/file.h> -#include <linux/smp_lock.h> #include <net/tcp.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -323,7 +322,6 @@ static int tgt_open(struct inode *inode, struct file *file) { tx_ring.tr_idx = rx_ring.tr_idx = 0; - cycle_kernel_lock(); return 0; } diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 78d616315d8e..b5507d59b5a6 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -49,7 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/blktrace_api.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include "scsi.h" #include <scsi/scsi_dbg.h> @@ -103,6 +103,8 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ; static int sg_add(struct device *, struct class_interface *); static void sg_remove(struct device *, struct class_interface *); +static DEFINE_MUTEX(sg_mutex); + static DEFINE_IDR(sg_index_idr); static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock file descriptor list for device */ @@ -229,7 +231,7 @@ sg_open(struct inode *inode, struct file *filp) int res; int retval; - lock_kernel(); + mutex_lock(&sg_mutex); nonseekable_open(inode, filp); SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); sdp = sg_get_dev(dev); @@ -314,7 +316,7 @@ sdp_put: sg_put: if (sdp) sg_put_dev(sdp); - unlock_kernel(); + mutex_unlock(&sg_mutex); return retval; } @@ -1092,9 +1094,9 @@ sg_unlocked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&sg_mutex); ret = sg_ioctl(filp, cmd_in, arg); - unlock_kernel(); + mutex_unlock(&sg_mutex); return ret; } diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index ba9c3e0387ce..e148341079b5 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -44,7 +44,6 @@ #include <linux/init.h> #include <linux/blkdev.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <asm/uaccess.h> @@ -76,6 +75,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM); CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ CDC_MRW|CDC_MRW_W|CDC_RAM) +static DEFINE_MUTEX(sr_mutex); static int sr_probe(struct device *); static int sr_remove(struct device *); static int sr_done(struct scsi_cmnd *); @@ -470,24 +470,24 @@ static int sr_block_open(struct block_device *bdev, fmode_t mode) struct scsi_cd *cd; int ret = -ENXIO; - lock_kernel(); + mutex_lock(&sr_mutex); cd = scsi_cd_get(bdev->bd_disk); if (cd) { ret = cdrom_open(&cd->cdi, bdev, mode); if (ret) scsi_cd_put(cd); } - unlock_kernel(); + mutex_unlock(&sr_mutex); return ret; } static int sr_block_release(struct gendisk *disk, fmode_t mode) { struct scsi_cd *cd = scsi_cd(disk); - lock_kernel(); + mutex_lock(&sr_mutex); cdrom_release(&cd->cdi, mode); scsi_cd_put(cd); - unlock_kernel(); + mutex_unlock(&sr_mutex); return 0; } @@ -499,7 +499,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, void __user *argp = (void __user *)arg; int ret; - lock_kernel(); + mutex_lock(&sr_mutex); /* * Send SCSI addressing ioctls directly to mid level, send other @@ -529,7 +529,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, ret = scsi_ioctl(sdev, cmd, argp); out: - unlock_kernel(); + mutex_unlock(&sr_mutex); return ret; } diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 24211d0efa6d..afdc3f5d915c 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -39,7 +39,6 @@ static const char *verstr = "20081215"; #include <linux/cdev.h> #include <linux/delay.h> #include <linux/mutex.h> -#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <asm/dma.h> @@ -76,6 +75,7 @@ static const char *verstr = "20081215"; #include "st_options.h" #include "st.h" +static DEFINE_MUTEX(st_mutex); static int buffer_kbs; static int max_sg_segs; static int try_direct_io = TRY_DIRECT_IO; @@ -1180,7 +1180,7 @@ static int st_open(struct inode *inode, struct file *filp) int dev = TAPE_NR(inode); char *name; - lock_kernel(); + mutex_lock(&st_mutex); /* * We really want to do nonseekable_open(inode, filp); here, but some * versions of tar incorrectly call lseek on tapes and bail out if that @@ -1189,7 +1189,7 @@ static int st_open(struct inode *inode, struct file *filp) filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); if (!(STp = scsi_tape_get(dev))) { - unlock_kernel(); + mutex_unlock(&st_mutex); return -ENXIO; } @@ -1200,7 +1200,7 @@ static int st_open(struct inode *inode, struct file *filp) if (STp->in_use) { write_unlock(&st_dev_arr_lock); scsi_tape_put(STp); - unlock_kernel(); + mutex_unlock(&st_mutex); DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) return (-EBUSY); } @@ -1249,14 +1249,14 @@ static int st_open(struct inode *inode, struct file *filp) retval = (-EIO); goto err_out; } - unlock_kernel(); + mutex_unlock(&st_mutex); return 0; err_out: normalize_buffer(STp->buffer); STp->in_use = 0; scsi_tape_put(STp); - unlock_kernel(); + mutex_unlock(&st_mutex); return retval; } diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index ff1d24720f11..8284297b30e9 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -25,7 +25,7 @@ #include <linux/major.h> #include <linux/delay.h> #include <linux/hdreg.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/slab.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> @@ -124,6 +124,7 @@ struct blkvsc_driver_context { }; /* Static decl */ +static DEFINE_MUTEX(blkvsc_mutex); static int blkvsc_probe(struct device *dev); static int blkvsc_remove(struct device *device); static void blkvsc_shutdown(struct device *device); @@ -1309,7 +1310,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode) DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, blkdev->gd->disk_name); - lock_kernel(); + mutex_lock(&blkvsc_mutex); spin_lock(&blkdev->lock); if (!blkdev->users && blkdev->device_type == DVD_TYPE) { @@ -1321,7 +1322,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode) blkdev->users++; spin_unlock(&blkdev->lock); - unlock_kernel(); + mutex_unlock(&blkvsc_mutex); return 0; } @@ -1332,7 +1333,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, blkdev->gd->disk_name); - lock_kernel(); + mutex_lock(&blkvsc_mutex); spin_lock(&blkdev->lock); if (blkdev->users == 1) { spin_unlock(&blkdev->lock); @@ -1343,7 +1344,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode) blkdev->users--; spin_unlock(&blkdev->lock); - unlock_kernel(); + mutex_unlock(&blkvsc_mutex); return 0; } diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c index fa21a0fd8e84..c7932da03c56 100644 --- a/drivers/staging/spectra/ffsport.c +++ b/drivers/staging/spectra/ffsport.c @@ -27,7 +27,6 @@ #include <linux/kthread.h> #include <linux/log2.h> #include <linux/init.h> -#include <linux/smp_lock.h> #include <linux/slab.h> /**** Helper functions used for Div, Remainder operation on u64 ****/ @@ -590,14 +589,16 @@ int GLOB_SBD_ioctl(struct block_device *bdev, fmode_t mode, return -ENOTTY; } +static DEFINE_MUTEX(ffsport_mutex); + int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { int ret; - lock_kernel(); + mutex_lock(&ffsport_mutex); ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg); - unlock_kernel(); + mutex_unlock(&ffsport_mutex); return ret; } diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index b53deee25d74..b1e469983b1d 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -257,7 +257,7 @@ #include <linux/fs.h> /* everything... */ #include <linux/errno.h> /* error codes */ #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/mm.h> #include <linux/ioport.h> #include <linux/interrupt.h> @@ -277,6 +277,7 @@ #define TYPE(inode) (iminor(inode) >> 4) #define NUM(inode) (iminor(inode) & 0xf) +static DEFINE_MUTEX(ixj_mutex); static int ixjdebug; static int hertz = HZ; static int samplerate = 100; @@ -6655,9 +6656,9 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&ixj_mutex); ret = do_ixj_ioctl(file_p, cmd, arg); - unlock_kernel(); + mutex_unlock(&ixj_mutex); return ret; } diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c index 566343b3c131..b7d96e6236a1 100644 --- a/drivers/watchdog/cpwd.c +++ b/drivers/watchdog/cpwd.c @@ -25,7 +25,7 @@ #include <linux/ioport.h> #include <linux/timer.h> #include <linux/slab.h> -#include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/io.h> #include <linux/of.h> #include <linux/of_device.h> @@ -89,6 +89,7 @@ struct cpwd { } devs[WD_NUMDEVS]; }; +static DEFINE_MUTEX(cpwd_mutex); static struct cpwd *cpwd_device; /* Sun uses Altera PLD EPF8820ATC144-4 @@ -368,7 +369,7 @@ static int cpwd_open(struct inode *inode, struct file *f) { struct cpwd *p = cpwd_device; - lock_kernel(); + mutex_lock(&cpwd_mutex); switch (iminor(inode)) { case WD0_MINOR: case WD1_MINOR: @@ -376,7 +377,7 @@ static int cpwd_open(struct inode *inode, struct file *f) break; default: - unlock_kernel(); + mutex_unlock(&cpwd_mutex); return -ENODEV; } @@ -386,13 +387,13 @@ static int cpwd_open(struct inode *inode, struct file *f) IRQF_SHARED, DRIVER_NAME, p)) { printk(KERN_ERR PFX "Cannot register IRQ %d\n", p->irq); - unlock_kernel(); + mutex_unlock(&cpwd_mutex); return -EBUSY; } p->initialized = true; } - unlock_kernel(); + mutex_unlock(&cpwd_mutex); return nonseekable_open(inode, f); } @@ -482,9 +483,9 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, case WIOCSTART: case WIOCSTOP: case WIOCGSTAT: - lock_kernel(); + mutex_lock(&cpwd_mutex); rval = cpwd_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&cpwd_mutex); break; /* everything else is handled by the generic compat layer */ |