Skip to contentSkip to conversation

ARM: stm32: Perform node compatible check for KS8851 early

PATCH In review Marek Vasut 2 participants 3 messages Sep 15, 2025 – Sep 17, 2025 Arm STM32

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: stm32: Perform node compatible check for KS8851 early

Check the compatible string of ethernet1 node for KS8851 very early on, before calling uclass_get_device_by_of_path() which might initialize the device and possibly attempt to configure MAC address into device which is not KS8851. Doing the compatibility check early prevent this.

---
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 board/dhelectronics/dh_stm32mp1/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +3 -3
index a15348ad7e7..551094b9489 100644
@@ -85,6 +85,9 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (!ofnode_valid(node))
 		return false;
 
+	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
+		return false;
+
 	ret = ofnode_get_path(node, path, sizeof(path));
 	if (ret)
 		return false;
@@ -93,9 +96,6 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (ret)
 		return false;
 
-	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
-		return false;
-
 	/*
 	 * KS8851 with EEPROM may use custom MAC from EEPROM, read
 	 * out the KS8851 CCR register to determine whether EEPROM
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · Marek Vasut

Check the compatible string of ethernet1 node for KS8851 very early on, before calling uclass_get_device_by_of_path() which might initialize the device and possibly attempt to configure MAC address into device which is not KS8851. Doing the compatibility check early prevent this.

---
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 board/dhelectronics/dh_stm32mp1/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +3 -0
index a15348ad7e7..551094b9489 100644
@@ -85,6 +85,9 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (!ofnode_valid(node))
 		return false;
 
+	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
+		return false;
+
 	ret = ofnode_get_path(node, path, sizeof(path));
 	if (ret)
 		return false;

board/dhelectronics/dh_stm32mp1/board.c static bool dh_stm32_mac_is_in_ks8851(void) · line 101

Quoted 9 lines
board/dhelectronics/dh_stm32mp1/board.c +0 -3
@@ -93,9 +96,6 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (ret)
 		return false;
 
-	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
-		return false;
-
 	/*
 	 * KS8851 with EEPROM may use custom MAC from EEPROM, read
 	 * out the KS8851 CCR register to determine whether EEPROM

Thanks
Patrice

#2 lore raw
Quoted 48 lines · Patrice CHOTARD
Quoted 33 lines · Marek Vasut

Check the compatible string of ethernet1 node for KS8851 very early on, before calling uclass_get_device_by_of_path() which might initialize the device and possibly attempt to configure MAC address into device which is not KS8851. Doing the compatibility check early prevent this.

---
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 board/dhelectronics/dh_stm32mp1/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +3 -0
index a15348ad7e7..551094b9489 100644
@@ -85,6 +85,9 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (!ofnode_valid(node))
 		return false;
 
+	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
+		return false;
+
 	ret = ofnode_get_path(node, path, sizeof(path));
 	if (ret)
 		return false;

board/dhelectronics/dh_stm32mp1/board.c static bool dh_stm32_mac_is_in_ks8851(void) · line 101

Quoted 9 lines
board/dhelectronics/dh_stm32mp1/board.c +0 -3
@@ -93,9 +96,6 @@ static bool dh_stm32_mac_is_in_ks8851(void)
 	if (ret)
 		return false;
 
-	if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll"))
-		return false;
-
 	/*
 	 * KS8851 with EEPROM may use custom MAC from EEPROM, read
 	 * out the KS8851 CCR register to determine whether EEPROM
Quoted 2 lines

Thanks
Patrice

Applied to u-boot-stm32/master

Thanks
Patrice