diff mbox series

[RFC,net-next,1/4] ethtool: Extract module EEPROM attributes before validation

Message ID 20210623075925.2610908-2-idosch@idosch.org
State New
Headers show
Series [RFC,net-next,1/4] ethtool: Extract module EEPROM attributes before validation | expand

Commit Message

Ido Schimmel June 23, 2021, 7:59 a.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

Move the extraction of the attributes before their validation, so that
the validation could be easily split into a different function in the
subsequent patch.

No functional changes intended.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 net/ethtool/eeprom.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/ethtool/eeprom.c b/net/ethtool/eeprom.c
index 7e6b37a54add..ed5f677f27cd 100644
--- a/net/ethtool/eeprom.c
+++ b/net/ethtool/eeprom.c
@@ -158,6 +158,9 @@  static int eeprom_parse_request(struct ethnl_req_info *req_info, struct nlattr *
 	request->i2c_address = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS]);
 	request->offset = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_OFFSET]);
 	request->length = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_LENGTH]);
+	request->page = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_PAGE]);
+	if (tb[ETHTOOL_A_MODULE_EEPROM_BANK])
+		request->bank = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_BANK]);
 
 	/* The following set of conditions limit the API to only dump 1/2
 	 * EEPROM page without crossing low page boundary located at offset 128.
@@ -165,7 +168,6 @@  static int eeprom_parse_request(struct ethnl_req_info *req_info, struct nlattr *
 	 * either low 128 bytes or high 128 bytes.
 	 * For pages higher than 0 only high 128 bytes are accessible.
 	 */
-	request->page = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_PAGE]);
 	if (request->page && request->offset < ETH_MODULE_EEPROM_PAGE_LEN) {
 		NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_MODULE_EEPROM_PAGE],
 				    "reading from lower half page is allowed for page 0 only");
@@ -183,9 +185,6 @@  static int eeprom_parse_request(struct ethnl_req_info *req_info, struct nlattr *
 		return -EINVAL;
 	}
 
-	if (tb[ETHTOOL_A_MODULE_EEPROM_BANK])
-		request->bank = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_BANK]);
-
 	return 0;
 }