1
0

[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:
Arjan van de Ven
2006-01-11 13:16:10 +01:00
committed by James Bottomley
parent dacee84b07
commit 0b95067238
17 changed files with 131 additions and 120 deletions

View File

@@ -44,6 +44,7 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <scsi/scsi.h>
@@ -90,7 +91,7 @@ static DEFINE_SPINLOCK(sr_index_lock);
/* This semaphore is used to mediate the 0->1 reference get in the
* face of object destruction (i.e. we can't allow a get on an
* object after last put) */
static DECLARE_MUTEX(sr_ref_sem);
static DEFINE_MUTEX(sr_ref_mutex);
static int sr_open(struct cdrom_device_info *, int);
static void sr_release(struct cdrom_device_info *);
@@ -133,7 +134,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
{
struct scsi_cd *cd = NULL;
down(&sr_ref_sem);
mutex_lock(&sr_ref_mutex);
if (disk->private_data == NULL)
goto out;
cd = scsi_cd(disk);
@@ -146,7 +147,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
kref_put(&cd->kref, sr_kref_release);
cd = NULL;
out:
up(&sr_ref_sem);
mutex_unlock(&sr_ref_mutex);
return cd;
}
@@ -154,10 +155,10 @@ static inline void scsi_cd_put(struct scsi_cd *cd)
{
struct scsi_device *sdev = cd->device;
down(&sr_ref_sem);
mutex_lock(&sr_ref_mutex);
kref_put(&cd->kref, sr_kref_release);
scsi_device_put(sdev);
up(&sr_ref_sem);
mutex_unlock(&sr_ref_mutex);
}
/*
@@ -845,7 +846,7 @@ static int sr_packet(struct cdrom_device_info *cdi,
* sr_kref_release - Called to free the scsi_cd structure
* @kref: pointer to embedded kref
*
* sr_ref_sem must be held entering this routine. Because it is
* sr_ref_mutex must be held entering this routine. Because it is
* called on last put, you should always use the scsi_cd_get()
* scsi_cd_put() helpers which manipulate the semaphore directly
* and never do a direct kref_put().
@@ -874,9 +875,9 @@ static int sr_remove(struct device *dev)
del_gendisk(cd->disk);
down(&sr_ref_sem);
mutex_lock(&sr_ref_mutex);
kref_put(&cd->kref, sr_kref_release);
up(&sr_ref_sem);
mutex_unlock(&sr_ref_mutex);
return 0;
}