swconfig: use a mutex instead of a spinlock, many swconfig calls sleep
authorFelix Fietkau <nbd@openwrt.org>
Thu, 15 Mar 2012 19:32:31 +0000 (19:32 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 15 Mar 2012 19:32:31 +0000 (19:32 +0000)
SVN-Revision: 30952

target/linux/generic/files/drivers/net/phy/swconfig.c
target/linux/generic/files/include/linux/switch.h

index 1baccb1ba3e6280b757b880bd223ff3d953def8a..e772c944819f95735da31374f07bfb0218afbb4d 100644 (file)
@@ -353,7 +353,7 @@ swconfig_get_dev(struct genl_info *info)
                break;
        }
        if (dev)
-               spin_lock(&dev->lock);
+               mutex_lock(&dev->sw_mutex);
        else
                DPRINTF("device %d not found\n", id);
        swconfig_unlock();
@@ -364,7 +364,7 @@ done:
 static inline void
 swconfig_put_dev(struct switch_dev *dev)
 {
-       spin_unlock(&dev->lock);
+       mutex_unlock(&dev->sw_mutex);
 }
 
 static int
@@ -962,7 +962,7 @@ register_switch(struct switch_dev *dev, struct net_device *netdev)
                        return -ENOMEM;
        }
        swconfig_defaults_init(dev);
-       spin_lock_init(&dev->lock);
+       mutex_init(&dev->sw_mutex);
        swconfig_lock();
        dev->id = ++swdev_id;
 
@@ -1000,11 +1000,11 @@ unregister_switch(struct switch_dev *dev)
 {
        swconfig_destroy_led_trigger(dev);
        kfree(dev->portbuf);
-       spin_lock(&dev->lock);
+       mutex_lock(&dev->sw_mutex);
        swconfig_lock();
        list_del(&dev->dev_list);
        swconfig_unlock();
-       spin_unlock(&dev->lock);
+       mutex_unlock(&dev->sw_mutex);
 }
 EXPORT_SYMBOL_GPL(unregister_switch);
 
index 2c88bb327659f71b54113bce91cdd385d2c114aa..4f4085ef89b533d09443d54eb4e9daacd78b8cb1 100644 (file)
@@ -191,7 +191,7 @@ struct switch_dev {
        struct list_head dev_list;
        unsigned long def_global, def_port, def_vlan;
 
-       spinlock_t lock;
+       struct mutex sw_mutex;
        struct switch_port *portbuf;
 
        char buf[128];