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>
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);
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;