From 0b9506723826c68b50fa33e345700ddcac1bed36 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Wed, 11 Jan 2006 13:16:10 +0100 Subject: [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 Signed-off-by: James Bottomley --- drivers/scsi/sd.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers/scsi/sd.c') diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4c5127ed379..fbd8e1bbad3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -111,7 +112,7 @@ static DEFINE_SPINLOCK(sd_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(sd_ref_sem); +static DEFINE_MUTEX(sd_ref_mutex); static int sd_revalidate_disk(struct gendisk *disk); static void sd_rw_intr(struct scsi_cmnd * SCpnt); @@ -193,9 +194,9 @@ static struct scsi_disk *scsi_disk_get(struct gendisk *disk) { struct scsi_disk *sdkp; - down(&sd_ref_sem); + mutex_lock(&sd_ref_mutex); sdkp = __scsi_disk_get(disk); - up(&sd_ref_sem); + mutex_unlock(&sd_ref_mutex); return sdkp; } @@ -203,11 +204,11 @@ static struct scsi_disk *scsi_disk_get_from_dev(struct device *dev) { struct scsi_disk *sdkp; - down(&sd_ref_sem); + mutex_lock(&sd_ref_mutex); sdkp = dev_get_drvdata(dev); if (sdkp) sdkp = __scsi_disk_get(sdkp->disk); - up(&sd_ref_sem); + mutex_unlock(&sd_ref_mutex); return sdkp; } @@ -215,10 +216,10 @@ static void scsi_disk_put(struct scsi_disk *sdkp) { struct scsi_device *sdev = sdkp->device; - down(&sd_ref_sem); + mutex_lock(&sd_ref_mutex); kref_put(&sdkp->kref, scsi_disk_release); scsi_device_put(sdev); - up(&sd_ref_sem); + mutex_unlock(&sd_ref_mutex); } /** @@ -1635,10 +1636,10 @@ static int sd_remove(struct device *dev) del_gendisk(sdkp->disk); sd_shutdown(dev); - down(&sd_ref_sem); + mutex_lock(&sd_ref_mutex); dev_set_drvdata(dev, NULL); kref_put(&sdkp->kref, scsi_disk_release); - up(&sd_ref_sem); + mutex_unlock(&sd_ref_mutex); return 0; } @@ -1647,7 +1648,7 @@ static int sd_remove(struct device *dev) * scsi_disk_release - Called to free the scsi_disk structure * @kref: pointer to embedded kref * - * sd_ref_sem must be held entering this routine. Because it is + * sd_ref_mutex must be held entering this routine. Because it is * called on last put, you should always use the scsi_disk_get() * scsi_disk_put() helpers which manipulate the semaphore directly * and never do a direct kref_put(). -- cgit v1.2.3