Skip to contentSkip to conversation

igc: change default return of igc_read_phy_reg()

PATCH In review [email protected] 3 participants 3 messages May 21, 2021 – Jun 24, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igc: change default return of igc_read_phy_reg()

From: Tom Rix <[email protected]>

Static analysis reports this problem

igc_main.c:4944:20: warning: The left operand of '&'
is a garbage value

    if (!(phy_data & SR_1000T_REMOTE_RX_STATUS) &&
          ~~~~~~~~ ^

pyy_data is set by the call to igc_read_phy_reg() only if there is a read_reg() op, else it is unset and a 0 is returned. Change the return to -EOPNOTSUPP.

Fixes 208983f099d9 ("igc: Add watchdog")
---
 drivers/net/ethernet/intel/igc/igc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc.h +1 -1
index b6d3277c6f520..71100ee7afbee 100644
@@ -577,7 +577,7 @@ static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data)
 	if (hw->phy.ops.read_reg)
 		return hw->phy.ops.read_reg(hw, offset, data);
 
-	return 0;
+	return -EOPNOTSUPP;
 }
 
 void igc_reinit_locked(struct igc_adapter *);
Signature · 1 line
2.26.3
#1 lore raw
Quoted 8 lines · trix at redhat.com

From: Tom Rix <[email protected]>

Static analysis reports this problem

igc_main.c:4944:20: warning: The left operand of '&'
is a garbage value

     if (!(phy_data & SR_1000T_REMOTE_RX_STATUS) &&
           ~~~~~~~~ ^

Tom, thanks for this patch. I believe the same static analysis problem should be with the 'igb_read_phy_reg' method:
https://elixir.bootlin.com/linux/v5.13-rc1/source/drivers/net/ethernet/intel/igb/igb.h#L769

Quoted 2 lines

pyy_data is set by the call to igc_read_phy_reg() only if

%s/pyy_data/phy_data/gc (typo)

Quoted 15 lines

there is a read_reg() op, else it is unset and a 0 is returned. Change the return to -EOPNOTSUPP.

Fixes 208983f099d9 ("igc: Add watchdog")
---
  drivers/net/ethernet/intel/igc/igc.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc.h +0 -0
index b6d3277c6f520..71100ee7afbee 100644

drivers/net/ethernet/intel/igc/igc.h static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data) · line 583

Quoted 8 lines
drivers/net/ethernet/intel/igc/igc.h +1 -1
@@ -577,7 +577,7 @@ static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data)
  	if (hw->phy.ops.read_reg)
  		return hw->phy.ops.read_reg(hw, offset, data);
 
-	return 0;
+	return -EOPNOTSUPP;
  }
 
  void igc_reinit_locked(struct igc_adapter *);

Thanks,
Sasha

Tested-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 13 lines · trix at redhat.com

From: Tom Rix <[email protected]>

Static analysis reports this problem

igc_main.c:4944:20: warning: The left operand of '&'
is a garbage value

     if (!(phy_data & SR_1000T_REMOTE_RX_STATUS) &&
           ~~~~~~~~ ^

pyy_data is set by the call to igc_read_phy_reg() only if there is a read_reg() op, else it is unset and a 0 is returned. Change the return to -EOPNOTSUPP.

Quoted 6 lines
Fixes 208983f099d9 ("igc: Add watchdog")
---
  drivers/net/ethernet/intel/igc/igc.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)