1f2507
From 2e122ad9aa2aa0259df1035e3ec2765d8e008394 Mon Sep 17 00:00:00 2001
1f2507
From: Ido Schimmel <idosch@nvidia.com>
1f2507
Date: Tue, 12 Oct 2021 16:25:19 +0300
1f2507
Subject: [PATCH 20/35] sff-8636: Consolidate code between IOCTL and netlink
1f2507
 paths
1f2507
1f2507
Now that both the netlink and IOCTL paths use the same memory map
1f2507
structure for parsing, the code can be easily consolidated.
1f2507
1f2507
Note that the switch-case statement is not necessary for the netlink
1f2507
path, as the netlink code (i.e., netlink/module-eeprom.c) already
1f2507
performed the check, but it is required for the IOCTL path.
1f2507
1f2507
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
1f2507
---
1f2507
 qsfp.c | 29 +++++++++++++++--------------
1f2507
 1 file changed, 15 insertions(+), 14 deletions(-)
1f2507
1f2507
diff --git a/qsfp.c b/qsfp.c
1f2507
index 354b3b1ce9ff..4aa49351e6b7 100644
1f2507
--- a/qsfp.c
1f2507
+++ b/qsfp.c
1f2507
@@ -898,6 +898,19 @@ static void sff8636_show_page_zero(const struct sff8636_memory_map *map)
1f2507
 				     SFF8636_REV_COMPLIANCE_OFFSET);
1f2507
 }
1f2507
 
1f2507
+static void sff8636_show_all_common(const struct sff8636_memory_map *map)
1f2507
+{
1f2507
+	sff8636_show_identifier(map);
1f2507
+	switch (map->lower_memory[SFF8636_ID_OFFSET]) {
1f2507
+	case SFF8024_ID_QSFP:
1f2507
+	case SFF8024_ID_QSFP_PLUS:
1f2507
+	case SFF8024_ID_QSFP28:
1f2507
+		sff8636_show_page_zero(map);
1f2507
+		sff8636_show_dom(map);
1f2507
+		break;
1f2507
+	}
1f2507
+}
1f2507
+
1f2507
 static void sff8636_memory_map_init_buf(struct sff8636_memory_map *map,
1f2507
 					const __u8 *id, __u32 eeprom_len)
1f2507
 {
1f2507
@@ -931,16 +944,7 @@ void sff8636_show_all_ioctl(const __u8 *id, __u32 eeprom_len)
1f2507
 	}
1f2507
 
1f2507
 	sff8636_memory_map_init_buf(&map, id, eeprom_len);
1f2507
-
1f2507
-	sff8636_show_identifier(&map);
1f2507
-	switch (map.lower_memory[SFF8636_ID_OFFSET]) {
1f2507
-	case SFF8024_ID_QSFP:
1f2507
-	case SFF8024_ID_QSFP_PLUS:
1f2507
-	case SFF8024_ID_QSFP28:
1f2507
-		sff8636_show_page_zero(&map);
1f2507
-		sff8636_show_dom(&map);
1f2507
-		break;
1f2507
-	}
1f2507
+	sff8636_show_all_common(&map);
1f2507
 }
1f2507
 
1f2507
 static void
1f2507
@@ -974,8 +978,5 @@ void sff8636_show_all_nl(const struct ethtool_module_eeprom *page_zero,
1f2507
 	struct sff8636_memory_map map = {};
1f2507
 
1f2507
 	sff8636_memory_map_init_pages(&map, page_zero, page_three);
1f2507
-
1f2507
-	sff8636_show_identifier(&map);
1f2507
-	sff8636_show_page_zero(&map);
1f2507
-	sff8636_show_dom(&map);
1f2507
+	sff8636_show_all_common(&map);
1f2507
 }
1f2507
-- 
1f2507
2.35.1
1f2507