]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal-net: Simplify spi_get_bootseq() bootmode switch
authorMichal Simek <michal.simek@amd.com>
Tue, 23 Jun 2026 12:53:40 +0000 (14:53 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 8 Jul 2026 06:55:51 +0000 (08:55 +0200)
The QSPI and OSPI cases only differ in the SPI device name. Pick the name
in the switch and perform a single uclass_get_device_by_name() lookup
afterwards, instead of repeating the lookup and dev_seq() in every case.

No functional change.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://patch.msgid.link/191f0f583e2d02c184ea2a2a2fe0ef473ca9fe61.1782219202.git.michal.simek@amd.com
board/xilinx/versal-net/board.c

index 5ad8c8d6426a45c0e7421ad700495b9f6f690e5b..50dd49927be2e55190c8c81b404c53ab894bb246 100644 (file)
@@ -71,41 +71,34 @@ int board_early_init_r(void)
 static int spi_get_bootseq(u8 bootmode)
 {
        struct udevice *dev;
-       int bootseq = -1;
+       const char *name;
+       int bootseq;
 
        switch (bootmode) {
        case QSPI_MODE_24BIT:
                puts("QSPI_MODE_24\n");
-               if (uclass_get_device_by_name(UCLASS_SPI,
-                                             "spi@f1030000", &dev)) {
-                       debug("QSPI driver for QSPI device is not present\n");
-                       break;
-               }
-               bootseq = dev_seq(dev);
+               name = "spi@f1030000";
                break;
        case QSPI_MODE_32BIT:
                puts("QSPI_MODE_32\n");
-               if (uclass_get_device_by_name(UCLASS_SPI,
-                                             "spi@f1030000", &dev)) {
-                       debug("QSPI driver for QSPI device is not present\n");
-                       break;
-               }
-               bootseq = dev_seq(dev);
+               name = "spi@f1030000";
                break;
        case OSPI_MODE:
                puts("OSPI_MODE\n");
-               if (uclass_get_device_by_name(UCLASS_SPI,
-                                             "spi@f1010000", &dev)) {
-                       debug("OSPI driver for OSPI device is not present\n");
-                       break;
-               }
-               bootseq = dev_seq(dev);
+               name = "spi@f1010000";
                break;
        default:
-               break;
+               return -1;
        }
 
+       if (uclass_get_device_by_name(UCLASS_SPI, name, &dev)) {
+               debug("SPI driver for %s is not present\n", name);
+               return -1;
+       }
+
+       bootseq = dev_seq(dev);
        debug("bootseq %d\n", bootseq);
+
        return bootseq;
 }