[SCSI] sem2mutex 3w-[x9]xxx

Convert a the 3w-9xxx.c and 3w-xxxx.c drivers to use mutexes instead
of semaphores. Untested, but compiles and looks obviously correct.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Jes Sorensen 2006-01-11 08:39:45 -05:00 committed by James Bottomley
parent 3759b78849
commit a12e25bd59
4 changed files with 10 additions and 8 deletions

View File

@ -73,6 +73,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
@ -615,7 +616,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
/* Only let one of these through at a time */ /* Only let one of these through at a time */
if (down_interruptible(&tw_dev->ioctl_sem)) { if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
retval = TW_IOCTL_ERROR_OS_EINTR; retval = TW_IOCTL_ERROR_OS_EINTR;
goto out; goto out;
} }
@ -852,7 +853,7 @@ out3:
/* Now free ioctl buf memory */ /* Now free ioctl buf memory */
dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle); dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle);
out2: out2:
up(&tw_dev->ioctl_sem); mutex_unlock(&tw_dev->ioctl_lock);
out: out:
return retval; return retval;
} /* End twa_chrdev_ioctl() */ } /* End twa_chrdev_ioctl() */
@ -1182,7 +1183,7 @@ static int twa_initialize_device_extension(TW_Device_Extension *tw_dev)
tw_dev->error_sequence_id = 1; tw_dev->error_sequence_id = 1;
tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
init_MUTEX(&tw_dev->ioctl_sem); mutex_init(&tw_dev->ioctl_lock);
init_waitqueue_head(&tw_dev->ioctl_wqueue); init_waitqueue_head(&tw_dev->ioctl_wqueue);
retval = 0; retval = 0;

View File

@ -672,7 +672,7 @@ typedef struct TAG_TW_Device_Extension {
u32 ioctl_msec; u32 ioctl_msec;
int chrdev_request_id; int chrdev_request_id;
wait_queue_head_t ioctl_wqueue; wait_queue_head_t ioctl_wqueue;
struct semaphore ioctl_sem; struct mutex ioctl_lock;
char aen_clobber; char aen_clobber;
unsigned short working_srl; unsigned short working_srl;
unsigned short working_branch; unsigned short working_branch;

View File

@ -203,6 +203,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
@ -888,7 +889,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
/* Only let one of these through at a time */ /* Only let one of these through at a time */
if (down_interruptible(&tw_dev->ioctl_sem)) if (mutex_lock_interruptible(&tw_dev->ioctl_lock))
return -EINTR; return -EINTR;
/* First copy down the buffer length */ /* First copy down the buffer length */
@ -1029,7 +1030,7 @@ out2:
/* Now free ioctl buf memory */ /* Now free ioctl buf memory */
dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
out: out:
up(&tw_dev->ioctl_sem); mutex_unlock(&tw_dev->ioctl_lock);
return retval; return retval;
} /* End tw_chrdev_ioctl() */ } /* End tw_chrdev_ioctl() */
@ -1270,7 +1271,7 @@ static int tw_initialize_device_extension(TW_Device_Extension *tw_dev)
tw_dev->pending_tail = TW_Q_START; tw_dev->pending_tail = TW_Q_START;
tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
init_MUTEX(&tw_dev->ioctl_sem); mutex_init(&tw_dev->ioctl_lock);
init_waitqueue_head(&tw_dev->ioctl_wqueue); init_waitqueue_head(&tw_dev->ioctl_wqueue);
return 0; return 0;

View File

@ -420,7 +420,7 @@ typedef struct TAG_TW_Device_Extension {
u32 max_sector_count; u32 max_sector_count;
u32 aen_count; u32 aen_count;
struct Scsi_Host *host; struct Scsi_Host *host;
struct semaphore ioctl_sem; struct mutex ioctl_lock;
unsigned short aen_queue[TW_Q_LENGTH]; unsigned short aen_queue[TW_Q_LENGTH];
unsigned char aen_head; unsigned char aen_head;
unsigned char aen_tail; unsigned char aen_tail;