At a slight footprint cost (24 vs 32 bytes), mutexes are more optimal than semaphores; it's also a nicer interface for mutual exclusion, which is why they are encouraged over binary semaphores, when possible. Replace the buffered_ioctl_sem, its semantics implies traditional lock ownership; that is, the lock owner is the same for both lock/unlock operations. Therefore it is safe to convert. Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx> --- This is in an effort to reduce semaphore users in the kernel. Compile-tested only. drivers/scsi/esas2r/esas2r_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c index 442c5e70a7b4..aad352fe27cf 100644 --- a/drivers/scsi/esas2r/esas2r_ioctl.c +++ b/drivers/scsi/esas2r/esas2r_ioctl.c @@ -56,7 +56,7 @@ dma_addr_t esas2r_buffered_ioctl_addr; u32 esas2r_buffered_ioctl_size; struct pci_dev *esas2r_buffered_ioctl_pcid; -static DEFINE_SEMAPHORE(buffered_ioctl_semaphore); +static DEFINE_MUTEX(buffered_ioctl_mutex); typedef int (*BUFFERED_IOCTL_CALLBACK)(struct esas2r_adapter *, struct esas2r_request *, struct esas2r_sg_context *, @@ -209,7 +209,7 @@ static u8 handle_buffered_ioctl(struct esas2r_buffered_ioctl *bi) struct esas2r_sg_context sgc; u8 result = IOCTL_SUCCESS; - if (down_interruptible(&buffered_ioctl_semaphore)) + if (mutex_lock_interruptible(&buffered_ioctl_mutex)) return IOCTL_OUT_OF_RESOURCES; /* allocate a buffer or use the existing buffer. */ @@ -285,7 +285,7 @@ static u8 handle_buffered_ioctl(struct esas2r_buffered_ioctl *bi) if (result == IOCTL_SUCCESS) memcpy(bi->ioctl, esas2r_buffered_ioctl, bi->length); - up(&buffered_ioctl_semaphore); + mutex_unlock(&buffered_ioctl_mutex); return result; } -- 2.16.4