Commit 28f85009 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by James Bottomley

[SCSI] st: Use mutex instead of semaphore

The SCSI Tape driver uses a semaphore as mutex. Use the mutex API
instead of the (binary) semaphore.
Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
Acked-by: default avatarKai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 0c6a89ba
...@@ -1485,7 +1485,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -1485,7 +1485,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
struct st_buffer *STbp; struct st_buffer *STbp;
char *name = tape_name(STp); char *name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (mutex_lock_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
retval = rw_checks(STp, filp, count); retval = rw_checks(STp, filp, count);
...@@ -1736,7 +1736,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -1736,7 +1736,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
if (SRpnt != NULL) if (SRpnt != NULL)
st_release_request(SRpnt); st_release_request(SRpnt);
release_buffering(STp, 0); release_buffering(STp, 0);
up(&STp->lock); mutex_unlock(&STp->lock);
return retval; return retval;
} }
...@@ -1942,7 +1942,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) ...@@ -1942,7 +1942,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
struct st_buffer *STbp = STp->buffer; struct st_buffer *STbp = STp->buffer;
DEB( char *name = tape_name(STp); ) DEB( char *name = tape_name(STp); )
if (down_interruptible(&STp->lock)) if (mutex_lock_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
retval = rw_checks(STp, filp, count); retval = rw_checks(STp, filp, count);
...@@ -2069,7 +2069,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) ...@@ -2069,7 +2069,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
release_buffering(STp, 1); release_buffering(STp, 1);
STbp->buffer_bytes = 0; STbp->buffer_bytes = 0;
} }
up(&STp->lock); mutex_unlock(&STp->lock);
return retval; return retval;
} }
...@@ -3226,7 +3226,7 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3226,7 +3226,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
char *name = tape_name(STp); char *name = tape_name(STp);
void __user *p = (void __user *)arg; void __user *p = (void __user *)arg;
if (down_interruptible(&STp->lock)) if (mutex_lock_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
DEB( DEB(
...@@ -3537,7 +3537,7 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3537,7 +3537,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
retval = (-EFAULT); retval = (-EFAULT);
goto out; goto out;
} }
up(&STp->lock); mutex_unlock(&STp->lock);
switch (cmd_in) { switch (cmd_in) {
case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_IDLUN:
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
...@@ -3563,7 +3563,7 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3563,7 +3563,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
return retval; return retval;
out: out:
up(&STp->lock); mutex_unlock(&STp->lock);
return retval; return retval;
} }
...@@ -4029,7 +4029,7 @@ static int st_probe(struct device *dev) ...@@ -4029,7 +4029,7 @@ static int st_probe(struct device *dev)
tpnt->density_changed = tpnt->compression_changed = tpnt->density_changed = tpnt->compression_changed =
tpnt->blksize_changed = 0; tpnt->blksize_changed = 0;
init_MUTEX(&tpnt->lock); mutex_init(&tpnt->lock);
st_nr_dev++; st_nr_dev++;
write_unlock(&st_dev_arr_lock); write_unlock(&st_dev_arr_lock);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define _ST_H #define _ST_H
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
...@@ -98,7 +99,7 @@ struct st_partstat { ...@@ -98,7 +99,7 @@ struct st_partstat {
struct scsi_tape { struct scsi_tape {
struct scsi_driver *driver; struct scsi_driver *driver;
struct scsi_device *device; struct scsi_device *device;
struct semaphore lock; /* For serialization */ struct mutex lock; /* For serialization */
struct completion wait; /* For SCSI commands */ struct completion wait; /* For SCSI commands */
struct st_buffer *buffer; struct st_buffer *buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment