Commit 1b64544d authored by Michael Chan's avatar Michael Chan Committed by Paolo Abeni
Browse files

bnxt_en: Refactor bnxt_get_module_eeprom_by_page()



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: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250310183129.3154117-7-michael.chan@broadcom.com


Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 17596d23
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -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,
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,