Skip to contentSkip to conversation

misc: pch_phub: Fix fallout and more cleanup

PATCH New Uwe Kleine-König (The Capable Hub) 1 participant 4 messages May 26 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

cover misc: pch_phub: Fix fallout and more cleanup

Hello,

Sashiko found a relevant issue in the patch that became 7b1d4ad96ea4 ("misc: pch_phub: Introduce an enum for device indentification"). This is fixed in the first patch.

The second patch is a follow-up to commit d14b649fd99f ("misc: pch_phub:
Drop two unused functions") that drops now unused struct members.

The third patch fixes an inconsistency in device handling. The comment suggest that ML7213 isn't handled, the code just falls back in the else branch for it. Make variant handling more explicit using a switch statement. If a new device is added without adapting pch_phub_write_gbe_mac_addr() a compiler warning is triggered.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (3):
misc: pch_phub: Complete enum usage for device identification
misc: pch_phub: Drop unused members from struct pch_phub_reg
misc: pch_phub: Make MAC address configuration more robust

 drivers/misc/pch_phub.c | 59 ++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 39 deletions(-)

base-commit: 7b1d4ad96ea47b3275328fa385d0497e164f1f5f

Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/3 misc: pch_phub: Complete enum usage for device identification

Recently an enum was introduced to identify the different hardware variants instead of magic constants. The respective commit however missed to adapt one code location that still checks the old values.

As the values shifted by one this is a relevant fix.

Fixes 7b1d4ad96ea4 ("misc: pch_phub: Introduce an enum for device indentification")
---
 drivers/misc/pch_phub.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/misc/pch_phub.c +10 -10
index 19c4fa017f24..0097611b97af 100644
@@ -83,6 +83,14 @@
 
 #define PCH_PHUB_OROM_SIZE 15360
 
+enum pch_phub_type {
+	PCH_EG20T,
+	PCH_ML7213,
+	PCH_ML7223M,
+	PCH_ML7223N,
+	PCH_ML7831,
+};
+
 /**
  * struct pch_phub_reg - PHUB register structure
  * @phub_id_reg:			PHUB_ID register val
@@ -125,7 +133,7 @@ struct pch_phub_reg {
 	void __iomem *pch_phub_extrom_base_address;
 	u32 pch_mac_start_address;
 	u32 pch_opt_rom_start_address;
-	int ioh_type;
+	enum pch_phub_type ioh_type;
 	struct pci_dev *pdev;
 };
 
@@ -344,7 +352,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
 	int retval;
 	int i;
 
-	if ((chip->ioh_type == 1) || (chip->ioh_type == 5)) /* EG20T or ML7831*/
+	if (chip->ioh_type == PCH_EG20T || chip->ioh_type == PCH_ML7831)
 		retval = pch_phub_gbe_serial_rom_conf(chip);
 	else	/* ML7223 */
 		retval = pch_phub_gbe_serial_rom_conf_mp(chip);
@@ -537,14 +545,6 @@ static const struct bin_attribute pch_bin_attr = {
 	.write = pch_phub_bin_write,
 };
 
-enum {
-	PCH_EG20T,
-	PCH_ML7213,
-	PCH_ML7223M,
-	PCH_ML7223N,
-	PCH_ML7831,
-};
-
 static int pch_phub_probe(struct pci_dev *pdev,
 				    const struct pci_device_id *id)
 {
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/3 misc: pch_phub: Drop unused members from struct pch_phub_reg

In reply to Uwe Kleine-König (The Capable Hub)

Since commit d14b649fd99f ("misc: pch_phub: Drop two unused functions") all the register values in struct pch_phub_reg are unused. Drop them.

---
 drivers/misc/pch_phub.c | 28 ----------------------------
 1 file changed, 28 deletions(-)
drivers/misc/pch_phub.c +0 -28
index 0097611b97af..5adf7f0c84ab 100644
@@ -93,20 +93,6 @@ enum pch_phub_type {
 
 /**
  * struct pch_phub_reg - PHUB register structure
- * @phub_id_reg:			PHUB_ID register val
- * @q_pri_val_reg:			QUEUE_PRI_VAL register val
- * @rc_q_maxsize_reg:			RC_QUEUE_MAXSIZE register val
- * @bri_q_maxsize_reg:			BRI_QUEUE_MAXSIZE register val
- * @comp_resp_timeout_reg:		COMP_RESP_TIMEOUT register val
- * @bus_slave_control_reg:		BUS_SLAVE_CONTROL_REG register val
- * @deadlock_avoid_type_reg:		DEADLOCK_AVOID_TYPE register val
- * @intpin_reg_wpermit_reg0:		INTPIN_REG_WPERMIT register 0 val
- * @intpin_reg_wpermit_reg1:		INTPIN_REG_WPERMIT register 1 val
- * @intpin_reg_wpermit_reg2:		INTPIN_REG_WPERMIT register 2 val
- * @intpin_reg_wpermit_reg3:		INTPIN_REG_WPERMIT register 3 val
- * @int_reduce_control_reg:		INT_REDUCE_CONTROL registers val
- * @clkcfg_reg:				CLK CFG register val
- * @funcsel_reg:			Function select register value
  * @pch_phub_base_address:		Register base address
  * @pch_phub_extrom_base_address:	external rom base address
  * @pch_mac_start_address:		MAC address area start address
@@ -115,20 +101,6 @@ enum pch_phub_type {
  * @pdev:				pointer to pci device struct
  */
 struct pch_phub_reg {
-	u32 phub_id_reg;
-	u32 q_pri_val_reg;
-	u32 rc_q_maxsize_reg;
-	u32 bri_q_maxsize_reg;
-	u32 comp_resp_timeout_reg;
-	u32 bus_slave_control_reg;
-	u32 deadlock_avoid_type_reg;
-	u32 intpin_reg_wpermit_reg0;
-	u32 intpin_reg_wpermit_reg1;
-	u32 intpin_reg_wpermit_reg2;
-	u32 intpin_reg_wpermit_reg3;
-	u32 int_reduce_control_reg[MAX_NUM_INT_REDUCE_CONTROL_REG];
-	u32 clkcfg_reg;
-	u32 funcsel_reg;
 	void __iomem *pch_phub_base_address;
 	void __iomem *pch_phub_extrom_base_address;
 	u32 pch_mac_start_address;
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/3 misc: pch_phub: Make MAC address configuration more robust

In reply to Uwe Kleine-König (The Capable Hub)

The comment in pch_phub_write_gbe_mac_addr() suggests that only EG20T, ML7831 and ML7223 are handled. Replace the code construct using an if with a switch that has the same semantics but issues a warning if a new device type is added to the driver without adapting this function.

---
 drivers/misc/pch_phub.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/misc/pch_phub.c +11 -2
index 5adf7f0c84ab..15785597da40 100644
@@ -324,10 +324,19 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
 	int retval;
 	int i;
 
-	if (chip->ioh_type == PCH_EG20T || chip->ioh_type == PCH_ML7831)
+	switch (chip->ioh_type) {
+	case PCH_EG20T:
+	case PCH_ML7831:
 		retval = pch_phub_gbe_serial_rom_conf(chip);
-	else	/* ML7223 */
+		break;
+
+	case PCH_ML7213:
+	case PCH_ML7223M:
+	case PCH_ML7223N:
 		retval = pch_phub_gbe_serial_rom_conf_mp(chip);
+		break;
+	}
+
 	if (retval)
 		return retval;
 
Signature · 1 line
2.47.3