datapath: Merge do_destroy_dp into destroy_dp.
authorJesse Gross <jesse@nicira.com>
Wed, 29 Dec 2010 21:08:15 +0000 (13:08 -0800)
committerJesse Gross <jesse@nicira.com>
Thu, 30 Dec 2010 17:25:30 +0000 (09:25 -0800)
Both do_destroy_dp() and destroy_dp() are small functions and
only have a single caller.  There's no good reason for them to
be separate so this merges them together.  It also makes things
more logically consistent and easier to read in the next commit,
which adds additional locking as everything is in one place.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c

index 8e76af2..87b2a05 100644 (file)
@@ -306,11 +306,21 @@ err:
        return err;
 }
 
-static void do_destroy_dp(struct datapath *dp)
+static int destroy_dp(int dp_idx)
 {
+       struct datapath *dp;
+       int err = 0;
        struct vport *p, *n;
        int i;
 
+       rtnl_lock();
+       mutex_lock(&dp_mutex);
+       dp = get_dp(dp_idx);
+       if (!dp) {
+               err = -ENODEV;
+               goto unlock;
+       }
+
        list_for_each_entry_safe (p, n, &dp->port_list, node)
                if (p->port_no != ODPP_LOCAL)
                        dp_detach_port(p);
@@ -325,26 +335,11 @@ static void do_destroy_dp(struct datapath *dp)
        for (i = 0; i < DP_N_QUEUES; i++)
                skb_queue_purge(&dp->queues[i]);
        free_percpu(dp->stats_percpu);
+
        kobject_put(&dp->ifobj);
        module_put(THIS_MODULE);
-}
 
-static int destroy_dp(int dp_idx)
-{
-       struct datapath *dp;
-       int err;
-
-       rtnl_lock();
-       mutex_lock(&dp_mutex);
-       dp = get_dp(dp_idx);
-       err = -ENODEV;
-       if (!dp)
-               goto err_unlock;
-
-       do_destroy_dp(dp);
-       err = 0;
-
-err_unlock:
+unlock:
        mutex_unlock(&dp_mutex);
        rtnl_unlock();
        return err;