diff mbox series

ice-shared: add macro specifying max NVM offset

Message ID 20200227223635.1021197-2-jacob.e.keller@intel.com
State New
Headers show
Series ice-shared: add macro specifying max NVM offset | expand

Commit Message

Jacob Keller Feb. 27, 2020, 10:36 p.m. UTC
The ice_aq_read_nvm function uses a somewhat weird construction for
verifying that the incoming offset is valid. Replace this construction
with a simple greater-than expression, and define the maximum value
(24bits) in the ice_adminq_cmd.h

By providing a macro, the check becomes more clear. Additionally the
maximum offset can be used in other locations.

Change-Id: I50993e53aca7c073d6906f48f8c9a6ecc05248d4
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Title: ice-shared: add macro specifying max NVM offset
Change-type: ImplementationChange
Reviewed-on: https://git-amr-3.devtools.intel.com/gerrit/250507
Tested-by: ND Linux CI Server <nd.linux.ci.server@intel.com>
Reviewed-by: Allan, Bruce W <bruce.w.allan@intel.com>
 ice_adminq_cmd.h | 1 +
 ice_nvm.c        | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)


Jacob Keller Feb. 27, 2020, 10:43 p.m. UTC | #1
This patch was sent in error. Please ignore it, as it's not part of the

diff mbox series


diff --git a/ice_adminq_cmd.h b/ice_adminq_cmd.h
index 38134e9dab11..fbbe676d1f7d 100644
--- a/ice_adminq_cmd.h
+++ b/ice_adminq_cmd.h
@@ -2778,6 +2778,7 @@  ICE_CHECK_PARAM_LEN(ice_aqc_sff_eeprom);
  * NVM Shadow RAM Dump commands (direct 0x0707)
 struct ice_aqc_nvm {
 	__le16 offset_low;
 	u8 offset_high;
diff --git a/ice_nvm.c b/ice_nvm.c
index b075a05eb38f..0e6d8390deb8 100644
--- a/ice_nvm.c
+++ b/ice_nvm.c
@@ -35,8 +35,7 @@  ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
 	cmd = &desc.params.nvm;
-	/* In offset the highest byte must be zeroed. */
-	if (offset & 0xFF000000)
+	if (offset > ICE_AQC_NVM_MAX_OFFSET)
 		return ICE_ERR_PARAM;
 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_read);