[PATCH] ARM: stm32: Perform node compatible check for KS8851 early

Marek Vasut marek.vasut at mailbox.org
Mon Sep 15 02:49:05 CEST 2025


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.

Signed-off-by: Marek Vasut <marek.vasut at mailbox.org>
---
Cc: Patrice Chotard <patrice.chotard at foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at dh-electronics.com
Cc: u-boot at lists.denx.de
Cc: uboot-stm32 at st-md-mailman.stormreply.com
---
 board/dhelectronics/dh_stm32mp1/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index a15348ad7e7..551094b9489 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -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
-- 
2.51.0



More information about the U-Boot mailing list