]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bnxt_en: Refactor bnxt_get_module_eeprom_by_page()
authorMichael Chan <michael.chan@broadcom.com>
Mon, 10 Mar 2025 18:31:28 +0000 (11:31 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 18 Mar 2025 09:25:22 +0000 (10:25 +0100)
In preparation for adding .set_module_eeprom_by_page(), extract the
common error checking done in bnxt_get_module_eeprom_by_page() into
a new common function that can be re-used for
.set_module_eeprom_by_page().

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250310183129.3154117-7-michael.chan@broadcom.com
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index e031340bdce2725b12b56122c48becb651b2de58..c0de8f0e722d3f7e12c9564581945f21ed99bb8e 100644 (file)
@@ -4541,11 +4541,11 @@ static int bnxt_get_module_status(struct bnxt *bp, struct netlink_ext_ack *extac
        return -EINVAL;
 }
 
-static int bnxt_get_module_eeprom_by_page(struct net_device *dev,
-                                         const struct ethtool_module_eeprom *page_data,
-                                         struct netlink_ext_ack *extack)
+static int
+bnxt_mod_eeprom_by_page_precheck(struct bnxt *bp,
+                                const struct ethtool_module_eeprom *page_data,
+                                struct netlink_ext_ack *extack)
 {
-       struct bnxt *bp = netdev_priv(dev);
        int rc;
 
        if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) {
@@ -4567,6 +4567,19 @@ static int bnxt_get_module_eeprom_by_page(struct net_device *dev,
                NL_SET_ERR_MSG_MOD(extack, "Firmware not capable for bank selection");
                return -EINVAL;
        }
+       return 0;
+}
+
+static int bnxt_get_module_eeprom_by_page(struct net_device *dev,
+                                         const struct ethtool_module_eeprom *page_data,
+                                         struct netlink_ext_ack *extack)
+{
+       struct bnxt *bp = netdev_priv(dev);
+       int rc;
+
+       rc = bnxt_mod_eeprom_by_page_precheck(bp, page_data, extack);
+       if (rc)
+               return rc;
 
        rc = bnxt_read_sfp_module_eeprom_info(bp, page_data->i2c_address << 1,
                                              page_data->page, page_data->bank,