diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 17:31:38 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 17:31:38 -0800 |
commit | 80c0531514516e43ae118ddf38424e06e5c3cb3c (patch) | |
tree | 2eef8cf8fdf505b18f83078d1eb41167e98f5b54 /drivers | |
parent | a457aa6c2bdd743bbbffd3f9e4fdbd8c71f8af1b (diff) | |
parent | 11b751ae8c8ca3fa24c85bd5a3e51dd9f95cda17 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/mingo/mutex-2.6
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/loop.c | 31 | ||||
-rw-r--r-- | drivers/block/sx8.c | 12 | ||||
-rw-r--r-- | drivers/char/mem.c | 4 | ||||
-rw-r--r-- | drivers/char/sysrq.c | 19 | ||||
-rw-r--r-- | drivers/char/watchdog/cpu5wdt.c | 9 | ||||
-rw-r--r-- | drivers/ide/ide-probe.c | 4 | ||||
-rw-r--r-- | drivers/ide/ide.c | 8 | ||||
-rw-r--r-- | drivers/isdn/capi/capifs.c | 6 | ||||
-rw-r--r-- | drivers/md/dm.c | 4 | ||||
-rw-r--r-- | drivers/md/md.c | 8 | ||||
-rw-r--r-- | drivers/pci/proc.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/inode.c | 28 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/inode.c | 4 |
14 files changed, 81 insertions, 64 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a452b13620a2..864729046e22 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -215,7 +215,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, unsigned offset, bv_offs; int len, ret; - down(&mapping->host->i_sem); + mutex_lock(&mapping->host->i_mutex); index = pos >> PAGE_CACHE_SHIFT; offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1); bv_offs = bvec->bv_offset; @@ -278,7 +278,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, } ret = 0; out: - up(&mapping->host->i_sem); + mutex_unlock(&mapping->host->i_mutex); return ret; unlock: unlock_page(page); @@ -527,12 +527,12 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio) lo->lo_pending++; loop_add_bio(lo, old_bio); spin_unlock_irq(&lo->lo_lock); - up(&lo->lo_bh_mutex); + complete(&lo->lo_bh_done); return 0; out: if (lo->lo_pending == 0) - up(&lo->lo_bh_mutex); + complete(&lo->lo_bh_done); spin_unlock_irq(&lo->lo_lock); bio_io_error(old_bio, old_bio->bi_size); return 0; @@ -593,23 +593,20 @@ static int loop_thread(void *data) lo->lo_pending = 1; /* - * up sem, we are running + * complete it, we are running */ - up(&lo->lo_sem); + complete(&lo->lo_done); for (;;) { int pending; - /* - * interruptible just to not contribute to load avg - */ - if (down_interruptible(&lo->lo_bh_mutex)) + if (wait_for_completion_interruptible(&lo->lo_bh_done)) continue; spin_lock_irq(&lo->lo_lock); /* - * could be upped because of tear-down, not pending work + * could be completed because of tear-down, not pending work */ if (unlikely(!lo->lo_pending)) { spin_unlock_irq(&lo->lo_lock); @@ -632,7 +629,7 @@ static int loop_thread(void *data) break; } - up(&lo->lo_sem); + complete(&lo->lo_done); return 0; } @@ -843,7 +840,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, set_blocksize(bdev, lo_blocksize); kernel_thread(loop_thread, lo, CLONE_KERNEL); - down(&lo->lo_sem); + wait_for_completion(&lo->lo_done); return 0; out_putf: @@ -909,10 +906,10 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev) lo->lo_state = Lo_rundown; lo->lo_pending--; if (!lo->lo_pending) - up(&lo->lo_bh_mutex); + complete(&lo->lo_bh_done); spin_unlock_irq(&lo->lo_lock); - down(&lo->lo_sem); + wait_for_completion(&lo->lo_done); lo->lo_backing_file = NULL; @@ -1289,8 +1286,8 @@ static int __init loop_init(void) if (!lo->lo_queue) goto out_mem4; init_MUTEX(&lo->lo_ctl_mutex); - init_MUTEX_LOCKED(&lo->lo_sem); - init_MUTEX_LOCKED(&lo->lo_bh_mutex); + init_completion(&lo->lo_done); + init_completion(&lo->lo_bh_done); lo->lo_number = i; spin_lock_init(&lo->lo_lock); disk->major = LOOP_MAJOR; diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index c0cdc182a8b0..4bdf95716e2b 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -27,8 +27,8 @@ #include <linux/time.h> #include <linux/hdreg.h> #include <linux/dma-mapping.h> +#include <linux/completion.h> #include <asm/io.h> -#include <asm/semaphore.h> #include <asm/uaccess.h> #if 0 @@ -303,7 +303,7 @@ struct carm_host { struct work_struct fsm_task; - struct semaphore probe_sem; + struct completion probe_comp; }; struct carm_response { @@ -1346,7 +1346,7 @@ static void carm_fsm_task (void *_data) } case HST_PROBE_FINISHED: - up(&host->probe_sem); + complete(&host->probe_comp); break; case HST_ERROR: @@ -1622,7 +1622,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) host->flags = pci_dac ? FL_DAC : 0; spin_lock_init(&host->lock); INIT_WORK(&host->fsm_task, carm_fsm_task, host); - init_MUTEX_LOCKED(&host->probe_sem); + init_completion(&host->probe_comp); for (i = 0; i < ARRAY_SIZE(host->req); i++) host->req[i].tag = i; @@ -1691,8 +1691,8 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto err_out_free_irq; - DPRINTK("waiting for probe_sem\n"); - down(&host->probe_sem); + DPRINTK("waiting for probe_comp\n"); + wait_for_completion(&host->probe_comp); printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n", host->name, pci_name(pdev), (int) CARM_MAX_PORTS, diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 5b2d18035073..704c3c07f0ab 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -741,7 +741,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig) { loff_t ret; - down(&file->f_dentry->d_inode->i_sem); + mutex_lock(&file->f_dentry->d_inode->i_mutex); switch (orig) { case 0: file->f_pos = offset; @@ -756,7 +756,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig) default: ret = -EINVAL; } - up(&file->f_dentry->d_inode->i_sem); + mutex_unlock(&file->f_dentry->d_inode->i_mutex); return ret; } diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 145275ebdd7e..5765f672e853 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c @@ -153,6 +153,21 @@ static struct sysrq_key_op sysrq_mountro_op = { /* END SYNC SYSRQ HANDLERS BLOCK */ +#ifdef CONFIG_DEBUG_MUTEXES + +static void +sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, struct tty_struct *tty) +{ + mutex_debug_show_all_locks(); +} + +static struct sysrq_key_op sysrq_showlocks_op = { + .handler = sysrq_handle_showlocks, + .help_msg = "show-all-locks(D)", + .action_msg = "Show Locks Held", +}; + +#endif /* SHOW SYSRQ HANDLERS BLOCK */ @@ -294,7 +309,11 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = { #else /* c */ NULL, #endif +#ifdef CONFIG_DEBUG_MUTEXES +/* d */ &sysrq_showlocks_op, +#else /* d */ NULL, +#endif /* e */ &sysrq_term_op, /* f */ &sysrq_moom_op, /* g */ NULL, diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c index e75045fe2641..3e8410b5a65e 100644 --- a/drivers/char/watchdog/cpu5wdt.c +++ b/drivers/char/watchdog/cpu5wdt.c @@ -28,6 +28,7 @@ #include <linux/init.h> #include <linux/ioport.h> #include <linux/timer.h> +#include <linux/completion.h> #include <linux/jiffies.h> #include <asm/io.h> #include <asm/uaccess.h> @@ -57,7 +58,7 @@ static int ticks = 10000; /* some device data */ static struct { - struct semaphore stop; + struct completion stop; volatile int running; struct timer_list timer; volatile int queue; @@ -85,7 +86,7 @@ static void cpu5wdt_trigger(unsigned long unused) } else { /* ticks doesn't matter anyway */ - up(&cpu5wdt_device.stop); + complete(&cpu5wdt_device.stop); } } @@ -239,7 +240,7 @@ static int __devinit cpu5wdt_init(void) if ( !val ) printk(KERN_INFO PFX "sorry, was my fault\n"); - init_MUTEX_LOCKED(&cpu5wdt_device.stop); + init_completion(&cpu5wdt_device.stop); cpu5wdt_device.queue = 0; clear_bit(0, &cpu5wdt_device.inuse); @@ -269,7 +270,7 @@ static void __devexit cpu5wdt_exit(void) { if ( cpu5wdt_device.queue ) { cpu5wdt_device.queue = 0; - down(&cpu5wdt_device.stop); + wait_for_completion(&cpu5wdt_device.stop); } misc_deregister(&cpu5wdt_misc); diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 1ddaa71a8f45..7cb2d86601db 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -655,7 +655,7 @@ static void hwif_release_dev (struct device *dev) { ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); - up(&hwif->gendev_rel_sem); + complete(&hwif->gendev_rel_comp); } static void hwif_register (ide_hwif_t *hwif) @@ -1327,7 +1327,7 @@ static void drive_release_dev (struct device *dev) drive->queue = NULL; spin_unlock_irq(&ide_lock); - up(&drive->gendev_rel_sem); + complete(&drive->gendev_rel_comp); } /* diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index b069b13b75a7..ec5a4cb173b0 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -222,7 +222,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index) hwif->mwdma_mask = 0x80; /* disable all mwdma */ hwif->swdma_mask = 0x80; /* disable all swdma */ - sema_init(&hwif->gendev_rel_sem, 0); + init_completion(&hwif->gendev_rel_comp); default_hwif_iops(hwif); default_hwif_transport(hwif); @@ -245,7 +245,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index) drive->is_flash = 0; drive->vdma = 0; INIT_LIST_HEAD(&drive->list); - sema_init(&drive->gendev_rel_sem, 0); + init_completion(&drive->gendev_rel_comp); } } @@ -602,7 +602,7 @@ void ide_unregister(unsigned int index) } spin_unlock_irq(&ide_lock); device_unregister(&drive->gendev); - down(&drive->gendev_rel_sem); + wait_for_completion(&drive->gendev_rel_comp); spin_lock_irq(&ide_lock); } hwif->present = 0; @@ -662,7 +662,7 @@ void ide_unregister(unsigned int index) /* More messed up locking ... */ spin_unlock_irq(&ide_lock); device_unregister(&hwif->gendev); - down(&hwif->gendev_rel_sem); + wait_for_completion(&hwif->gendev_rel_comp); /* * Remove us from the kernel's knowledge diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c index 207cae366256..0a37aded4b54 100644 --- a/drivers/isdn/capi/capifs.c +++ b/drivers/isdn/capi/capifs.c @@ -138,7 +138,7 @@ static struct dentry *get_node(int num) { char s[10]; struct dentry *root = capifs_root; - down(&root->d_inode->i_sem); + mutex_lock(&root->d_inode->i_mutex); return lookup_one_len(s, root, sprintf(s, "%d", num)); } @@ -159,7 +159,7 @@ void capifs_new_ncci(unsigned int number, dev_t device) dentry = get_node(number); if (!IS_ERR(dentry) && !dentry->d_inode) d_instantiate(dentry, inode); - up(&capifs_root->d_inode->i_sem); + mutex_unlock(&capifs_root->d_inode->i_mutex); } void capifs_free_ncci(unsigned int number) @@ -175,7 +175,7 @@ void capifs_free_ncci(unsigned int number) } dput(dentry); } - up(&capifs_root->d_inode->i_sem); + mutex_unlock(&capifs_root->d_inode->i_mutex); } static int __init capifs_init(void) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 0e481512f918..5c210b0a4cb0 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -837,9 +837,9 @@ static void __set_size(struct mapped_device *md, sector_t size) { set_capacity(md->disk, size); - down(&md->suspended_bdev->bd_inode->i_sem); + mutex_lock(&md->suspended_bdev->bd_inode->i_mutex); i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); - up(&md->suspended_bdev->bd_inode->i_sem); + mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex); } static int __bind(struct mapped_device *md, struct dm_table *t) diff --git a/drivers/md/md.c b/drivers/md/md.c index e423a16ba3c9..0302723fa21f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3460,9 +3460,9 @@ static int update_size(mddev_t *mddev, unsigned long size) bdev = bdget_disk(mddev->gendisk, 0); if (bdev) { - down(&bdev->bd_inode->i_sem); + mutex_lock(&bdev->bd_inode->i_mutex); i_size_write(bdev->bd_inode, mddev->array_size << 10); - up(&bdev->bd_inode->i_sem); + mutex_unlock(&bdev->bd_inode->i_mutex); bdput(bdev); } } @@ -3486,9 +3486,9 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks) bdev = bdget_disk(mddev->gendisk, 0); if (bdev) { - down(&bdev->bd_inode->i_sem); + mutex_lock(&bdev->bd_inode->i_mutex); i_size_write(bdev->bd_inode, mddev->array_size << 10); - up(&bdev->bd_inode->i_sem); + mutex_unlock(&bdev->bd_inode->i_mutex); bdput(bdev); } } diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 9eb465727fce..9cb6dd0834be 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -25,7 +25,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence) loff_t new = -1; struct inode *inode = file->f_dentry->d_inode; - down(&inode->i_sem); + mutex_lock(&inode->i_mutex); switch (whence) { case 0: new = off; @@ -41,7 +41,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence) new = -EINVAL; else file->f_pos = new; - up(&inode->i_sem); + mutex_unlock(&inode->i_mutex); return new; } diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 4ddc453023a2..3cf945cc5b9a 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -184,13 +184,13 @@ static void update_bus(struct dentry *bus) bus->d_inode->i_gid = busgid; bus->d_inode->i_mode = S_IFDIR | busmode; - down(&bus->d_inode->i_sem); + mutex_lock(&bus->d_inode->i_mutex); list_for_each_entry(dev, &bus->d_subdirs, d_u.d_child) if (dev->d_inode) update_dev(dev); - up(&bus->d_inode->i_sem); + mutex_unlock(&bus->d_inode->i_mutex); } static void update_sb(struct super_block *sb) @@ -201,7 +201,7 @@ static void update_sb(struct super_block *sb) if (!root) return; - down(&root->d_inode->i_sem); + mutex_lock(&root->d_inode->i_mutex); list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) { if (bus->d_inode) { @@ -219,7 +219,7 @@ static void update_sb(struct super_block *sb) } } - up(&root->d_inode->i_sem); + mutex_unlock(&root->d_inode->i_mutex); } static int remount(struct super_block *sb, int *flags, char *data) @@ -333,10 +333,10 @@ static int usbfs_empty (struct dentry *dentry) static int usbfs_unlink (struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; - down(&inode->i_sem); + mutex_lock(&inode->i_mutex); dentry->d_inode->i_nlink--; dput(dentry); - up(&inode->i_sem); + mutex_unlock(&inode->i_mutex); d_delete(dentry); return 0; } @@ -346,7 +346,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry) int error = -ENOTEMPTY; struct inode * inode = dentry->d_inode; - down(&inode->i_sem); + mutex_lock(&inode->i_mutex); dentry_unhash(dentry); if (usbfs_empty(dentry)) { dentry->d_inode->i_nlink -= 2; @@ -355,7 +355,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry) dir->i_nlink--; error = 0; } - up(&inode->i_sem); + mutex_unlock(&inode->i_mutex); if (!error) d_delete(dentry); dput(dentry); @@ -380,7 +380,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig) { loff_t retval = -EINVAL; - down(&file->f_dentry->d_inode->i_sem); + mutex_lock(&file->f_dentry->d_inode->i_mutex); switch(orig) { case 0: if (offset > 0) { @@ -397,7 +397,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig) default: break; } - up(&file->f_dentry->d_inode->i_sem); + mutex_unlock(&file->f_dentry->d_inode->i_mutex); return retval; } @@ -480,7 +480,7 @@ static int fs_create_by_name (const char *name, mode_t mode, } *dentry = NULL; - down(&parent->d_inode->i_sem); + mutex_lock(&parent->d_inode->i_mutex); *dentry = lookup_one_len(name, parent, strlen(name)); if (!IS_ERR(dentry)) { if ((mode & S_IFMT) == S_IFDIR) @@ -489,7 +489,7 @@ static int fs_create_by_name (const char *name, mode_t mode, error = usbfs_create (parent->d_inode, *dentry, mode); } else error = PTR_ERR(dentry); - up(&parent->d_inode->i_sem); + mutex_unlock(&parent->d_inode->i_mutex); return error; } @@ -528,7 +528,7 @@ static void fs_remove_file (struct dentry *dentry) if (!parent || !parent->d_inode) return; - down(&parent->d_inode->i_sem); + mutex_lock(&parent->d_inode->i_mutex); if (usbfs_positive(dentry)) { if (dentry->d_inode) { if (S_ISDIR(dentry->d_inode->i_mode)) @@ -538,7 +538,7 @@ static void fs_remove_file (struct dentry *dentry) dput(dentry); } } - up(&parent->d_inode->i_sem); + mutex_unlock(&parent->d_inode->i_mutex); } /* --------------------------------------------------------------------- */ diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 0cea9782d7d4..de59c58896d6 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -1891,7 +1891,7 @@ static int fsync_sub(struct lun *curlun) return -EINVAL; inode = filp->f_dentry->d_inode; - down(&inode->i_sem); + mutex_lock(&inode->i_mutex); current->flags |= PF_SYNCWRITE; rc = filemap_fdatawrite(inode->i_mapping); err = filp->f_op->fsync(filp, filp->f_dentry, 1); @@ -1901,7 +1901,7 @@ static int fsync_sub(struct lun *curlun) if (!rc) rc = err; current->flags &= ~PF_SYNCWRITE; - up(&inode->i_sem); + mutex_unlock(&inode->i_mutex); VLDBG(curlun, "fdatasync -> %d\n", rc); return rc; } diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 5c40980a5bd9..c6c279de832e 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1562,10 +1562,10 @@ restart: spin_unlock_irq (&dev->lock); /* break link to dcache */ - down (&parent->i_sem); + mutex_lock (&parent->i_mutex); d_delete (dentry); dput (dentry); - up (&parent->i_sem); + mutex_unlock (&parent->i_mutex); /* fds may still be open */ goto restart; |