From: Jesse Gross Date: Wed, 29 Dec 2010 21:08:15 +0000 (-0800) Subject: datapath: Merge do_destroy_dp into destroy_dp. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f843b6f0fc45fdba373024aaa759785938858fc;p=openvswitch datapath: Merge do_destroy_dp into destroy_dp. 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 Acked-by: Ben Pfaff --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 8e76af2e..87b2a058 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;