[ovs-dev] [PATCH 1/7] datapath: Merge do_destroy_dp into destroy_dp.

Jesse Gross jesse at nicira.com
Wed Dec 29 23:41:29 UTC 2010


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 at nicira.com>
---
 datapath/datapath.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 8e76af2..87b2a05 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -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;
-- 
1.7.1





More information about the dev mailing list