diff mbox series

[net-next,4/6] bnxt_en: Refactor bnxt_get_module_info()

Message ID 1664326724-1415-5-git-send-email-michael.chan@broadcom.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Driver updates | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 41 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan Sept. 28, 2022, 12:58 a.m. UTC
From: Vikas Gupta <vikas.gupta@broadcom.com>

Add bnxt_module_status_check() helper to check if we can proceed to read
module eeprom data.  This helper will be used in the next patch when
adding get_module_eeprom_by_page().

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 1c8a92fa2f2c..379afa670494 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -3184,25 +3184,34 @@  static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
 	return rc;
 }
 
-static int bnxt_get_module_info(struct net_device *dev,
-				struct ethtool_modinfo *modinfo)
+static int bnxt_module_status_check(struct bnxt *bp)
 {
-	u8 data[SFF_DIAG_SUPPORT_OFFSET + 1];
-	struct bnxt *bp = netdev_priv(dev);
-	int rc;
-
 	/* No point in going further if phy status indicates
 	 * module is not inserted or if it is powered down or
 	 * if it is of type 10GBase-T
 	 */
 	if (bp->link_info.module_status >
-		PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG)
+	    PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG)
 		return -EOPNOTSUPP;
 
 	/* This feature is not supported in older firmware versions */
 	if (bp->hwrm_spec_code < 0x10202)
 		return -EOPNOTSUPP;
 
+	return 0;
+}
+
+static int bnxt_get_module_info(struct net_device *dev,
+				struct ethtool_modinfo *modinfo)
+{
+	u8 data[SFF_DIAG_SUPPORT_OFFSET + 1];
+	struct bnxt *bp = netdev_priv(dev);
+	int rc;
+
+	rc = bnxt_module_status_check(bp);
+	if (rc)
+		return rc;
+
 	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0, false,
 					      0, SFF_DIAG_SUPPORT_OFFSET + 1,
 					      data);