]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mach-snapdragon: of_fixup: fix condition check in ft_board_setup()
authorCaleb Connolly <caleb.connolly@linaro.org>
Mon, 31 Mar 2025 10:43:18 +0000 (12:43 +0200)
committerCaleb Connolly <caleb.connolly@linaro.org>
Thu, 10 Apr 2025 13:43:10 +0000 (15:43 +0200)
The fdt_node_check_compatible() function returns 0 on success which is
pretty confusing, and we were using it wrong!

Invert the condition check and refactor things to be more readable.

Additionally, add the check for the RB1 which needs the same fixup as
the RB2.

Reported-by: Sam Day <me@samcday.com>
Fixes: e64503f1fcdf ("mach-snapdragon: implement ft_board_setup() for USB role selection")
Tested-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
Tested-by: Sam Day <me@samcday.com>
Link: https://lore.kernel.org/r/20250331104327.321339-1-caleb.connolly@linaro.org
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
arch/arm/mach-snapdragon/of_fixup.c

index ea956a4791d0c7c93ce385a5d2d7baa12ca857a8..1ea0c18c2f2789a8aa054cd95bb9e4308d6b3384 100644 (file)
@@ -161,14 +161,14 @@ int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
        struct fdt_header *fdt = blob;
        int node;
 
-       /* We only want to do this fix-up for the RB1 board, quick return for all others */
-       if (!fdt_node_check_compatible(fdt, 0, "qcom,qrb4210-rb2"))
-               return 0;
-
-       fdt_for_each_node_by_compatible(node, blob, 0, "snps,dwc3") {
-               log_debug("%s: Setting 'dr_mode' to OTG\n", fdt_get_name(blob, node, NULL));
-               fdt_setprop_string(fdt, node, "dr_mode", "otg");
-               break;
+       /* On RB1/2 we need to fix-up the dr_mode */
+       if (!fdt_node_check_compatible(fdt, 0, "qcom,qrb4210-rb2") ||
+           !fdt_node_check_compatible(fdt, 0, "qcom,qrb2210-rb1")) {
+               fdt_for_each_node_by_compatible(node, blob, 0, "snps,dwc3") {
+                       log_debug("%s: Setting 'dr_mode' to OTG\n", fdt_get_name(blob, node, NULL));
+                       fdt_setprop_string(fdt, node, "dr_mode", "otg");
+                       break;
+               }
        }
 
        return 0;