bonding: add bond_has_slaves() and use it

Currently we verify if we have slaves by checking if bond->slave_list is
empty. Create a define bond_has_slaves() and use it, a bit more readable
and easier to change in the future.

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Veaceslav Falico
2013-09-25 09:20:21 +02:00
committed by David S. Miller
parent b386c58b85
commit 0965a1f3f8
5 changed files with 25 additions and 23 deletions

View File

@@ -1178,7 +1178,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
struct slave *tmp_slave1, *free_mac_slave = NULL;
struct list_head *iter;
if (list_empty(&bond->slave_list)) {
if (!bond_has_slaves(bond)) {
/* this is the first slave */
return 0;
}
@@ -1469,7 +1469,7 @@ void bond_alb_monitor(struct work_struct *work)
read_lock(&bond->lock);
if (list_empty(&bond->slave_list)) {
if (!bond_has_slaves(bond)) {
bond_info->tx_rebalance_counter = 0;
bond_info->lp_counter = 0;
goto re_arm;
@@ -1606,7 +1606,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
*/
void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
{
if (!list_empty(&bond->slave_list))
if (bond_has_slaves(bond))
alb_change_hw_addr_on_detach(bond, slave);
tlb_clear_slave(bond, slave, 0);
@@ -1676,7 +1676,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
swap_slave = bond->curr_active_slave;
rcu_assign_pointer(bond->curr_active_slave, new_slave);
if (!new_slave || list_empty(&bond->slave_list))
if (!new_slave || !bond_has_slaves(bond))
return;
/* set the new curr_active_slave to the bonds mac address