From: Lukasz Czapnik <[email protected]>

Fix unreachable code: the conditionals in ice_set_pauseparam() used
the bitwise-AND operator suggesting aq_failures is a bitmap, but it
is actually an enum, making the third condition logically unreachable.

Replace the if-else ladder with a switch statement.  Also move the
aq_failures initialization to the variable declaration and remove the
redundant zeroing from ice_set_fc().

Fixes: fcea6f3da546 ("ice: Add stats and ethtool support")
Signed-off-by: Lukasz Czapnik <[email protected]>
Signed-off-by: Aleksandr Loktionov <[email protected]>
---

 drivers/net/ethernet/intel/ice/ice_common.c  |  1 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 12 ++++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c 
b/drivers/net/ethernet/intel/ice/ice_common.c
index f1a6601..6dad7d4 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -3883,7 +3883,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, 
bool ena_auto_link_update)
        if (!pi || !aq_failures)
                return -EINVAL;
 
-       *aq_failures = 0;
        hw = pi->hw;
 
        pcaps = kzalloc_obj(*pcaps);
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c 
b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 2a4f06f..0cf064c 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -3501,7 +3501,7 @@ ice_set_pauseparam(struct net_device *netdev, struct 
ethtool_pauseparam *pause)
        struct ice_vsi *vsi = np->vsi;
        struct ice_hw *hw = &pf->hw;
        struct ice_port_info *pi;
-       u8 aq_failures;
+       u8 aq_failures = 0;
        bool link_up;
        u32 is_an;
        int err;
@@ -3572,18 +3572,22 @@ ice_set_pauseparam(struct net_device *netdev, struct 
ethtool_pauseparam *pause)
        /* Set the FC mode and only restart AN if link is up */
        err = ice_set_fc(pi, &aq_failures, link_up);
 
-       if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
+       switch (aq_failures) {
+       case ICE_SET_FC_AQ_FAIL_GET:
                netdev_info(netdev, "Set fc failed on the get_phy_capabilities 
call with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
-       } else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
+               break;
+       case ICE_SET_FC_AQ_FAIL_SET:
                netdev_info(netdev, "Set fc failed on the set_phy_config call 
with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
-       } else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
+               break;
+       case ICE_SET_FC_AQ_FAIL_UPDATE:
                netdev_info(netdev, "Set fc failed on the get_link_info call 
with err %d aq_err %s\n",
                            err, libie_aq_str(hw->adminq.sq_last_status));
                err = -EAGAIN;
+               break;
        }
 
        return err;
-- 
2.52.0

Reply via email to