Skip to content

Commit

Permalink
[PATCH] sem2mutex: drivers/block/floppy.c
Browse files Browse the repository at this point in the history
Convert from semaphore to mutex.
Untested as I have no access to a floppy drive at the moment.

Signed-off-by: Jes Sorensen <jes@sgi.com>
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
Jes Sorensen authored and Linus Torvalds committed Mar 23, 2006
1 parent 1657f82 commit b1c82b5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static int print_unex = 1;
#include <linux/devfs_fs_kernel.h>
#include <linux/platform_device.h>
#include <linux/buffer_head.h> /* for invalidate_buffers() */
#include <linux/mutex.h>

/*
* PS/2 floppies have much slower step rates than regular floppies.
Expand Down Expand Up @@ -413,7 +414,7 @@ static struct floppy_write_errors write_errors[N_DRIVE];
static struct timer_list motor_off_timer[N_DRIVE];
static struct gendisk *disks[N_DRIVE];
static struct block_device *opened_bdev[N_DRIVE];
static DECLARE_MUTEX(open_lock);
static DEFINE_MUTEX(open_lock);
static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;

/*
Expand Down Expand Up @@ -3333,7 +3334,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
if (type) {
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
down(&open_lock);
mutex_lock(&open_lock);
LOCK_FDC(drive, 1);
floppy_type[type] = *g;
floppy_type[type].name = "user format";
Expand All @@ -3347,7 +3348,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
continue;
__invalidate_device(bdev);
}
up(&open_lock);
mutex_unlock(&open_lock);
} else {
int oldStretch;
LOCK_FDC(drive, 1);
Expand Down Expand Up @@ -3674,7 +3675,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
{
int drive = (long)inode->i_bdev->bd_disk->private_data;

down(&open_lock);
mutex_lock(&open_lock);
if (UDRS->fd_ref < 0)
UDRS->fd_ref = 0;
else if (!UDRS->fd_ref--) {
Expand All @@ -3684,7 +3685,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
if (!UDRS->fd_ref)
opened_bdev[drive] = NULL;
floppy_release_irq_and_dma();
up(&open_lock);
mutex_unlock(&open_lock);
return 0;
}

Expand All @@ -3702,7 +3703,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
char *tmp;

filp->private_data = (void *)0;
down(&open_lock);
mutex_lock(&open_lock);
old_dev = UDRS->fd_device;
if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
goto out2;
Expand Down Expand Up @@ -3785,7 +3786,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
goto out;
}
up(&open_lock);
mutex_unlock(&open_lock);
return 0;
out:
if (UDRS->fd_ref < 0)
Expand All @@ -3796,7 +3797,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
opened_bdev[drive] = NULL;
floppy_release_irq_and_dma();
out2:
up(&open_lock);
mutex_unlock(&open_lock);
return res;
}

Expand Down

0 comments on commit b1c82b5

Please sign in to comment.