diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/ch.c | 33 | ||||
-rw-r--r-- | drivers/scsi/dpt_i2o.c | 35 | ||||
-rw-r--r-- | drivers/scsi/hosts.c | 8 | ||||
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 37 | ||||
-rw-r--r-- | drivers/scsi/iscsi_tcp.h | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid.c | 6 | ||||
-rw-r--r-- | drivers/scsi/megaraid.h | 4 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 7 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 13 | ||||
-rw-r--r-- | drivers/scsi/scsi_proc.c | 11 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 16 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 4 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 17 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 21 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 17 | ||||
-rw-r--r-- | drivers/scsi/st.c | 17 |
16 files changed, 129 insertions, 119 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 | ||
117 | static LIST_HEAD(ch_devlist); | 118 | static 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) |
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 6252b9ddc01e..cdeb30b0462e 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -61,6 +61,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); | |||
61 | #include <linux/timer.h> | 61 | #include <linux/timer.h> |
62 | #include <linux/string.h> | 62 | #include <linux/string.h> |
63 | #include <linux/ioport.h> | 63 | #include <linux/ioport.h> |
64 | #include <linux/mutex.h> | ||
64 | 65 | ||
65 | #include <asm/processor.h> /* for boot_cpu_data */ | 66 | #include <asm/processor.h> /* for boot_cpu_data */ |
66 | #include <asm/pgtable.h> | 67 | #include <asm/pgtable.h> |
@@ -106,7 +107,7 @@ static dpt_sig_S DPTI_sig = { | |||
106 | *============================================================================ | 107 | *============================================================================ |
107 | */ | 108 | */ |
108 | 109 | ||
109 | static DECLARE_MUTEX(adpt_configuration_lock); | 110 | static DEFINE_MUTEX(adpt_configuration_lock); |
110 | 111 | ||
111 | static struct i2o_sys_tbl *sys_tbl = NULL; | 112 | static struct i2o_sys_tbl *sys_tbl = NULL; |
112 | static int sys_tbl_ind = 0; | 113 | static int sys_tbl_ind = 0; |
@@ -537,13 +538,13 @@ static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, of | |||
537 | */ | 538 | */ |
538 | 539 | ||
539 | // Find HBA (host bus adapter) we are looking for | 540 | // Find HBA (host bus adapter) we are looking for |
540 | down(&adpt_configuration_lock); | 541 | mutex_lock(&adpt_configuration_lock); |
541 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | 542 | for (pHba = hba_chain; pHba; pHba = pHba->next) { |
542 | if (pHba->host == host) { | 543 | if (pHba->host == host) { |
543 | break; /* found adapter */ | 544 | break; /* found adapter */ |
544 | } | 545 | } |
545 | } | 546 | } |
546 | up(&adpt_configuration_lock); | 547 | mutex_unlock(&adpt_configuration_lock); |
547 | if (pHba == NULL) { | 548 | if (pHba == NULL) { |
548 | return 0; | 549 | return 0; |
549 | } | 550 | } |
@@ -958,7 +959,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
958 | } | 959 | } |
959 | memset(pHba, 0, sizeof(adpt_hba)); | 960 | memset(pHba, 0, sizeof(adpt_hba)); |
960 | 961 | ||
961 | down(&adpt_configuration_lock); | 962 | mutex_lock(&adpt_configuration_lock); |
962 | 963 | ||
963 | if(hba_chain != NULL){ | 964 | if(hba_chain != NULL){ |
964 | for(p = hba_chain; p->next; p = p->next); | 965 | for(p = hba_chain; p->next; p = p->next); |
@@ -971,7 +972,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
971 | sprintf(pHba->name, "dpti%d", hba_count); | 972 | sprintf(pHba->name, "dpti%d", hba_count); |
972 | hba_count++; | 973 | hba_count++; |
973 | 974 | ||
974 | up(&adpt_configuration_lock); | 975 | mutex_unlock(&adpt_configuration_lock); |
975 | 976 | ||
976 | pHba->pDev = pDev; | 977 | pHba->pDev = pDev; |
977 | pHba->base_addr_phys = base_addr0_phys; | 978 | pHba->base_addr_phys = base_addr0_phys; |
@@ -1027,7 +1028,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) | |||
1027 | struct adpt_device* pNext; | 1028 | struct adpt_device* pNext; |
1028 | 1029 | ||
1029 | 1030 | ||
1030 | down(&adpt_configuration_lock); | 1031 | mutex_lock(&adpt_configuration_lock); |
1031 | // scsi_unregister calls our adpt_release which | 1032 | // scsi_unregister calls our adpt_release which |
1032 | // does a quiese | 1033 | // does a quiese |
1033 | if(pHba->host){ | 1034 | if(pHba->host){ |
@@ -1046,7 +1047,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) | |||
1046 | } | 1047 | } |
1047 | 1048 | ||
1048 | hba_count--; | 1049 | hba_count--; |
1049 | up(&adpt_configuration_lock); | 1050 | mutex_unlock(&adpt_configuration_lock); |
1050 | 1051 | ||
1051 | iounmap(pHba->base_addr_virt); | 1052 | iounmap(pHba->base_addr_virt); |
1052 | pci_release_regions(pHba->pDev); | 1053 | pci_release_regions(pHba->pDev); |
@@ -1549,7 +1550,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba) | |||
1549 | 1550 | ||
1550 | static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d) | 1551 | static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d) |
1551 | { | 1552 | { |
1552 | down(&adpt_configuration_lock); | 1553 | mutex_lock(&adpt_configuration_lock); |
1553 | d->controller=pHba; | 1554 | d->controller=pHba; |
1554 | d->owner=NULL; | 1555 | d->owner=NULL; |
1555 | d->next=pHba->devices; | 1556 | d->next=pHba->devices; |
@@ -1560,7 +1561,7 @@ static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d) | |||
1560 | pHba->devices=d; | 1561 | pHba->devices=d; |
1561 | *d->dev_name = 0; | 1562 | *d->dev_name = 0; |
1562 | 1563 | ||
1563 | up(&adpt_configuration_lock); | 1564 | mutex_unlock(&adpt_configuration_lock); |
1564 | return 0; | 1565 | return 0; |
1565 | } | 1566 | } |
1566 | 1567 | ||
@@ -1575,24 +1576,24 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1575 | if (minor >= hba_count) { | 1576 | if (minor >= hba_count) { |
1576 | return -ENXIO; | 1577 | return -ENXIO; |
1577 | } | 1578 | } |
1578 | down(&adpt_configuration_lock); | 1579 | mutex_lock(&adpt_configuration_lock); |
1579 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | 1580 | for (pHba = hba_chain; pHba; pHba = pHba->next) { |
1580 | if (pHba->unit == minor) { | 1581 | if (pHba->unit == minor) { |
1581 | break; /* found adapter */ | 1582 | break; /* found adapter */ |
1582 | } | 1583 | } |
1583 | } | 1584 | } |
1584 | if (pHba == NULL) { | 1585 | if (pHba == NULL) { |
1585 | up(&adpt_configuration_lock); | 1586 | mutex_unlock(&adpt_configuration_lock); |
1586 | return -ENXIO; | 1587 | return -ENXIO; |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | // if(pHba->in_use){ | 1590 | // if(pHba->in_use){ |
1590 | // up(&adpt_configuration_lock); | 1591 | // mutex_unlock(&adpt_configuration_lock); |
1591 | // return -EBUSY; | 1592 | // return -EBUSY; |
1592 | // } | 1593 | // } |
1593 | 1594 | ||
1594 | pHba->in_use = 1; | 1595 | pHba->in_use = 1; |
1595 | up(&adpt_configuration_lock); | 1596 | mutex_unlock(&adpt_configuration_lock); |
1596 | 1597 | ||
1597 | return 0; | 1598 | return 0; |
1598 | } | 1599 | } |
@@ -1606,13 +1607,13 @@ static int adpt_close(struct inode *inode, struct file *file) | |||
1606 | if (minor >= hba_count) { | 1607 | if (minor >= hba_count) { |
1607 | return -ENXIO; | 1608 | return -ENXIO; |
1608 | } | 1609 | } |
1609 | down(&adpt_configuration_lock); | 1610 | mutex_lock(&adpt_configuration_lock); |
1610 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | 1611 | for (pHba = hba_chain; pHba; pHba = pHba->next) { |
1611 | if (pHba->unit == minor) { | 1612 | if (pHba->unit == minor) { |
1612 | break; /* found adapter */ | 1613 | break; /* found adapter */ |
1613 | } | 1614 | } |
1614 | } | 1615 | } |
1615 | up(&adpt_configuration_lock); | 1616 | mutex_unlock(&adpt_configuration_lock); |
1616 | if (pHba == NULL) { | 1617 | if (pHba == NULL) { |
1617 | return -ENXIO; | 1618 | return -ENXIO; |
1618 | } | 1619 | } |
@@ -1910,13 +1911,13 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, | |||
1910 | if (minor >= DPTI_MAX_HBA){ | 1911 | if (minor >= DPTI_MAX_HBA){ |
1911 | return -ENXIO; | 1912 | return -ENXIO; |
1912 | } | 1913 | } |
1913 | down(&adpt_configuration_lock); | 1914 | mutex_lock(&adpt_configuration_lock); |
1914 | for (pHba = hba_chain; pHba; pHba = pHba->next) { | 1915 | for (pHba = hba_chain; pHba; pHba = pHba->next) { |
1915 | if (pHba->unit == minor) { | 1916 | if (pHba->unit == minor) { |
1916 | break; /* found adapter */ | 1917 | break; /* found adapter */ |
1917 | } | 1918 | } |
1918 | } | 1919 | } |
1919 | up(&adpt_configuration_lock); | 1920 | mutex_unlock(&adpt_configuration_lock); |
1920 | if(pHba == NULL){ | 1921 | if(pHba == NULL){ |
1921 | return -ENXIO; | 1922 | return -ENXIO; |
1922 | } | 1923 | } |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 66783c860a19..588107923499 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -156,16 +156,16 @@ EXPORT_SYMBOL(scsi_host_set_state); | |||
156 | void scsi_remove_host(struct Scsi_Host *shost) | 156 | void scsi_remove_host(struct Scsi_Host *shost) |
157 | { | 157 | { |
158 | unsigned long flags; | 158 | unsigned long flags; |
159 | down(&shost->scan_mutex); | 159 | mutex_lock(&shost->scan_mutex); |
160 | spin_lock_irqsave(shost->host_lock, flags); | 160 | spin_lock_irqsave(shost->host_lock, flags); |
161 | if (scsi_host_set_state(shost, SHOST_CANCEL)) | 161 | if (scsi_host_set_state(shost, SHOST_CANCEL)) |
162 | if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) { | 162 | if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) { |
163 | spin_unlock_irqrestore(shost->host_lock, flags); | 163 | spin_unlock_irqrestore(shost->host_lock, flags); |
164 | up(&shost->scan_mutex); | 164 | mutex_unlock(&shost->scan_mutex); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | spin_unlock_irqrestore(shost->host_lock, flags); | 167 | spin_unlock_irqrestore(shost->host_lock, flags); |
168 | up(&shost->scan_mutex); | 168 | mutex_unlock(&shost->scan_mutex); |
169 | scsi_forget_host(shost); | 169 | scsi_forget_host(shost); |
170 | scsi_proc_host_rm(shost); | 170 | scsi_proc_host_rm(shost); |
171 | 171 | ||
@@ -320,7 +320,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
320 | INIT_LIST_HEAD(&shost->starved_list); | 320 | INIT_LIST_HEAD(&shost->starved_list); |
321 | init_waitqueue_head(&shost->host_wait); | 321 | init_waitqueue_head(&shost->host_wait); |
322 | 322 | ||
323 | init_MUTEX(&shost->scan_mutex); | 323 | mutex_init(&shost->scan_mutex); |
324 | 324 | ||
325 | shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ | 325 | shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ |
326 | shost->dma_channel = 0xff; | 326 | shost->dma_channel = 0xff; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 10bcf42cb65c..1067d77da10e 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/kfifo.h> | 34 | #include <linux/kfifo.h> |
35 | #include <linux/scatterlist.h> | 35 | #include <linux/scatterlist.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <net/tcp.h> | 37 | #include <net/tcp.h> |
37 | #include <scsi/scsi_cmnd.h> | 38 | #include <scsi/scsi_cmnd.h> |
38 | #include <scsi/scsi_device.h> | 39 | #include <scsi/scsi_device.h> |
@@ -2300,10 +2301,10 @@ iscsi_xmitworker(void *data) | |||
2300 | /* | 2301 | /* |
2301 | * serialize Xmit worker on a per-connection basis. | 2302 | * serialize Xmit worker on a per-connection basis. |
2302 | */ | 2303 | */ |
2303 | down(&conn->xmitsema); | 2304 | mutex_lock(&conn->xmitmutex); |
2304 | if (iscsi_data_xmit(conn)) | 2305 | if (iscsi_data_xmit(conn)) |
2305 | schedule_work(&conn->xmitwork); | 2306 | schedule_work(&conn->xmitwork); |
2306 | up(&conn->xmitsema); | 2307 | mutex_unlock(&conn->xmitmutex); |
2307 | } | 2308 | } |
2308 | 2309 | ||
2309 | #define FAILURE_BAD_HOST 1 | 2310 | #define FAILURE_BAD_HOST 1 |
@@ -2367,11 +2368,11 @@ iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
2367 | session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); | 2368 | session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); |
2368 | spin_unlock(&session->lock); | 2369 | spin_unlock(&session->lock); |
2369 | 2370 | ||
2370 | if (!in_interrupt() && !down_trylock(&conn->xmitsema)) { | 2371 | if (!in_interrupt() && mutex_trylock(&conn->xmitmutex)) { |
2371 | spin_unlock_irq(host->host_lock); | 2372 | spin_unlock_irq(host->host_lock); |
2372 | if (iscsi_data_xmit(conn)) | 2373 | if (iscsi_data_xmit(conn)) |
2373 | schedule_work(&conn->xmitwork); | 2374 | schedule_work(&conn->xmitwork); |
2374 | up(&conn->xmitsema); | 2375 | mutex_unlock(&conn->xmitmutex); |
2375 | spin_lock_irq(host->host_lock); | 2376 | spin_lock_irq(host->host_lock); |
2376 | } else | 2377 | } else |
2377 | schedule_work(&conn->xmitwork); | 2378 | schedule_work(&conn->xmitwork); |
@@ -2531,7 +2532,7 @@ iscsi_conn_create(iscsi_sessionh_t sessionh, uint32_t conn_idx) | |||
2531 | goto max_recv_dlenght_alloc_fail; | 2532 | goto max_recv_dlenght_alloc_fail; |
2532 | 2533 | ||
2533 | init_timer(&conn->tmabort_timer); | 2534 | init_timer(&conn->tmabort_timer); |
2534 | init_MUTEX(&conn->xmitsema); | 2535 | mutex_init(&conn->xmitmutex); |
2535 | init_waitqueue_head(&conn->ehwait); | 2536 | init_waitqueue_head(&conn->ehwait); |
2536 | 2537 | ||
2537 | return iscsi_handle(conn); | 2538 | return iscsi_handle(conn); |
@@ -2561,7 +2562,7 @@ iscsi_conn_destroy(iscsi_connh_t connh) | |||
2561 | struct iscsi_conn *conn = iscsi_ptr(connh); | 2562 | struct iscsi_conn *conn = iscsi_ptr(connh); |
2562 | struct iscsi_session *session = conn->session; | 2563 | struct iscsi_session *session = conn->session; |
2563 | 2564 | ||
2564 | down(&conn->xmitsema); | 2565 | mutex_lock(&conn->xmitmutex); |
2565 | set_bit(SUSPEND_BIT, &conn->suspend_tx); | 2566 | set_bit(SUSPEND_BIT, &conn->suspend_tx); |
2566 | if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) { | 2567 | if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE && conn->sock) { |
2567 | struct sock *sk = conn->sock->sk; | 2568 | struct sock *sk = conn->sock->sk; |
@@ -2592,7 +2593,7 @@ iscsi_conn_destroy(iscsi_connh_t connh) | |||
2592 | } | 2593 | } |
2593 | spin_unlock_bh(&session->lock); | 2594 | spin_unlock_bh(&session->lock); |
2594 | 2595 | ||
2595 | up(&conn->xmitsema); | 2596 | mutex_unlock(&conn->xmitmutex); |
2596 | 2597 | ||
2597 | /* | 2598 | /* |
2598 | * Block until all in-progress commands for this connection | 2599 | * Block until all in-progress commands for this connection |
@@ -2796,7 +2797,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag) | |||
2796 | set_bit(SUSPEND_BIT, &conn->suspend_rx); | 2797 | set_bit(SUSPEND_BIT, &conn->suspend_rx); |
2797 | write_unlock_bh(&sk->sk_callback_lock); | 2798 | write_unlock_bh(&sk->sk_callback_lock); |
2798 | 2799 | ||
2799 | down(&conn->xmitsema); | 2800 | mutex_lock(&conn->xmitmutex); |
2800 | 2801 | ||
2801 | spin_lock_irqsave(session->host->host_lock, flags); | 2802 | spin_lock_irqsave(session->host->host_lock, flags); |
2802 | spin_lock(&session->lock); | 2803 | spin_lock(&session->lock); |
@@ -2878,7 +2879,7 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag) | |||
2878 | conn->datadgst_en = 0; | 2879 | conn->datadgst_en = 0; |
2879 | } | 2880 | } |
2880 | } | 2881 | } |
2881 | up(&conn->xmitsema); | 2882 | mutex_unlock(&conn->xmitmutex); |
2882 | } | 2883 | } |
2883 | 2884 | ||
2884 | static int | 2885 | static int |
@@ -3029,12 +3030,12 @@ iscsi_eh_abort(struct scsi_cmnd *sc) | |||
3029 | * 1) connection-level failure; | 3030 | * 1) connection-level failure; |
3030 | * 2) recovery due protocol error; | 3031 | * 2) recovery due protocol error; |
3031 | */ | 3032 | */ |
3032 | down(&conn->xmitsema); | 3033 | mutex_lock(&conn->xmitmutex); |
3033 | spin_lock_bh(&session->lock); | 3034 | spin_lock_bh(&session->lock); |
3034 | if (session->state != ISCSI_STATE_LOGGED_IN) { | 3035 | if (session->state != ISCSI_STATE_LOGGED_IN) { |
3035 | if (session->state == ISCSI_STATE_TERMINATE) { | 3036 | if (session->state == ISCSI_STATE_TERMINATE) { |
3036 | spin_unlock_bh(&session->lock); | 3037 | spin_unlock_bh(&session->lock); |
3037 | up(&conn->xmitsema); | 3038 | mutex_unlock(&conn->xmitmutex); |
3038 | goto failed; | 3039 | goto failed; |
3039 | } | 3040 | } |
3040 | spin_unlock_bh(&session->lock); | 3041 | spin_unlock_bh(&session->lock); |
@@ -3052,7 +3053,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc) | |||
3052 | * 2) session was re-open during time out of ctask. | 3053 | * 2) session was re-open during time out of ctask. |
3053 | */ | 3054 | */ |
3054 | spin_unlock_bh(&session->lock); | 3055 | spin_unlock_bh(&session->lock); |
3055 | up(&conn->xmitsema); | 3056 | mutex_unlock(&conn->xmitmutex); |
3056 | goto success; | 3057 | goto success; |
3057 | } | 3058 | } |
3058 | conn->tmabort_state = TMABORT_INITIAL; | 3059 | conn->tmabort_state = TMABORT_INITIAL; |
@@ -3107,7 +3108,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc) | |||
3107 | conn->tmabort_state == TMABORT_SUCCESS) { | 3108 | conn->tmabort_state == TMABORT_SUCCESS) { |
3108 | conn->tmabort_state = TMABORT_INITIAL; | 3109 | conn->tmabort_state = TMABORT_INITIAL; |
3109 | spin_unlock_bh(&session->lock); | 3110 | spin_unlock_bh(&session->lock); |
3110 | up(&conn->xmitsema); | 3111 | mutex_unlock(&conn->xmitmutex); |
3111 | goto success; | 3112 | goto success; |
3112 | } | 3113 | } |
3113 | conn->tmabort_state = TMABORT_INITIAL; | 3114 | conn->tmabort_state = TMABORT_INITIAL; |
@@ -3116,7 +3117,7 @@ iscsi_eh_abort(struct scsi_cmnd *sc) | |||
3116 | spin_unlock_bh(&session->lock); | 3117 | spin_unlock_bh(&session->lock); |
3117 | } | 3118 | } |
3118 | } | 3119 | } |
3119 | up(&conn->xmitsema); | 3120 | mutex_unlock(&conn->xmitmutex); |
3120 | 3121 | ||
3121 | 3122 | ||
3122 | /* | 3123 | /* |
@@ -3182,7 +3183,7 @@ failed: | |||
3182 | exit: | 3183 | exit: |
3183 | del_timer_sync(&conn->tmabort_timer); | 3184 | del_timer_sync(&conn->tmabort_timer); |
3184 | 3185 | ||
3185 | down(&conn->xmitsema); | 3186 | mutex_lock(&conn->xmitmutex); |
3186 | if (conn->sock) { | 3187 | if (conn->sock) { |
3187 | struct sock *sk = conn->sock->sk; | 3188 | struct sock *sk = conn->sock->sk; |
3188 | 3189 | ||
@@ -3190,7 +3191,7 @@ exit: | |||
3190 | iscsi_ctask_cleanup(conn, ctask); | 3191 | iscsi_ctask_cleanup(conn, ctask); |
3191 | write_unlock_bh(&sk->sk_callback_lock); | 3192 | write_unlock_bh(&sk->sk_callback_lock); |
3192 | } | 3193 | } |
3193 | up(&conn->xmitsema); | 3194 | mutex_unlock(&conn->xmitmutex); |
3194 | return rc; | 3195 | return rc; |
3195 | } | 3196 | } |
3196 | 3197 | ||
@@ -3601,9 +3602,9 @@ iscsi_conn_send_pdu(iscsi_connh_t connh, struct iscsi_hdr *hdr, char *data, | |||
3601 | struct iscsi_conn *conn = iscsi_ptr(connh); | 3602 | struct iscsi_conn *conn = iscsi_ptr(connh); |
3602 | int rc; | 3603 | int rc; |
3603 | 3604 | ||
3604 | down(&conn->xmitsema); | 3605 | mutex_lock(&conn->xmitmutex); |
3605 | rc = iscsi_conn_send_generic(conn, hdr, data, data_size); | 3606 | rc = iscsi_conn_send_generic(conn, hdr, data, data_size); |
3606 | up(&conn->xmitsema); | 3607 | mutex_unlock(&conn->xmitmutex); |
3607 | 3608 | ||
3608 | return rc; | 3609 | return rc; |
3609 | } | 3610 | } |
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index 855f2dfd18af..9badafe8820d 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h | |||
@@ -158,7 +158,7 @@ struct iscsi_conn { | |||
158 | struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ | 158 | struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ |
159 | struct kfifo *xmitqueue; /* data-path cmd queue */ | 159 | struct kfifo *xmitqueue; /* data-path cmd queue */ |
160 | struct work_struct xmitwork; /* per-conn. xmit workqueue */ | 160 | struct work_struct xmitwork; /* per-conn. xmit workqueue */ |
161 | struct semaphore xmitsema; /* serializes connection xmit, | 161 | struct mutex xmitmutex; /* serializes connection xmit, |
162 | * access to kfifos: * | 162 | * access to kfifos: * |
163 | * xmitqueue, writequeue, * | 163 | * xmitqueue, writequeue, * |
164 | * immqueue, mgmtqueue */ | 164 | * immqueue, mgmtqueue */ |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 4a6feb1e5e3d..d101a8a6f4e8 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -4479,7 +4479,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4479 | * serialized. This is so because we want to reserve maximum number of | 4479 | * serialized. This is so because we want to reserve maximum number of |
4480 | * available command ids for the I/O commands. | 4480 | * available command ids for the I/O commands. |
4481 | */ | 4481 | */ |
4482 | down(&adapter->int_mtx); | 4482 | mutex_lock(&adapter->int_mtx); |
4483 | 4483 | ||
4484 | scb = &adapter->int_scb; | 4484 | scb = &adapter->int_scb; |
4485 | memset(scb, 0, sizeof(scb_t)); | 4485 | memset(scb, 0, sizeof(scb_t)); |
@@ -4527,7 +4527,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4527 | mc->cmd, mc->opcode, mc->subopcode, scmd->result); | 4527 | mc->cmd, mc->opcode, mc->subopcode, scmd->result); |
4528 | } | 4528 | } |
4529 | 4529 | ||
4530 | up(&adapter->int_mtx); | 4530 | mutex_unlock(&adapter->int_mtx); |
4531 | 4531 | ||
4532 | return rval; | 4532 | return rval; |
4533 | } | 4533 | } |
@@ -4866,7 +4866,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
4866 | adapter->has_64bit_addr = 0; | 4866 | adapter->has_64bit_addr = 0; |
4867 | } | 4867 | } |
4868 | 4868 | ||
4869 | init_MUTEX(&adapter->int_mtx); | 4869 | mutex_init(&adapter->int_mtx); |
4870 | init_completion(&adapter->int_waitq); | 4870 | init_completion(&adapter->int_waitq); |
4871 | 4871 | ||
4872 | adapter->this_id = DEFAULT_INITIATOR_ID; | 4872 | adapter->this_id = DEFAULT_INITIATOR_ID; |
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index 6f9078025748..4b3e0d6e5afa 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define __MEGARAID_H__ | 2 | #define __MEGARAID_H__ |
3 | 3 | ||
4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
5 | 5 | #include <linux/mutex.h> | |
6 | 6 | ||
7 | #define MEGARAID_VERSION \ | 7 | #define MEGARAID_VERSION \ |
8 | "v2.00.3 (Release Date: Wed Feb 19 08:51:30 EST 2003)\n" | 8 | "v2.00.3 (Release Date: Wed Feb 19 08:51:30 EST 2003)\n" |
@@ -889,7 +889,7 @@ typedef struct { | |||
889 | 889 | ||
890 | scb_t int_scb; | 890 | scb_t int_scb; |
891 | Scsi_Cmnd int_scmd; | 891 | Scsi_Cmnd int_scmd; |
892 | struct semaphore int_mtx; /* To synchronize the internal | 892 | struct mutex int_mtx; /* To synchronize the internal |
893 | commands */ | 893 | commands */ |
894 | struct completion int_waitq; /* wait queue for internal | 894 | struct completion int_waitq; /* wait queue for internal |
895 | cmds */ | 895 | cmds */ |
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 3c32e69afcd9..c0bb8061401f 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/compat.h> | 37 | #include <linux/compat.h> |
38 | #include <linux/mutex.h> | ||
38 | 39 | ||
39 | #include <scsi/scsi.h> | 40 | #include <scsi/scsi.h> |
40 | #include <scsi/scsi_cmnd.h> | 41 | #include <scsi/scsi_cmnd.h> |
@@ -72,7 +73,7 @@ MODULE_DEVICE_TABLE(pci, megasas_pci_table); | |||
72 | static int megasas_mgmt_majorno; | 73 | static int megasas_mgmt_majorno; |
73 | static struct megasas_mgmt_info megasas_mgmt_info; | 74 | static struct megasas_mgmt_info megasas_mgmt_info; |
74 | static struct fasync_struct *megasas_async_queue; | 75 | static struct fasync_struct *megasas_async_queue; |
75 | static DECLARE_MUTEX(megasas_async_queue_mutex); | 76 | static DEFINE_MUTEX(megasas_async_queue_mutex); |
76 | 77 | ||
77 | /** | 78 | /** |
78 | * megasas_get_cmd - Get a command from the free pool | 79 | * megasas_get_cmd - Get a command from the free pool |
@@ -2362,11 +2363,11 @@ static int megasas_mgmt_fasync(int fd, struct file *filep, int mode) | |||
2362 | { | 2363 | { |
2363 | int rc; | 2364 | int rc; |
2364 | 2365 | ||
2365 | down(&megasas_async_queue_mutex); | 2366 | mutex_lock(&megasas_async_queue_mutex); |
2366 | 2367 | ||
2367 | rc = fasync_helper(fd, filep, mode, &megasas_async_queue); | 2368 | rc = fasync_helper(fd, filep, mode, &megasas_async_queue); |
2368 | 2369 | ||
2369 | up(&megasas_async_queue_mutex); | 2370 | mutex_unlock(&megasas_async_queue_mutex); |
2370 | 2371 | ||
2371 | if (rc >= 0) { | 2372 | if (rc >= 0) { |
2372 | /* For sanity check when we get ioctl */ | 2373 | /* For sanity check when we get ioctl */ |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index ee5f4dfdab14..245ca99a641e 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/interrupt.h> | 55 | #include <linux/interrupt.h> |
56 | #include <linux/notifier.h> | 56 | #include <linux/notifier.h> |
57 | #include <linux/cpu.h> | 57 | #include <linux/cpu.h> |
58 | #include <linux/mutex.h> | ||
58 | 59 | ||
59 | #include <scsi/scsi.h> | 60 | #include <scsi/scsi.h> |
60 | #include <scsi/scsi_cmnd.h> | 61 | #include <scsi/scsi_cmnd.h> |
@@ -209,7 +210,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = { | |||
209 | .gfp_mask = __GFP_DMA, | 210 | .gfp_mask = __GFP_DMA, |
210 | }; | 211 | }; |
211 | 212 | ||
212 | static DECLARE_MUTEX(host_cmd_pool_mutex); | 213 | static DEFINE_MUTEX(host_cmd_pool_mutex); |
213 | 214 | ||
214 | static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, | 215 | static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, |
215 | gfp_t gfp_mask) | 216 | gfp_t gfp_mask) |
@@ -330,7 +331,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
330 | * Select a command slab for this host and create it if not | 331 | * Select a command slab for this host and create it if not |
331 | * yet existant. | 332 | * yet existant. |
332 | */ | 333 | */ |
333 | down(&host_cmd_pool_mutex); | 334 | mutex_lock(&host_cmd_pool_mutex); |
334 | pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); | 335 | pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); |
335 | if (!pool->users) { | 336 | if (!pool->users) { |
336 | pool->slab = kmem_cache_create(pool->name, | 337 | pool->slab = kmem_cache_create(pool->name, |
@@ -342,7 +343,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
342 | 343 | ||
343 | pool->users++; | 344 | pool->users++; |
344 | shost->cmd_pool = pool; | 345 | shost->cmd_pool = pool; |
345 | up(&host_cmd_pool_mutex); | 346 | mutex_unlock(&host_cmd_pool_mutex); |
346 | 347 | ||
347 | /* | 348 | /* |
348 | * Get one backup command for this host. | 349 | * Get one backup command for this host. |
@@ -359,7 +360,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
359 | kmem_cache_destroy(pool->slab); | 360 | kmem_cache_destroy(pool->slab); |
360 | return -ENOMEM; | 361 | return -ENOMEM; |
361 | fail: | 362 | fail: |
362 | up(&host_cmd_pool_mutex); | 363 | mutex_unlock(&host_cmd_pool_mutex); |
363 | return -ENOMEM; | 364 | return -ENOMEM; |
364 | 365 | ||
365 | } | 366 | } |
@@ -381,10 +382,10 @@ void scsi_destroy_command_freelist(struct Scsi_Host *shost) | |||
381 | kmem_cache_free(shost->cmd_pool->slab, cmd); | 382 | kmem_cache_free(shost->cmd_pool->slab, cmd); |
382 | } | 383 | } |
383 | 384 | ||
384 | down(&host_cmd_pool_mutex); | 385 | mutex_lock(&host_cmd_pool_mutex); |
385 | if (!--shost->cmd_pool->users) | 386 | if (!--shost->cmd_pool->users) |
386 | kmem_cache_destroy(shost->cmd_pool->slab); | 387 | kmem_cache_destroy(shost->cmd_pool->slab); |
387 | up(&host_cmd_pool_mutex); | 388 | mutex_unlock(&host_cmd_pool_mutex); |
388 | } | 389 | } |
389 | 390 | ||
390 | #ifdef CONFIG_SCSI_LOGGING | 391 | #ifdef CONFIG_SCSI_LOGGING |
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index a50958b1b6ee..1b5711e714a5 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
27 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
28 | #include <linux/mutex.h> | ||
28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
29 | 30 | ||
30 | #include <scsi/scsi.h> | 31 | #include <scsi/scsi.h> |
@@ -41,7 +42,7 @@ | |||
41 | static struct proc_dir_entry *proc_scsi; | 42 | static struct proc_dir_entry *proc_scsi; |
42 | 43 | ||
43 | /* Protect sht->present and sht->proc_dir */ | 44 | /* Protect sht->present and sht->proc_dir */ |
44 | static DECLARE_MUTEX(global_host_template_sem); | 45 | static DEFINE_MUTEX(global_host_template_mutex); |
45 | 46 | ||
46 | static int proc_scsi_read(char *buffer, char **start, off_t offset, | 47 | static int proc_scsi_read(char *buffer, char **start, off_t offset, |
47 | int length, int *eof, void *data) | 48 | int length, int *eof, void *data) |
@@ -83,7 +84,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht) | |||
83 | if (!sht->proc_info) | 84 | if (!sht->proc_info) |
84 | return; | 85 | return; |
85 | 86 | ||
86 | down(&global_host_template_sem); | 87 | mutex_lock(&global_host_template_mutex); |
87 | if (!sht->present++) { | 88 | if (!sht->present++) { |
88 | sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi); | 89 | sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi); |
89 | if (!sht->proc_dir) | 90 | if (!sht->proc_dir) |
@@ -92,7 +93,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht) | |||
92 | else | 93 | else |
93 | sht->proc_dir->owner = sht->module; | 94 | sht->proc_dir->owner = sht->module; |
94 | } | 95 | } |
95 | up(&global_host_template_sem); | 96 | mutex_unlock(&global_host_template_mutex); |
96 | } | 97 | } |
97 | 98 | ||
98 | void scsi_proc_hostdir_rm(struct scsi_host_template *sht) | 99 | void scsi_proc_hostdir_rm(struct scsi_host_template *sht) |
@@ -100,12 +101,12 @@ void scsi_proc_hostdir_rm(struct scsi_host_template *sht) | |||
100 | if (!sht->proc_info) | 101 | if (!sht->proc_info) |
101 | return; | 102 | return; |
102 | 103 | ||
103 | down(&global_host_template_sem); | 104 | mutex_lock(&global_host_template_mutex); |
104 | if (!--sht->present && sht->proc_dir) { | 105 | if (!--sht->present && sht->proc_dir) { |
105 | remove_proc_entry(sht->proc_name, proc_scsi); | 106 | remove_proc_entry(sht->proc_name, proc_scsi); |
106 | sht->proc_dir = NULL; | 107 | sht->proc_dir = NULL; |
107 | } | 108 | } |
108 | up(&global_host_template_sem); | 109 | mutex_unlock(&global_host_template_mutex); |
109 | } | 110 | } |
110 | 111 | ||
111 | void scsi_proc_host_add(struct Scsi_Host *shost) | 112 | void scsi_proc_host_add(struct Scsi_Host *shost) |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 05ebb9cef961..edcd80b749c1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1289,14 +1289,14 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, | |||
1289 | return ERR_PTR(-ENOMEM); | 1289 | return ERR_PTR(-ENOMEM); |
1290 | 1290 | ||
1291 | get_device(&starget->dev); | 1291 | get_device(&starget->dev); |
1292 | down(&shost->scan_mutex); | 1292 | mutex_lock(&shost->scan_mutex); |
1293 | if (scsi_host_scan_allowed(shost)) { | 1293 | if (scsi_host_scan_allowed(shost)) { |
1294 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, | 1294 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, |
1295 | hostdata); | 1295 | hostdata); |
1296 | if (res != SCSI_SCAN_LUN_PRESENT) | 1296 | if (res != SCSI_SCAN_LUN_PRESENT) |
1297 | sdev = ERR_PTR(-ENODEV); | 1297 | sdev = ERR_PTR(-ENODEV); |
1298 | } | 1298 | } |
1299 | up(&shost->scan_mutex); | 1299 | mutex_unlock(&shost->scan_mutex); |
1300 | scsi_target_reap(starget); | 1300 | scsi_target_reap(starget); |
1301 | put_device(&starget->dev); | 1301 | put_device(&starget->dev); |
1302 | 1302 | ||
@@ -1404,10 +1404,10 @@ void scsi_scan_target(struct device *parent, unsigned int channel, | |||
1404 | { | 1404 | { |
1405 | struct Scsi_Host *shost = dev_to_shost(parent); | 1405 | struct Scsi_Host *shost = dev_to_shost(parent); |
1406 | 1406 | ||
1407 | down(&shost->scan_mutex); | 1407 | mutex_lock(&shost->scan_mutex); |
1408 | if (scsi_host_scan_allowed(shost)) | 1408 | if (scsi_host_scan_allowed(shost)) |
1409 | __scsi_scan_target(parent, channel, id, lun, rescan); | 1409 | __scsi_scan_target(parent, channel, id, lun, rescan); |
1410 | up(&shost->scan_mutex); | 1410 | mutex_unlock(&shost->scan_mutex); |
1411 | } | 1411 | } |
1412 | EXPORT_SYMBOL(scsi_scan_target); | 1412 | EXPORT_SYMBOL(scsi_scan_target); |
1413 | 1413 | ||
@@ -1454,7 +1454,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, | |||
1454 | ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) | 1454 | ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) |
1455 | return -EINVAL; | 1455 | return -EINVAL; |
1456 | 1456 | ||
1457 | down(&shost->scan_mutex); | 1457 | mutex_lock(&shost->scan_mutex); |
1458 | if (scsi_host_scan_allowed(shost)) { | 1458 | if (scsi_host_scan_allowed(shost)) { |
1459 | if (channel == SCAN_WILD_CARD) | 1459 | if (channel == SCAN_WILD_CARD) |
1460 | for (channel = 0; channel <= shost->max_channel; | 1460 | for (channel = 0; channel <= shost->max_channel; |
@@ -1464,7 +1464,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, | |||
1464 | else | 1464 | else |
1465 | scsi_scan_channel(shost, channel, id, lun, rescan); | 1465 | scsi_scan_channel(shost, channel, id, lun, rescan); |
1466 | } | 1466 | } |
1467 | up(&shost->scan_mutex); | 1467 | mutex_unlock(&shost->scan_mutex); |
1468 | 1468 | ||
1469 | return 0; | 1469 | return 0; |
1470 | } | 1470 | } |
@@ -1522,7 +1522,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) | |||
1522 | struct scsi_device *sdev = NULL; | 1522 | struct scsi_device *sdev = NULL; |
1523 | struct scsi_target *starget; | 1523 | struct scsi_target *starget; |
1524 | 1524 | ||
1525 | down(&shost->scan_mutex); | 1525 | mutex_lock(&shost->scan_mutex); |
1526 | if (!scsi_host_scan_allowed(shost)) | 1526 | if (!scsi_host_scan_allowed(shost)) |
1527 | goto out; | 1527 | goto out; |
1528 | starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); | 1528 | starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); |
@@ -1536,7 +1536,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) | |||
1536 | } | 1536 | } |
1537 | put_device(&starget->dev); | 1537 | put_device(&starget->dev); |
1538 | out: | 1538 | out: |
1539 | up(&shost->scan_mutex); | 1539 | mutex_unlock(&shost->scan_mutex); |
1540 | return sdev; | 1540 | return sdev; |
1541 | } | 1541 | } |
1542 | EXPORT_SYMBOL(scsi_get_host_dev); | 1542 | EXPORT_SYMBOL(scsi_get_host_dev); |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index ea7f3a433572..2cb962751a7e 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -745,9 +745,9 @@ void scsi_remove_device(struct scsi_device *sdev) | |||
745 | { | 745 | { |
746 | struct Scsi_Host *shost = sdev->host; | 746 | struct Scsi_Host *shost = sdev->host; |
747 | 747 | ||
748 | down(&shost->scan_mutex); | 748 | mutex_lock(&shost->scan_mutex); |
749 | __scsi_remove_device(sdev); | 749 | __scsi_remove_device(sdev); |
750 | up(&shost->scan_mutex); | 750 | mutex_unlock(&shost->scan_mutex); |
751 | } | 751 | } |
752 | EXPORT_SYMBOL(scsi_remove_device); | 752 | EXPORT_SYMBOL(scsi_remove_device); |
753 | 753 | ||
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index e08462d50c97..50ed88f98f46 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/mempool.h> | 26 | #include <linux/mempool.h> |
27 | #include <linux/mutex.h> | ||
27 | #include <net/tcp.h> | 28 | #include <net/tcp.h> |
28 | 29 | ||
29 | #include <scsi/scsi.h> | 30 | #include <scsi/scsi.h> |
@@ -46,7 +47,7 @@ struct iscsi_internal { | |||
46 | struct list_head sessions; | 47 | struct list_head sessions; |
47 | /* | 48 | /* |
48 | * lock to serialize access to the sessions list which must | 49 | * lock to serialize access to the sessions list which must |
49 | * be taken after the rx_queue_sema | 50 | * be taken after the rx_queue_mutex |
50 | */ | 51 | */ |
51 | spinlock_t session_lock; | 52 | spinlock_t session_lock; |
52 | /* | 53 | /* |
@@ -70,7 +71,7 @@ struct iscsi_internal { | |||
70 | /* | 71 | /* |
71 | * list of registered transports and lock that must | 72 | * list of registered transports and lock that must |
72 | * be held while accessing list. The iscsi_transport_lock must | 73 | * be held while accessing list. The iscsi_transport_lock must |
73 | * be acquired after the rx_queue_sema. | 74 | * be acquired after the rx_queue_mutex. |
74 | */ | 75 | */ |
75 | static LIST_HEAD(iscsi_transports); | 76 | static LIST_HEAD(iscsi_transports); |
76 | static DEFINE_SPINLOCK(iscsi_transport_lock); | 77 | static DEFINE_SPINLOCK(iscsi_transport_lock); |
@@ -145,7 +146,7 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class, | |||
145 | 146 | ||
146 | static struct sock *nls; | 147 | static struct sock *nls; |
147 | static int daemon_pid; | 148 | static int daemon_pid; |
148 | static DECLARE_MUTEX(rx_queue_sema); | 149 | static DEFINE_MUTEX(rx_queue_mutex); |
149 | 150 | ||
150 | struct mempool_zone { | 151 | struct mempool_zone { |
151 | mempool_t *pool; | 152 | mempool_t *pool; |
@@ -881,7 +882,7 @@ iscsi_if_rx(struct sock *sk, int len) | |||
881 | { | 882 | { |
882 | struct sk_buff *skb; | 883 | struct sk_buff *skb; |
883 | 884 | ||
884 | down(&rx_queue_sema); | 885 | mutex_lock(&rx_queue_mutex); |
885 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 886 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
886 | while (skb->len >= NLMSG_SPACE(0)) { | 887 | while (skb->len >= NLMSG_SPACE(0)) { |
887 | int err; | 888 | int err; |
@@ -923,7 +924,7 @@ iscsi_if_rx(struct sock *sk, int len) | |||
923 | } | 924 | } |
924 | kfree_skb(skb); | 925 | kfree_skb(skb); |
925 | } | 926 | } |
926 | up(&rx_queue_sema); | 927 | mutex_unlock(&rx_queue_mutex); |
927 | } | 928 | } |
928 | 929 | ||
929 | /* | 930 | /* |
@@ -1159,7 +1160,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) | |||
1159 | 1160 | ||
1160 | BUG_ON(!tt); | 1161 | BUG_ON(!tt); |
1161 | 1162 | ||
1162 | down(&rx_queue_sema); | 1163 | mutex_lock(&rx_queue_mutex); |
1163 | 1164 | ||
1164 | priv = iscsi_if_transport_lookup(tt); | 1165 | priv = iscsi_if_transport_lookup(tt); |
1165 | BUG_ON (!priv); | 1166 | BUG_ON (!priv); |
@@ -1167,7 +1168,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) | |||
1167 | spin_lock_irqsave(&priv->session_lock, flags); | 1168 | spin_lock_irqsave(&priv->session_lock, flags); |
1168 | if (!list_empty(&priv->sessions)) { | 1169 | if (!list_empty(&priv->sessions)) { |
1169 | spin_unlock_irqrestore(&priv->session_lock, flags); | 1170 | spin_unlock_irqrestore(&priv->session_lock, flags); |
1170 | up(&rx_queue_sema); | 1171 | mutex_unlock(&rx_queue_mutex); |
1171 | return -EPERM; | 1172 | return -EPERM; |
1172 | } | 1173 | } |
1173 | spin_unlock_irqrestore(&priv->session_lock, flags); | 1174 | spin_unlock_irqrestore(&priv->session_lock, flags); |
@@ -1181,7 +1182,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) | |||
1181 | 1182 | ||
1182 | sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); | 1183 | sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); |
1183 | class_device_unregister(&priv->cdev); | 1184 | class_device_unregister(&priv->cdev); |
1184 | up(&rx_queue_sema); | 1185 | mutex_unlock(&rx_queue_mutex); |
1185 | 1186 | ||
1186 | return 0; | 1187 | return 0; |
1187 | } | 1188 | } |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4c5127ed379c..fbd8e1bbad38 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/blkpg.h> | 49 | #include <linux/blkpg.h> |
50 | #include <linux/kref.h> | 50 | #include <linux/kref.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/mutex.h> | ||
52 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
53 | 54 | ||
54 | #include <scsi/scsi.h> | 55 | #include <scsi/scsi.h> |
@@ -111,7 +112,7 @@ static DEFINE_SPINLOCK(sd_index_lock); | |||
111 | /* This semaphore is used to mediate the 0->1 reference get in the | 112 | /* This semaphore is used to mediate the 0->1 reference get in the |
112 | * face of object destruction (i.e. we can't allow a get on an | 113 | * face of object destruction (i.e. we can't allow a get on an |
113 | * object after last put) */ | 114 | * object after last put) */ |
114 | static DECLARE_MUTEX(sd_ref_sem); | 115 | static DEFINE_MUTEX(sd_ref_mutex); |
115 | 116 | ||
116 | static int sd_revalidate_disk(struct gendisk *disk); | 117 | static int sd_revalidate_disk(struct gendisk *disk); |
117 | static void sd_rw_intr(struct scsi_cmnd * SCpnt); | 118 | static void sd_rw_intr(struct scsi_cmnd * SCpnt); |
@@ -193,9 +194,9 @@ static struct scsi_disk *scsi_disk_get(struct gendisk *disk) | |||
193 | { | 194 | { |
194 | struct scsi_disk *sdkp; | 195 | struct scsi_disk *sdkp; |
195 | 196 | ||
196 | down(&sd_ref_sem); | 197 | mutex_lock(&sd_ref_mutex); |
197 | sdkp = __scsi_disk_get(disk); | 198 | sdkp = __scsi_disk_get(disk); |
198 | up(&sd_ref_sem); | 199 | mutex_unlock(&sd_ref_mutex); |
199 | return sdkp; | 200 | return sdkp; |
200 | } | 201 | } |
201 | 202 | ||
@@ -203,11 +204,11 @@ static struct scsi_disk *scsi_disk_get_from_dev(struct device *dev) | |||
203 | { | 204 | { |
204 | struct scsi_disk *sdkp; | 205 | struct scsi_disk *sdkp; |
205 | 206 | ||
206 | down(&sd_ref_sem); | 207 | mutex_lock(&sd_ref_mutex); |
207 | sdkp = dev_get_drvdata(dev); | 208 | sdkp = dev_get_drvdata(dev); |
208 | if (sdkp) | 209 | if (sdkp) |
209 | sdkp = __scsi_disk_get(sdkp->disk); | 210 | sdkp = __scsi_disk_get(sdkp->disk); |
210 | up(&sd_ref_sem); | 211 | mutex_unlock(&sd_ref_mutex); |
211 | return sdkp; | 212 | return sdkp; |
212 | } | 213 | } |
213 | 214 | ||
@@ -215,10 +216,10 @@ static void scsi_disk_put(struct scsi_disk *sdkp) | |||
215 | { | 216 | { |
216 | struct scsi_device *sdev = sdkp->device; | 217 | struct scsi_device *sdev = sdkp->device; |
217 | 218 | ||
218 | down(&sd_ref_sem); | 219 | mutex_lock(&sd_ref_mutex); |
219 | kref_put(&sdkp->kref, scsi_disk_release); | 220 | kref_put(&sdkp->kref, scsi_disk_release); |
220 | scsi_device_put(sdev); | 221 | scsi_device_put(sdev); |
221 | up(&sd_ref_sem); | 222 | mutex_unlock(&sd_ref_mutex); |
222 | } | 223 | } |
223 | 224 | ||
224 | /** | 225 | /** |
@@ -1635,10 +1636,10 @@ static int sd_remove(struct device *dev) | |||
1635 | del_gendisk(sdkp->disk); | 1636 | del_gendisk(sdkp->disk); |
1636 | sd_shutdown(dev); | 1637 | sd_shutdown(dev); |
1637 | 1638 | ||
1638 | down(&sd_ref_sem); | 1639 | mutex_lock(&sd_ref_mutex); |
1639 | dev_set_drvdata(dev, NULL); | 1640 | dev_set_drvdata(dev, NULL); |
1640 | kref_put(&sdkp->kref, scsi_disk_release); | 1641 | kref_put(&sdkp->kref, scsi_disk_release); |
1641 | up(&sd_ref_sem); | 1642 | mutex_unlock(&sd_ref_mutex); |
1642 | 1643 | ||
1643 | return 0; | 1644 | return 0; |
1644 | } | 1645 | } |
@@ -1647,7 +1648,7 @@ static int sd_remove(struct device *dev) | |||
1647 | * scsi_disk_release - Called to free the scsi_disk structure | 1648 | * scsi_disk_release - Called to free the scsi_disk structure |
1648 | * @kref: pointer to embedded kref | 1649 | * @kref: pointer to embedded kref |
1649 | * | 1650 | * |
1650 | * sd_ref_sem must be held entering this routine. Because it is | 1651 | * sd_ref_mutex must be held entering this routine. Because it is |
1651 | * called on last put, you should always use the scsi_disk_get() | 1652 | * called on last put, you should always use the scsi_disk_get() |
1652 | * scsi_disk_put() helpers which manipulate the semaphore directly | 1653 | * scsi_disk_put() helpers which manipulate the semaphore directly |
1653 | * and never do a direct kref_put(). | 1654 | * and never do a direct kref_put(). |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index a4d9be7c6874..ec73223ad2ea 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/interrupt.h> | 44 | #include <linux/interrupt.h> |
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/blkdev.h> | 46 | #include <linux/blkdev.h> |
47 | #include <linux/mutex.h> | ||
47 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
48 | 49 | ||
49 | #include <scsi/scsi.h> | 50 | #include <scsi/scsi.h> |
@@ -90,7 +91,7 @@ static DEFINE_SPINLOCK(sr_index_lock); | |||
90 | /* This semaphore is used to mediate the 0->1 reference get in the | 91 | /* This semaphore is used to mediate the 0->1 reference get in the |
91 | * face of object destruction (i.e. we can't allow a get on an | 92 | * face of object destruction (i.e. we can't allow a get on an |
92 | * object after last put) */ | 93 | * object after last put) */ |
93 | static DECLARE_MUTEX(sr_ref_sem); | 94 | static DEFINE_MUTEX(sr_ref_mutex); |
94 | 95 | ||
95 | static int sr_open(struct cdrom_device_info *, int); | 96 | static int sr_open(struct cdrom_device_info *, int); |
96 | static void sr_release(struct cdrom_device_info *); | 97 | static void sr_release(struct cdrom_device_info *); |
@@ -133,7 +134,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk) | |||
133 | { | 134 | { |
134 | struct scsi_cd *cd = NULL; | 135 | struct scsi_cd *cd = NULL; |
135 | 136 | ||
136 | down(&sr_ref_sem); | 137 | mutex_lock(&sr_ref_mutex); |
137 | if (disk->private_data == NULL) | 138 | if (disk->private_data == NULL) |
138 | goto out; | 139 | goto out; |
139 | cd = scsi_cd(disk); | 140 | cd = scsi_cd(disk); |
@@ -146,7 +147,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk) | |||
146 | kref_put(&cd->kref, sr_kref_release); | 147 | kref_put(&cd->kref, sr_kref_release); |
147 | cd = NULL; | 148 | cd = NULL; |
148 | out: | 149 | out: |
149 | up(&sr_ref_sem); | 150 | mutex_unlock(&sr_ref_mutex); |
150 | return cd; | 151 | return cd; |
151 | } | 152 | } |
152 | 153 | ||
@@ -154,10 +155,10 @@ static inline void scsi_cd_put(struct scsi_cd *cd) | |||
154 | { | 155 | { |
155 | struct scsi_device *sdev = cd->device; | 156 | struct scsi_device *sdev = cd->device; |
156 | 157 | ||
157 | down(&sr_ref_sem); | 158 | mutex_lock(&sr_ref_mutex); |
158 | kref_put(&cd->kref, sr_kref_release); | 159 | kref_put(&cd->kref, sr_kref_release); |
159 | scsi_device_put(sdev); | 160 | scsi_device_put(sdev); |
160 | up(&sr_ref_sem); | 161 | mutex_unlock(&sr_ref_mutex); |
161 | } | 162 | } |
162 | 163 | ||
163 | /* | 164 | /* |
@@ -845,7 +846,7 @@ static int sr_packet(struct cdrom_device_info *cdi, | |||
845 | * sr_kref_release - Called to free the scsi_cd structure | 846 | * sr_kref_release - Called to free the scsi_cd structure |
846 | * @kref: pointer to embedded kref | 847 | * @kref: pointer to embedded kref |
847 | * | 848 | * |
848 | * sr_ref_sem must be held entering this routine. Because it is | 849 | * sr_ref_mutex must be held entering this routine. Because it is |
849 | * called on last put, you should always use the scsi_cd_get() | 850 | * called on last put, you should always use the scsi_cd_get() |
850 | * scsi_cd_put() helpers which manipulate the semaphore directly | 851 | * scsi_cd_put() helpers which manipulate the semaphore directly |
851 | * and never do a direct kref_put(). | 852 | * and never do a direct kref_put(). |
@@ -874,9 +875,9 @@ static int sr_remove(struct device *dev) | |||
874 | 875 | ||
875 | del_gendisk(cd->disk); | 876 | del_gendisk(cd->disk); |
876 | 877 | ||
877 | down(&sr_ref_sem); | 878 | mutex_lock(&sr_ref_mutex); |
878 | kref_put(&cd->kref, sr_kref_release); | 879 | kref_put(&cd->kref, sr_kref_release); |
879 | up(&sr_ref_sem); | 880 | mutex_unlock(&sr_ref_mutex); |
880 | 881 | ||
881 | return 0; | 882 | return 0; |
882 | } | 883 | } |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index c4aade8f5345..6e4a36af58c3 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -38,6 +38,7 @@ static const char *verstr = "20050830"; | |||
38 | #include <linux/devfs_fs_kernel.h> | 38 | #include <linux/devfs_fs_kernel.h> |
39 | #include <linux/cdev.h> | 39 | #include <linux/cdev.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/mutex.h> | ||
41 | 42 | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/dma.h> | 44 | #include <asm/dma.h> |
@@ -220,7 +221,7 @@ static void scsi_tape_release(struct kref *); | |||
220 | 221 | ||
221 | #define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) | 222 | #define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) |
222 | 223 | ||
223 | static DECLARE_MUTEX(st_ref_sem); | 224 | static DEFINE_MUTEX(st_ref_mutex); |
224 | 225 | ||
225 | 226 | ||
226 | #include "osst_detect.h" | 227 | #include "osst_detect.h" |
@@ -237,7 +238,7 @@ static struct scsi_tape *scsi_tape_get(int dev) | |||
237 | { | 238 | { |
238 | struct scsi_tape *STp = NULL; | 239 | struct scsi_tape *STp = NULL; |
239 | 240 | ||
240 | down(&st_ref_sem); | 241 | mutex_lock(&st_ref_mutex); |
241 | write_lock(&st_dev_arr_lock); | 242 | write_lock(&st_dev_arr_lock); |
242 | 243 | ||
243 | if (dev < st_dev_max && scsi_tapes != NULL) | 244 | if (dev < st_dev_max && scsi_tapes != NULL) |
@@ -259,7 +260,7 @@ out_put: | |||
259 | STp = NULL; | 260 | STp = NULL; |
260 | out: | 261 | out: |
261 | write_unlock(&st_dev_arr_lock); | 262 | write_unlock(&st_dev_arr_lock); |
262 | up(&st_ref_sem); | 263 | mutex_unlock(&st_ref_mutex); |
263 | return STp; | 264 | return STp; |
264 | } | 265 | } |
265 | 266 | ||
@@ -267,10 +268,10 @@ static void scsi_tape_put(struct scsi_tape *STp) | |||
267 | { | 268 | { |
268 | struct scsi_device *sdev = STp->device; | 269 | struct scsi_device *sdev = STp->device; |
269 | 270 | ||
270 | down(&st_ref_sem); | 271 | mutex_lock(&st_ref_mutex); |
271 | kref_put(&STp->kref, scsi_tape_release); | 272 | kref_put(&STp->kref, scsi_tape_release); |
272 | scsi_device_put(sdev); | 273 | scsi_device_put(sdev); |
273 | up(&st_ref_sem); | 274 | mutex_unlock(&st_ref_mutex); |
274 | } | 275 | } |
275 | 276 | ||
276 | struct st_reject_data { | 277 | struct st_reject_data { |
@@ -4141,9 +4142,9 @@ static int st_remove(struct device *dev) | |||
4141 | } | 4142 | } |
4142 | } | 4143 | } |
4143 | 4144 | ||
4144 | down(&st_ref_sem); | 4145 | mutex_lock(&st_ref_mutex); |
4145 | kref_put(&tpnt->kref, scsi_tape_release); | 4146 | kref_put(&tpnt->kref, scsi_tape_release); |
4146 | up(&st_ref_sem); | 4147 | mutex_unlock(&st_ref_mutex); |
4147 | return 0; | 4148 | return 0; |
4148 | } | 4149 | } |
4149 | } | 4150 | } |
@@ -4156,7 +4157,7 @@ static int st_remove(struct device *dev) | |||
4156 | * scsi_tape_release - Called to free the Scsi_Tape structure | 4157 | * scsi_tape_release - Called to free the Scsi_Tape structure |
4157 | * @kref: pointer to embedded kref | 4158 | * @kref: pointer to embedded kref |
4158 | * | 4159 | * |
4159 | * st_ref_sem must be held entering this routine. Because it is | 4160 | * st_ref_mutex must be held entering this routine. Because it is |
4160 | * called on last put, you should always use the scsi_tape_get() | 4161 | * called on last put, you should always use the scsi_tape_get() |
4161 | * scsi_tape_put() helpers which manipulate the semaphore directly | 4162 | * scsi_tape_put() helpers which manipulate the semaphore directly |
4162 | * and never do a direct kref_put(). | 4163 | * and never do a direct kref_put(). |