]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spl: remove redundant prints in boot_from_devices
authorAnshul Dalal <anshuld@ti.com>
Fri, 31 Oct 2025 07:46:26 +0000 (13:16 +0530)
committerTom Rini <trini@konsulko.com>
Thu, 6 Nov 2025 23:42:07 +0000 (17:42 -0600)
The null check for loader in boot_from_devices was moved earlier in the
code path by the commit ae409a84e7bff ("spl: NULL check variable before
dereference"), therefore the subsequent null checks for loader are not
necessary.

This patch removes those checks and refactors the prints to be more
useful in case of errors.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
common/spl/spl.c

index 4dae3d0940d02b59e97f89bea6f803e0ade94332..fd915d9564b6472403bb6ffdd380487d60e581eb 100644 (file)
@@ -643,26 +643,26 @@ static int boot_from_devices(struct spl_image_info *spl_image,
                        if (loader && bootdev != loader->boot_device)
                                continue;
                        if (!CONFIG_IS_ENABLED(SILENT_CONSOLE)) {
-                               if (loader)
-                                       printf("Trying to boot from %s\n",
-                                              spl_loader_name(loader));
-                               else if (CONFIG_IS_ENABLED(SHOW_ERRORS)) {
-                                       printf(PHASE_PROMPT
-                                              "Unsupported Boot Device %d\n",
-                                              bootdev);
-                               } else {
-                                       puts(PHASE_PROMPT
-                                            "Unsupported Boot Device!\n");
-                               }
+                               printf("Trying to boot from %s\n",
+                                      spl_loader_name(loader));
                        }
-                       if (loader) {
-                               ret = spl_load_image(spl_image, loader);
-                               if (!ret) {
-                                       spl_image->boot_device = bootdev;
-                                       return 0;
-                               }
-                               printf("Error: %d\n", ret);
+
+                       ret = spl_load_image(spl_image, loader);
+                       if (!ret) {
+                               spl_image->boot_device = bootdev;
+                               return 0;
                        }
+                       printf("Error: %d\n", ret);
+               }
+
+               if (!CONFIG_IS_ENABLED(SILENT_CONSOLE)) {
+                       if (CONFIG_IS_ENABLED(SHOW_ERRORS))
+                               printf(PHASE_PROMPT
+                                      "Unsupported Boot Device %d\n",
+                                      bootdev);
+                       else
+                               printf(PHASE_PROMPT
+                                      "Unsupported Boot Device!\n");
                }
        }