aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ch.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 07:16:10 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2006-01-12 12:53:11 -0500
commit0b9506723826c68b50fa33e345700ddcac1bed36 (patch)
treeda3e432ef4517c47ebdc088c6322d0ac51193127 /drivers/scsi/ch.c
parentdacee84b070c4e705a5b6446f1f0a6a6e2f8d7a4 (diff)
[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>
Diffstat (limited to 'drivers/scsi/ch.c')
-rw-r--r--drivers/scsi/ch.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 4299fabca554..c3f27285db1b 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -22,6 +22,7 @@
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/compat.h> 23#include <linux/compat.h>
24#include <linux/chio.h> /* here are all the ioctls */ 24#include <linux/chio.h> /* here are all the ioctls */
25#include <linux/mutex.h>
25 26
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h> 28#include <scsi/scsi_cmnd.h>
@@ -111,7 +112,7 @@ typedef struct {
111 u_int counts[CH_TYPES]; 112 u_int counts[CH_TYPES];
112 u_int unit_attention; 113 u_int unit_attention;
113 u_int voltags; 114 u_int voltags;
114 struct semaphore lock; 115 struct mutex lock;
115} scsi_changer; 116} scsi_changer;
116 117
117static LIST_HEAD(ch_devlist); 118static LIST_HEAD(ch_devlist);
@@ -565,7 +566,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
565 u_char data[16]; 566 u_char data[16];
566 unsigned int i; 567 unsigned int i;
567 568
568 down(&ch->lock); 569 mutex_lock(&ch->lock);
569 for (i = 0; i < ch->counts[type]; i++) { 570 for (i = 0; i < ch->counts[type]; i++) {
570 if (0 != ch_read_element_status 571 if (0 != ch_read_element_status
571 (ch, ch->firsts[type]+i,data)) { 572 (ch, ch->firsts[type]+i,data)) {
@@ -582,7 +583,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest)
582 if (0 != retval) 583 if (0 != retval)
583 break; 584 break;
584 } 585 }
585 up(&ch->lock); 586 mutex_unlock(&ch->lock);
586 return retval; 587 return retval;
587} 588}
588 589
@@ -687,11 +688,11 @@ static int ch_ioctl(struct inode * inode, struct file * file,
687 dprintk("CHIOPOSITION: invalid parameter\n"); 688 dprintk("CHIOPOSITION: invalid parameter\n");
688 return -EBADSLT; 689 return -EBADSLT;
689 } 690 }
690 down(&ch->lock); 691 mutex_lock(&ch->lock);
691 retval = ch_position(ch,0, 692 retval = ch_position(ch,0,
692 ch->firsts[pos.cp_type] + pos.cp_unit, 693 ch->firsts[pos.cp_type] + pos.cp_unit,
693 pos.cp_flags & CP_INVERT); 694 pos.cp_flags & CP_INVERT);
694 up(&ch->lock); 695 mutex_unlock(&ch->lock);
695 return retval; 696 return retval;
696 } 697 }
697 698
@@ -708,12 +709,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
708 return -EBADSLT; 709 return -EBADSLT;
709 } 710 }
710 711
711 down(&ch->lock); 712 mutex_lock(&ch->lock);
712 retval = ch_move(ch,0, 713 retval = ch_move(ch,0,
713 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit, 714 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
714 ch->firsts[mv.cm_totype] + mv.cm_tounit, 715 ch->firsts[mv.cm_totype] + mv.cm_tounit,
715 mv.cm_flags & CM_INVERT); 716 mv.cm_flags & CM_INVERT);
716 up(&ch->lock); 717 mutex_unlock(&ch->lock);
717 return retval; 718 return retval;
718 } 719 }
719 720
@@ -731,14 +732,14 @@ static int ch_ioctl(struct inode * inode, struct file * file,
731 return -EBADSLT; 732 return -EBADSLT;
732 } 733 }
733 734
734 down(&ch->lock); 735 mutex_lock(&ch->lock);
735 retval = ch_exchange 736 retval = ch_exchange
736 (ch,0, 737 (ch,0,
737 ch->firsts[mv.ce_srctype] + mv.ce_srcunit, 738 ch->firsts[mv.ce_srctype] + mv.ce_srcunit,
738 ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit, 739 ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
739 ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit, 740 ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
740 mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2); 741 mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
741 up(&ch->lock); 742 mutex_unlock(&ch->lock);
742 return retval; 743 return retval;
743 } 744 }
744 745
@@ -772,7 +773,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
772 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 773 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
773 if (!buffer) 774 if (!buffer)
774 return -ENOMEM; 775 return -ENOMEM;
775 down(&ch->lock); 776 mutex_lock(&ch->lock);
776 777
777 voltag_retry: 778 voltag_retry:
778 memset(cmd,0,sizeof(cmd)); 779 memset(cmd,0,sizeof(cmd));
@@ -823,7 +824,7 @@ static int ch_ioctl(struct inode * inode, struct file * file,
823 goto voltag_retry; 824 goto voltag_retry;
824 } 825 }
825 kfree(buffer); 826 kfree(buffer);
826 up(&ch->lock); 827 mutex_unlock(&ch->lock);
827 828
828 if (copy_to_user(argp, &cge, sizeof (cge))) 829 if (copy_to_user(argp, &cge, sizeof (cge)))
829 return -EFAULT; 830 return -EFAULT;
@@ -832,9 +833,9 @@ static int ch_ioctl(struct inode * inode, struct file * file,
832 833
833 case CHIOINITELEM: 834 case CHIOINITELEM:
834 { 835 {
835 down(&ch->lock); 836 mutex_lock(&ch->lock);
836 retval = ch_init_elem(ch); 837 retval = ch_init_elem(ch);
837 up(&ch->lock); 838 mutex_unlock(&ch->lock);
838 return retval; 839 return retval;
839 } 840 }
840 841
@@ -851,12 +852,12 @@ static int ch_ioctl(struct inode * inode, struct file * file,
851 return -EBADSLT; 852 return -EBADSLT;
852 } 853 }
853 elem = ch->firsts[csv.csv_type] + csv.csv_unit; 854 elem = ch->firsts[csv.csv_type] + csv.csv_unit;
854 down(&ch->lock); 855 mutex_lock(&ch->lock);
855 retval = ch_set_voltag(ch, elem, 856 retval = ch_set_voltag(ch, elem,
856 csv.csv_flags & CSV_AVOLTAG, 857 csv.csv_flags & CSV_AVOLTAG,
857 csv.csv_flags & CSV_CLEARTAG, 858 csv.csv_flags & CSV_CLEARTAG,
858 csv.csv_voltag); 859 csv.csv_voltag);
859 up(&ch->lock); 860 mutex_unlock(&ch->lock);
860 return retval; 861 return retval;
861 } 862 }
862 863
@@ -929,7 +930,7 @@ static int ch_probe(struct device *dev)
929 memset(ch,0,sizeof(*ch)); 930 memset(ch,0,sizeof(*ch));
930 ch->minor = ch_devcount; 931 ch->minor = ch_devcount;
931 sprintf(ch->name,"ch%d",ch->minor); 932 sprintf(ch->name,"ch%d",ch->minor);
932 init_MUTEX(&ch->lock); 933 mutex_init(&ch->lock);
933 ch->device = sd; 934 ch->device = sd;
934 ch_readconfig(ch); 935 ch_readconfig(ch);
935 if (init) 936 if (init)