[IA64-SGI] sem2mutex ioc4.c
authorJes Sorensen <jes@sgi.com>
Tue, 17 Jan 2006 17:24:39 +0000 (12:24 -0500)
committerTony Luck <tony.luck@intel.com>
Thu, 26 Jan 2006 21:13:00 +0000 (13:13 -0800)
Convert to use a single mutex instead of two rwsems as this isn't
performance critical.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Brent Casavant <bcasavan@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/sn/ioc4.c

index ea75b3d0612b596819fba49a6d17c8e24939e941..67140a5804f574b97eb6a8823f3affb3b2088830 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/ioc4.h>
 #include <linux/mmtimer.h>
 #include <linux/rtc.h>
-#include <linux/rwsem.h>
+#include <linux/mutex.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/clksupport.h>
 #include <asm/sn/shub_mmr.h>
  * Submodule management *
  ************************/
 
-static LIST_HEAD(ioc4_devices);
-static DECLARE_RWSEM(ioc4_devices_rwsem);
+static DEFINE_MUTEX(ioc4_mutex);
 
+static LIST_HEAD(ioc4_devices);
 static LIST_HEAD(ioc4_submodules);
-static DECLARE_RWSEM(ioc4_submodules_rwsem);
 
 /* Register an IOC4 submodule */
 int
@@ -66,15 +65,13 @@ ioc4_register_submodule(struct ioc4_submodule *is)
 {
        struct ioc4_driver_data *idd;
 
-       down_write(&ioc4_submodules_rwsem);
+       mutex_lock(&ioc4_mutex);
        list_add(&is->is_list, &ioc4_submodules);
-       up_write(&ioc4_submodules_rwsem);
 
        /* Initialize submodule for each IOC4 */
        if (!is->is_probe)
-               return 0;
+               goto out;
 
-       down_read(&ioc4_devices_rwsem);
        list_for_each_entry(idd, &ioc4_devices, idd_list) {
                if (is->is_probe(idd)) {
                        printk(KERN_WARNING
@@ -84,8 +81,8 @@ ioc4_register_submodule(struct ioc4_submodule *is)
                               pci_name(idd->idd_pdev));
                }
        }
-       up_read(&ioc4_devices_rwsem);
-
+ out:
+       mutex_unlock(&ioc4_mutex);
        return 0;
 }
 
@@ -95,15 +92,13 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
 {
        struct ioc4_driver_data *idd;
 
-       down_write(&ioc4_submodules_rwsem);
+       mutex_lock(&ioc4_mutex);
        list_del(&is->is_list);
-       up_write(&ioc4_submodules_rwsem);
 
        /* Remove submodule for each IOC4 */
        if (!is->is_remove)
-               return;
+               goto out;
 
-       down_read(&ioc4_devices_rwsem);
        list_for_each_entry(idd, &ioc4_devices, idd_list) {
                if (is->is_remove(idd)) {
                        printk(KERN_WARNING
@@ -113,7 +108,8 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
                               pci_name(idd->idd_pdev));
                }
        }
-       up_read(&ioc4_devices_rwsem);
+ out:
+       mutex_unlock(&ioc4_mutex);
 }
 
 /*********************
@@ -312,12 +308,11 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
        /* Track PCI-device specific data */
        idd->idd_serial_data = NULL;
        pci_set_drvdata(idd->idd_pdev, idd);
-       down_write(&ioc4_devices_rwsem);
+
+       mutex_lock(&ioc4_mutex);
        list_add(&idd->idd_list, &ioc4_devices);
-       up_write(&ioc4_devices_rwsem);
 
        /* Add this IOC4 to all submodules */
-       down_read(&ioc4_submodules_rwsem);
        list_for_each_entry(is, &ioc4_submodules, is_list) {
                if (is->is_probe && is->is_probe(idd)) {
                        printk(KERN_WARNING
@@ -327,7 +322,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                               pci_name(idd->idd_pdev));
                }
        }
-       up_read(&ioc4_submodules_rwsem);
+       mutex_unlock(&ioc4_mutex);
 
        return 0;
 
@@ -351,7 +346,7 @@ ioc4_remove(struct pci_dev *pdev)
        idd = pci_get_drvdata(pdev);
 
        /* Remove this IOC4 from all submodules */
-       down_read(&ioc4_submodules_rwsem);
+       mutex_lock(&ioc4_mutex);
        list_for_each_entry(is, &ioc4_submodules, is_list) {
                if (is->is_remove && is->is_remove(idd)) {
                        printk(KERN_WARNING
@@ -361,7 +356,7 @@ ioc4_remove(struct pci_dev *pdev)
                               pci_name(idd->idd_pdev));
                }
        }
-       up_read(&ioc4_submodules_rwsem);
+       mutex_unlock(&ioc4_mutex);
 
        /* Release resources */
        iounmap(idd->idd_misc_regs);
@@ -377,9 +372,9 @@ ioc4_remove(struct pci_dev *pdev)
        pci_disable_device(pdev);
 
        /* Remove and free driver data */
-       down_write(&ioc4_devices_rwsem);
+       mutex_lock(&ioc4_mutex);
        list_del(&idd->idd_list);
-       up_write(&ioc4_devices_rwsem);
+       mutex_unlock(&ioc4_mutex);
        kfree(idd);
 }