batman-adv: Fix names in kerneldoc of functions
[deliverable/linux.git] / net / batman-adv / originator.c
index ae6d18cafc5a1f9ee03145c9448c33fea87d2cac..dfeebc89ed9a92b90e2e31a3d14b5d06765d32fb 100644 (file)
@@ -163,148 +163,101 @@ err:
 }
 
 /**
- * batadv_neigh_ifinfo_free_rcu - free the neigh_ifinfo object
- * @rcu: rcu pointer of the neigh_ifinfo object
- */
-static void batadv_neigh_ifinfo_free_rcu(struct rcu_head *rcu)
-{
-       struct batadv_neigh_ifinfo *neigh_ifinfo;
-
-       neigh_ifinfo = container_of(rcu, struct batadv_neigh_ifinfo, rcu);
-
-       if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT)
-               batadv_hardif_free_ref_now(neigh_ifinfo->if_outgoing);
-
-       kfree(neigh_ifinfo);
-}
-
-/**
- * batadv_neigh_ifinfo_free_now - decrement the refcounter and possibly free
- *  the neigh_ifinfo (without rcu callback)
+ * batadv_neigh_ifinfo_release - release neigh_ifinfo from lists and queue for
+ *  free after rcu grace period
  * @neigh_ifinfo: the neigh_ifinfo object to release
  */
 static void
-batadv_neigh_ifinfo_free_ref_now(struct batadv_neigh_ifinfo *neigh_ifinfo)
+batadv_neigh_ifinfo_release(struct batadv_neigh_ifinfo *neigh_ifinfo)
 {
-       if (atomic_dec_and_test(&neigh_ifinfo->refcount))
-               batadv_neigh_ifinfo_free_rcu(&neigh_ifinfo->rcu);
+       if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT)
+               batadv_hardif_free_ref(neigh_ifinfo->if_outgoing);
+
+       kfree_rcu(neigh_ifinfo, rcu);
 }
 
 /**
- * batadv_neigh_ifinfo_free_ref - decrement the refcounter and possibly free
+ * batadv_neigh_ifinfo_free_ref - decrement the refcounter and possibly release
  *  the neigh_ifinfo
  * @neigh_ifinfo: the neigh_ifinfo object to release
  */
 void batadv_neigh_ifinfo_free_ref(struct batadv_neigh_ifinfo *neigh_ifinfo)
 {
        if (atomic_dec_and_test(&neigh_ifinfo->refcount))
-               call_rcu(&neigh_ifinfo->rcu, batadv_neigh_ifinfo_free_rcu);
+               batadv_neigh_ifinfo_release(neigh_ifinfo);
 }
 
 /**
- * batadv_hardif_neigh_free_rcu - free the hardif neigh_node
- * @rcu: rcu pointer of the neigh_node
- */
-static void batadv_hardif_neigh_free_rcu(struct rcu_head *rcu)
-{
-       struct batadv_hardif_neigh_node *hardif_neigh;
-
-       hardif_neigh = container_of(rcu, struct batadv_hardif_neigh_node, rcu);
-
-       batadv_hardif_free_ref_now(hardif_neigh->if_incoming);
-       kfree(hardif_neigh);
-}
-
-/**
- * batadv_hardif_neigh_free_now - decrement the hardif neighbors refcounter
- *  and possibly free it (without rcu callback)
+ * batadv_hardif_neigh_release - release hardif neigh node from lists and
+ *  queue for free after rcu grace period
  * @hardif_neigh: hardif neigh neighbor to free
  */
 static void
-batadv_hardif_neigh_free_now(struct batadv_hardif_neigh_node *hardif_neigh)
+batadv_hardif_neigh_release(struct batadv_hardif_neigh_node *hardif_neigh)
 {
-       if (atomic_dec_and_test(&hardif_neigh->refcount)) {
-               spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
-               hlist_del_init_rcu(&hardif_neigh->list);
-               spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
+       spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
+       hlist_del_init_rcu(&hardif_neigh->list);
+       spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
 
-               batadv_hardif_neigh_free_rcu(&hardif_neigh->rcu);
-       }
+       batadv_hardif_free_ref(hardif_neigh->if_incoming);
+       kfree_rcu(hardif_neigh, rcu);
 }
 
 /**
  * batadv_hardif_neigh_free_ref - decrement the hardif neighbors refcounter
- *  and possibly free it
+ *  and possibly release it
  * @hardif_neigh: hardif neigh neighbor to free
  */
 void batadv_hardif_neigh_free_ref(struct batadv_hardif_neigh_node *hardif_neigh)
 {
-       if (atomic_dec_and_test(&hardif_neigh->refcount)) {
-               spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
-               hlist_del_init_rcu(&hardif_neigh->list);
-               spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
-
-               call_rcu(&hardif_neigh->rcu, batadv_hardif_neigh_free_rcu);
-       }
+       if (atomic_dec_and_test(&hardif_neigh->refcount))
+               batadv_hardif_neigh_release(hardif_neigh);
 }
 
 /**
- * batadv_neigh_node_free_rcu - free the neigh_node
- * @rcu: rcu pointer of the neigh_node
+ * batadv_neigh_node_release - release neigh_node from lists and queue for
+ *  free after rcu grace period
+ * @neigh_node: neigh neighbor to free
  */
-static void batadv_neigh_node_free_rcu(struct rcu_head *rcu)
+static void batadv_neigh_node_release(struct batadv_neigh_node *neigh_node)
 {
        struct hlist_node *node_tmp;
-       struct batadv_neigh_node *neigh_node;
        struct batadv_hardif_neigh_node *hardif_neigh;
        struct batadv_neigh_ifinfo *neigh_ifinfo;
        struct batadv_algo_ops *bao;
 
-       neigh_node = container_of(rcu, struct batadv_neigh_node, rcu);
        bao = neigh_node->orig_node->bat_priv->bat_algo_ops;
 
        hlist_for_each_entry_safe(neigh_ifinfo, node_tmp,
                                  &neigh_node->ifinfo_list, list) {
-               batadv_neigh_ifinfo_free_ref_now(neigh_ifinfo);
+               batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
        }
 
        hardif_neigh = batadv_hardif_neigh_get(neigh_node->if_incoming,
                                               neigh_node->addr);
        if (hardif_neigh) {
                /* batadv_hardif_neigh_get() increases refcount too */
-               batadv_hardif_neigh_free_now(hardif_neigh);
-               batadv_hardif_neigh_free_now(hardif_neigh);
+               batadv_hardif_neigh_free_ref(hardif_neigh);
+               batadv_hardif_neigh_free_ref(hardif_neigh);
        }
 
        if (bao->bat_neigh_free)
                bao->bat_neigh_free(neigh_node);
 
-       batadv_hardif_free_ref_now(neigh_node->if_incoming);
+       batadv_hardif_free_ref(neigh_node->if_incoming);
 
-       kfree(neigh_node);
-}
-
-/**
- * batadv_neigh_node_free_ref_now - decrement the neighbors refcounter
- *  and possibly free it (without rcu callback)
- * @neigh_node: neigh neighbor to free
- */
-static void
-batadv_neigh_node_free_ref_now(struct batadv_neigh_node *neigh_node)
-{
-       if (atomic_dec_and_test(&neigh_node->refcount))
-               batadv_neigh_node_free_rcu(&neigh_node->rcu);
+       kfree_rcu(neigh_node, rcu);
 }
 
 /**
  * batadv_neigh_node_free_ref - decrement the neighbors refcounter
- *  and possibly free it
+ *  and possibly release it
  * @neigh_node: neigh neighbor to free
  */
 void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node)
 {
        if (atomic_dec_and_test(&neigh_node->refcount))
-               call_rcu(&neigh_node->rcu, batadv_neigh_node_free_rcu);
+               batadv_neigh_node_release(neigh_node);
 }
 
 /**
@@ -422,7 +375,7 @@ out:
 
 /**
  * batadv_neigh_ifinfo_get - find the ifinfo from an neigh_node
- * @neigh_node: the neigh node to be queried
+ * @neigh: the neigh node to be queried
  * @if_outgoing: the interface for which the ifinfo should be acquired
  *
  * The object is returned with refcounter increased by 1.
@@ -455,7 +408,7 @@ batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
 
 /**
  * batadv_neigh_ifinfo_new - search and possibly create an neigh_ifinfo object
- * @neigh_node: the neigh node to be queried
+ * @neigh: the neigh node to be queried
  * @if_outgoing: the interface for which the ifinfo should be acquired
  *
  * Returns NULL in case of failure or the neigh_ifinfo object for the
@@ -733,108 +686,99 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset)
 }
 
 /**
- * batadv_orig_ifinfo_free_rcu - free the orig_ifinfo object
- * @rcu: rcu pointer of the orig_ifinfo object
+ * batadv_orig_ifinfo_release - release orig_ifinfo from lists and queue for
+ *  free after rcu grace period
+ * @orig_ifinfo: the orig_ifinfo object to release
  */
-static void batadv_orig_ifinfo_free_rcu(struct rcu_head *rcu)
+static void batadv_orig_ifinfo_release(struct batadv_orig_ifinfo *orig_ifinfo)
 {
-       struct batadv_orig_ifinfo *orig_ifinfo;
        struct batadv_neigh_node *router;
 
-       orig_ifinfo = container_of(rcu, struct batadv_orig_ifinfo, rcu);
-
        if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT)
-               batadv_hardif_free_ref_now(orig_ifinfo->if_outgoing);
+               batadv_hardif_free_ref(orig_ifinfo->if_outgoing);
 
        /* this is the last reference to this object */
        router = rcu_dereference_protected(orig_ifinfo->router, true);
        if (router)
-               batadv_neigh_node_free_ref_now(router);
-       kfree(orig_ifinfo);
+               batadv_neigh_node_free_ref(router);
+
+       kfree_rcu(orig_ifinfo, rcu);
 }
 
 /**
- * batadv_orig_ifinfo_free_ref - decrement the refcounter and possibly free
- *  the orig_ifinfo (without rcu callback)
+ * batadv_orig_ifinfo_free_ref - decrement the refcounter and possibly release
+ *  the orig_ifinfo
  * @orig_ifinfo: the orig_ifinfo object to release
  */
-static void
-batadv_orig_ifinfo_free_ref_now(struct batadv_orig_ifinfo *orig_ifinfo)
+void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo)
 {
        if (atomic_dec_and_test(&orig_ifinfo->refcount))
-               batadv_orig_ifinfo_free_rcu(&orig_ifinfo->rcu);
+               batadv_orig_ifinfo_release(orig_ifinfo);
 }
 
 /**
- * batadv_orig_ifinfo_free_ref - decrement the refcounter and possibly free
- *  the orig_ifinfo
- * @orig_ifinfo: the orig_ifinfo object to release
+ * batadv_orig_node_free_rcu - free the orig_node
+ * @rcu: rcu pointer of the orig_node
  */
-void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo)
+static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
 {
-       if (atomic_dec_and_test(&orig_ifinfo->refcount))
-               call_rcu(&orig_ifinfo->rcu, batadv_orig_ifinfo_free_rcu);
+       struct batadv_orig_node *orig_node;
+
+       orig_node = container_of(rcu, struct batadv_orig_node, rcu);
+
+       batadv_mcast_purge_orig(orig_node);
+
+       batadv_frag_purge_orig(orig_node, NULL);
+
+       if (orig_node->bat_priv->bat_algo_ops->bat_orig_free)
+               orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node);
+
+       kfree(orig_node->tt_buff);
+       kfree(orig_node);
 }
 
-static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
+/**
+ * batadv_orig_node_release - release orig_node from lists and queue for
+ *  free after rcu grace period
+ * @orig_node: the orig node to free
+ */
+static void batadv_orig_node_release(struct batadv_orig_node *orig_node)
 {
        struct hlist_node *node_tmp;
        struct batadv_neigh_node *neigh_node;
-       struct batadv_orig_node *orig_node;
        struct batadv_orig_ifinfo *orig_ifinfo;
 
-       orig_node = container_of(rcu, struct batadv_orig_node, rcu);
-
        spin_lock_bh(&orig_node->neigh_list_lock);
 
        /* for all neighbors towards this originator ... */
        hlist_for_each_entry_safe(neigh_node, node_tmp,
                                  &orig_node->neigh_list, list) {
                hlist_del_rcu(&neigh_node->list);
-               batadv_neigh_node_free_ref_now(neigh_node);
+               batadv_neigh_node_free_ref(neigh_node);
        }
 
        hlist_for_each_entry_safe(orig_ifinfo, node_tmp,
                                  &orig_node->ifinfo_list, list) {
                hlist_del_rcu(&orig_ifinfo->list);
-               batadv_orig_ifinfo_free_ref_now(orig_ifinfo);
+               batadv_orig_ifinfo_free_ref(orig_ifinfo);
        }
        spin_unlock_bh(&orig_node->neigh_list_lock);
 
-       batadv_mcast_purge_orig(orig_node);
-
        /* Free nc_nodes */
        batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL);
 
-       batadv_frag_purge_orig(orig_node, NULL);
-
-       if (orig_node->bat_priv->bat_algo_ops->bat_orig_free)
-               orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node);
-
-       kfree(orig_node->tt_buff);
-       kfree(orig_node);
+       call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
 }
 
 /**
  * batadv_orig_node_free_ref - decrement the orig node refcounter and possibly
- * schedule an rcu callback for freeing it
+ *  release it
  * @orig_node: the orig node to free
  */
 void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node)
 {
        if (atomic_dec_and_test(&orig_node->refcount))
-               call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu);
-}
-
-/**
- * batadv_orig_node_free_ref_now - decrement the orig node refcounter and
- * possibly free it (without rcu callback)
- * @orig_node: the orig node to free
- */
-void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node)
-{
-       if (atomic_dec_and_test(&orig_node->refcount))
-               batadv_orig_node_free_rcu(&orig_node->rcu);
+               batadv_orig_node_release(orig_node);
 }
 
 void batadv_originator_free(struct batadv_priv *bat_priv)
This page took 0.04423 seconds and 5 git commands to generate.