ice: use ice_for_each_vsi macro when possible
authorBrett Creeley <brett.creeley@intel.com>
Fri, 8 Feb 2019 20:50:54 +0000 (12:50 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 19 Mar 2019 23:54:23 +0000 (16:54 -0700)
Replace all instances of:
for (i = 0; i < pf->num_alloc_vsi; i++)

with the following macro:
ice_for_each_vsi(pf, i)

This will allow the code to be consistent since there are currently
cases of using both.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c

index eb8d149e317ceab9be78fd96c6db0aed69cf23f6..1bb333c3fdc5e279c5c17d5eadbe0374b97a0fc8 100644 (file)
@@ -1400,13 +1400,12 @@ ice_set_link_ksettings(struct net_device *netdev,
                return -EOPNOTSUPP;
 
        /* Check if this is lan vsi */
-       for (idx = 0 ; idx <  pf->num_alloc_vsi ; idx++) {
+       ice_for_each_vsi(pf, idx)
                if (pf->vsi[idx]->type == ICE_VSI_PF) {
                        if (np->vsi != pf->vsi[idx])
                                return -EOPNOTSUPP;
                        break;
                }
-       }
 
        if (p->phy.media_type != ICE_MEDIA_BASET &&
            p->phy.media_type != ICE_MEDIA_FIBER &&
index d353de4456f5242c607e8358110da76366b085ee..8b4c64ef85edd144a230cceac6c96204518b25fc 100644 (file)
@@ -322,7 +322,7 @@ static void ice_sync_fltr_subtask(struct ice_pf *pf)
 
        clear_bit(ICE_FLAG_FLTR_SYNC, pf->flags);
 
-       for (v = 0; v < pf->num_alloc_vsi; v++)
+       ice_for_each_vsi(pf, v)
                if (pf->vsi[v] && ice_vsi_fltr_changed(pf->vsi[v]) &&
                    ice_vsi_sync_fltr(pf->vsi[v])) {
                        /* come back and try again later */
@@ -642,7 +642,7 @@ static void ice_watchdog_subtask(struct ice_pf *pf)
         * can look at updated numbers whenever it cares to
         */
        ice_update_pf_stats(pf);
-       for (i = 0; i < pf->num_alloc_vsi; i++)
+       ice_for_each_vsi(pf, i)
                if (pf->vsi[i] && pf->vsi[i]->netdev)
                        ice_update_vsi_stats(pf->vsi[i]);
 }
@@ -3273,7 +3273,7 @@ static void ice_vsi_release_all(struct ice_pf *pf)
        if (!pf->vsi)
                return;
 
-       for (i = 0; i < pf->num_alloc_vsi; i++) {
+       ice_for_each_vsi(pf, i) {
                if (!pf->vsi[i])
                        continue;
 
@@ -3372,7 +3372,7 @@ static int ice_vsi_rebuild_all(struct ice_pf *pf)
        int i;
 
        /* loop through pf->vsi array and reinit the VSI if found */
-       for (i = 0; i < pf->num_alloc_vsi; i++) {
+       ice_for_each_vsi(pf, i) {
                int err;
 
                if (!pf->vsi[i])
@@ -3409,7 +3409,7 @@ static int ice_vsi_replay_all(struct ice_pf *pf)
        int i;
 
        /* loop through pf->vsi array and replay the VSI if found */
-       for (i = 0; i < pf->num_alloc_vsi; i++) {
+       ice_for_each_vsi(pf, i) {
                if (!pf->vsi[i])
                        continue;
 
@@ -3520,7 +3520,7 @@ static void ice_rebuild(struct ice_pf *pf)
 
        ice_reset_all_vfs(pf, true);
 
-       for (i = 0; i < pf->num_alloc_vsi; i++) {
+       ice_for_each_vsi(pf, i) {
                bool link_up;
 
                if (!pf->vsi[i] || pf->vsi[i]->type != ICE_VSI_PF)
index 4706dae17764e0bcb1ae25a46bc4c9be62fbc918..d73915af5b18a32bbbfb2d1e08a4236ab80d12b3 100644 (file)
@@ -1385,7 +1385,7 @@ static struct ice_vsi *ice_find_vsi_from_id(struct ice_pf *pf, u16 id)
 {
        int i;
 
-       for (i = 0; i < pf->num_alloc_vsi; i++)
+       ice_for_each_vsi(pf, i)
                if (pf->vsi[i] && pf->vsi[i]->vsi_num == id)
                        return pf->vsi[i];