Skip to contentSkip to conversation

phy: Fix phy_string_for_interface() function

PATCH In review Pali Rohár 2 participants 3 messages May 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: Fix phy_string_for_interface() function

Commit c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition") broke function phy_string_for_interface(). And therefore completely broke support for 2500base-x mode in Armada 3720 comphy driver.

Since that commit function phy_string_for_interface() returns constant value PHY_INTERFACE_MODE_NA because PHY_INTERFACE_MODE_NA from moved from end to the beginning.

Previous value of PHY_INTERFACE_MODE_NA was PHY_INTERFACE_MODE_MAX-1. So change phy_string_for_interface() code to check upper bound via previous value.

This patch fixes 2500base-x mode on Armada 3720

Fixes c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition")
---
 include/phy_interface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/phy_interface.h +1 -1
index ce3b5004ec22..fed3357b9a26 100644
@@ -85,7 +85,7 @@ static const char * const backplane_mode_strings[] = {
 static inline const char *phy_string_for_interface(phy_interface_t i)
 {
 	/* Default to unknown */
-	if (i > PHY_INTERFACE_MODE_NA)
+	if (i >= PHY_INTERFACE_MODE_MAX)
 		i = PHY_INTERFACE_MODE_NA;
 
 	return phy_interface_strings[i];
Signature · 1 line
2.20.1
#1 lore raw
Quoted 13 lines · Pali Rohár

Commit c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition") broke function phy_string_for_interface(). And therefore completely broke support for 2500base-x mode in Armada 3720 comphy driver.

Since that commit function phy_string_for_interface() returns constant value PHY_INTERFACE_MODE_NA because PHY_INTERFACE_MODE_NA from moved from end to the beginning.

Previous value of PHY_INTERFACE_MODE_NA was PHY_INTERFACE_MODE_MAX-1. So change phy_string_for_interface() code to check upper bound via previous value.

Quoted 5 lines

This patch fixes 2500base-x mode on Armada 3720

Fixes c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition")

---

Ramon, can you please apply this patch, since people are hitting the issue?
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#2 lore raw
Quoted 14 lines · On Thursday 19 May 2022 13:03:43 Vladimir Oltean wrote:
Quoted 13 lines · Pali Rohár

Commit c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition") broke function phy_string_for_interface(). And therefore completely broke support for 2500base-x mode in Armada 3720 comphy driver.

Since that commit function phy_string_for_interface() returns constant value PHY_INTERFACE_MODE_NA because PHY_INTERFACE_MODE_NA from moved from end to the beginning.

Previous value of PHY_INTERFACE_MODE_NA was PHY_INTERFACE_MODE_MAX-1. So change phy_string_for_interface() code to check upper bound via previous value.

Quoted 8 lines
Quoted 5 lines

This patch fixes 2500base-x mode on Armada 3720

Fixes c677fb1e3196 ("phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition")

---

Ramon, can you please apply this patch, since people are hitting the issue?
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Ou, I did not know that this patch is already on ML.