Skip to content

Commit

Permalink
net/hsr: using kfree_rcu() to simplify the code
Browse files Browse the repository at this point in the history
The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

Signed-off-by: Wei Yongjun <[email protected]>
Acked-by: Arvid Brodin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Wei Yongjun authored and davem330 committed Dec 17, 2013
1 parent 7271174 commit 1aee6cc
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions net/hsr/hsr_framereg.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ int hsr_create_self_node(struct list_head *self_node_db,
return 0;
}

static void node_entry_reclaim(struct rcu_head *rh)
{
kfree(container_of(rh, struct node_entry, rcu_head));
}


/* Add/merge node to the database of nodes. 'skb' must contain an HSR
* supervision frame.
Expand Down Expand Up @@ -175,15 +170,15 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
if (node && !ether_addr_equal(node->MacAddressA, hsr_sp->MacAddressA)) {
/* Node has changed its AddrA, frame was received from SlaveB */
list_del_rcu(&node->mac_list);
call_rcu(&node->rcu_head, node_entry_reclaim);
kfree_rcu(node, rcu_head);
node = NULL;
}

if (node && (dev_idx == node->AddrB_if) &&
!ether_addr_equal(node->MacAddressB, hsr_ethsup->ethhdr.h_source)) {
/* Cables have been swapped */
list_del_rcu(&node->mac_list);
call_rcu(&node->rcu_head, node_entry_reclaim);
kfree_rcu(node, rcu_head);
node = NULL;
}

Expand All @@ -192,7 +187,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
!ether_addr_equal(node->MacAddressA, hsr_ethsup->ethhdr.h_source)) {
/* Cables have been swapped */
list_del_rcu(&node->mac_list);
call_rcu(&node->rcu_head, node_entry_reclaim);
kfree_rcu(node, rcu_head);
node = NULL;
}

Expand Down Expand Up @@ -417,7 +412,7 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
hsr_nl_nodedown(hsr_priv, node->MacAddressA);
list_del_rcu(&node->mac_list);
/* Note that we need to free this entry later: */
call_rcu(&node->rcu_head, node_entry_reclaim);
kfree_rcu(node, rcu_head);
}
}
rcu_read_unlock();
Expand Down

0 comments on commit 1aee6cc

Please sign in to comment.