Skip to content

Commit

Permalink
[PATCH] sem2mutex: drivers/block/loop.c
Browse files Browse the repository at this point in the history
Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Mar 23, 2006
1 parent 0ac1759 commit f85221d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ static int lo_ioctl(struct inode * inode, struct file * file,
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
int err;

down(&lo->lo_ctl_mutex);
mutex_lock(&lo->lo_ctl_mutex);
switch (cmd) {
case LOOP_SET_FD:
err = loop_set_fd(lo, file, inode->i_bdev, arg);
Expand All @@ -1170,17 +1170,17 @@ static int lo_ioctl(struct inode * inode, struct file * file,
default:
err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
}
up(&lo->lo_ctl_mutex);
mutex_unlock(&lo->lo_ctl_mutex);
return err;
}

static int lo_open(struct inode *inode, struct file *file)
{
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;

down(&lo->lo_ctl_mutex);
mutex_lock(&lo->lo_ctl_mutex);
lo->lo_refcnt++;
up(&lo->lo_ctl_mutex);
mutex_unlock(&lo->lo_ctl_mutex);

return 0;
}
Expand All @@ -1189,9 +1189,9 @@ static int lo_release(struct inode *inode, struct file *file)
{
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;

down(&lo->lo_ctl_mutex);
mutex_lock(&lo->lo_ctl_mutex);
--lo->lo_refcnt;
up(&lo->lo_ctl_mutex);
mutex_unlock(&lo->lo_ctl_mutex);

return 0;
}
Expand Down Expand Up @@ -1233,12 +1233,12 @@ int loop_unregister_transfer(int number)
xfer_funcs[n] = NULL;

for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) {
down(&lo->lo_ctl_mutex);
mutex_lock(&lo->lo_ctl_mutex);

if (lo->lo_encryption == xfer)
loop_release_xfer(lo);

up(&lo->lo_ctl_mutex);
mutex_unlock(&lo->lo_ctl_mutex);
}

return 0;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ static int __init loop_init(void)
lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
if (!lo->lo_queue)
goto out_mem4;
init_MUTEX(&lo->lo_ctl_mutex);
mutex_init(&lo->lo_ctl_mutex);
init_completion(&lo->lo_done);
init_completion(&lo->lo_bh_done);
lo->lo_number = i;
Expand Down
3 changes: 2 additions & 1 deletion include/linux/loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>

/* Possible states of device */
enum {
Expand Down Expand Up @@ -60,7 +61,7 @@ struct loop_device {
int lo_state;
struct completion lo_done;
struct completion lo_bh_done;
struct semaphore lo_ctl_mutex;
struct mutex lo_ctl_mutex;
int lo_pending;

request_queue_t *lo_queue;
Expand Down

0 comments on commit f85221d

Please sign in to comment.