tipc: remove dev_base_lock use from enable_bearer
authorYing Xue <ying.xue@windriver.com>
Mon, 17 Jun 2013 14:54:51 +0000 (10:54 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jun 2013 22:53:01 +0000 (15:53 -0700)
Convert enable_bearer() to RCU locking with dev_get_by_name().

Based on a similar changeset in commit 840a185d ["aoe: remove
dev_base_lock use from aoecmd_cfg_pkts()"] -- quoting that:

  "dev_base_lock is the legacy way to lock the device list,
   and is planned to disappear. (writers hold RTNL, readers
   hold RCU lock)"

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/eth_media.c
net/tipc/ib_media.c

index c1aa37fdca2f8d7576d0f68e282f8150bbe7c84d..40ea40cf6204506f4a579f99d2a0c3d8e79652ca 100644 (file)
@@ -162,8 +162,7 @@ static void setup_bearer(struct work_struct *work)
  */
 static int enable_bearer(struct tipc_bearer *tb_ptr)
 {
-       struct net_device *dev = NULL;
-       struct net_device *pdev = NULL;
+       struct net_device *dev;
        struct eth_bearer *eb_ptr = &eth_bearers[0];
        struct eth_bearer *stop = &eth_bearers[MAX_ETH_BEARERS];
        char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
@@ -178,15 +177,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
        }
 
        /* Find device with specified name */
-       read_lock(&dev_base_lock);
-       for_each_netdev(&init_net, pdev) {
-               if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
-                       dev = pdev;
-                       dev_hold(dev);
-                       break;
-               }
-       }
-       read_unlock(&dev_base_lock);
+       dev = dev_get_by_name(&init_net, driver_name);
        if (!dev)
                return -ENODEV;
 
index baa9df4327d955472ae04d464c8958af4bae2356..ad2e1ec4117e316de8a497ab7e83a7b4fe6a8eb8 100644 (file)
@@ -155,8 +155,7 @@ static void setup_bearer(struct work_struct *work)
  */
 static int enable_bearer(struct tipc_bearer *tb_ptr)
 {
-       struct net_device *dev = NULL;
-       struct net_device *pdev = NULL;
+       struct net_device *dev;
        struct ib_bearer *ib_ptr = &ib_bearers[0];
        struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS];
        char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
@@ -171,15 +170,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
        }
 
        /* Find device with specified name */
-       read_lock(&dev_base_lock);
-       for_each_netdev(&init_net, pdev) {
-               if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
-                       dev = pdev;
-                       dev_hold(dev);
-                       break;
-               }
-       }
-       read_unlock(&dev_base_lock);
+       dev = dev_get_by_name(&init_net, driver_name);
        if (!dev)
                return -ENODEV;