[SCSI] turn most scsi semaphores into mutexes
the scsi layer is using semaphores in a mutex way, this patch converts these into using mutexes instead Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
committed by
James Bottomley
parent
dacee84b07
commit
0b95067238
@ -22,6 +22,7 @@
|
||||
#include <linux/completion.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/chio.h> /* here are all the ioctls */
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_cmnd.h>
|
||||
@ -111,7 +112,7 @@ typedef struct {
|
||||
u_int counts[CH_TYPES];
|
||||
u_int unit_attention;
|
||||
u_int voltags;
|
||||
struct semaphore lock;
|
||||
struct mutex lock;
|
||||
} scsi_changer;
|
||||
|
||||
static LIST_HEAD(ch_devlist);
|
||||
@ -565,7 +566,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
|
||||
u_char data[16];
|
||||
unsigned int i;
|
||||
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
for (i = 0; i < ch->counts[type]; i++) {
|
||||
if (0 != ch_read_element_status
|
||||
(ch, ch->firsts[type]+i,data)) {
|
||||
@ -582,7 +583,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
|
||||
if (0 != retval)
|
||||
break;
|
||||
}
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -687,11 +688,11 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
dprintk("CHIOPOSITION: invalid parameter\n");
|
||||
return -EBADSLT;
|
||||
}
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
retval = ch_position(ch,0,
|
||||
ch->firsts[pos.cp_type] + pos.cp_unit,
|
||||
pos.cp_flags & CP_INVERT);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -708,12 +709,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
return -EBADSLT;
|
||||
}
|
||||
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
retval = ch_move(ch,0,
|
||||
ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
|
||||
ch->firsts[mv.cm_totype] + mv.cm_tounit,
|
||||
mv.cm_flags & CM_INVERT);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -731,14 +732,14 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
return -EBADSLT;
|
||||
}
|
||||
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
retval = ch_exchange
|
||||
(ch,0,
|
||||
ch->firsts[mv.ce_srctype] + mv.ce_srcunit,
|
||||
ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
|
||||
ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
|
||||
mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -772,7 +773,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
|
||||
if (!buffer)
|
||||
return -ENOMEM;
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
|
||||
voltag_retry:
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
@ -823,7 +824,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
goto voltag_retry;
|
||||
}
|
||||
kfree(buffer);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
|
||||
if (copy_to_user(argp, &cge, sizeof (cge)))
|
||||
return -EFAULT;
|
||||
@ -832,9 +833,9 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
|
||||
case CHIOINITELEM:
|
||||
{
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
retval = ch_init_elem(ch);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -851,12 +852,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
|
||||
return -EBADSLT;
|
||||
}
|
||||
elem = ch->firsts[csv.csv_type] + csv.csv_unit;
|
||||
down(&ch->lock);
|
||||
mutex_lock(&ch->lock);
|
||||
retval = ch_set_voltag(ch, elem,
|
||||
csv.csv_flags & CSV_AVOLTAG,
|
||||
csv.csv_flags & CSV_CLEARTAG,
|
||||
csv.csv_voltag);
|
||||
up(&ch->lock);
|
||||
mutex_unlock(&ch->lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -929,7 +930,7 @@ static int ch_probe(struct device *dev)
|
||||
memset(ch,0,sizeof(*ch));
|
||||
ch->minor = ch_devcount;
|
||||
sprintf(ch->name,"ch%d",ch->minor);
|
||||
init_MUTEX(&ch->lock);
|
||||
mutex_init(&ch->lock);
|
||||
ch->device = sd;
|
||||
ch_readconfig(ch);
|
||||
if (init)
|
||||
|
Reference in New Issue
Block a user