[PATCH] ice-shared: add macro specifying max NVM offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
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@xxxxxxxxx>
Reviewed-by: Allan, Bruce W <bruce.w.allan@xxxxxxxxx>
---
 ice_adminq_cmd.h | 1 +
 ice_nvm.c        | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

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 {
+#define ICE_AQC_NVM_MAX_OFFSET		0xFFFFFF
 	__le16 offset_low;
 	u8 offset_high;
 #ifdef PREBOOT_SUPPORT
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);
-- 
2.25.0.368.g28a2d05eebfb




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux