From: Michal Simek Date: Tue, 23 Jun 2026 12:53:40 +0000 (+0200) Subject: arm64: versal-net: Simplify spi_get_bootseq() bootmode switch X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9938274747cafa24af47d404e78001396f7fdf0;p=thirdparty%2Fu-boot.git arm64: versal-net: Simplify spi_get_bootseq() bootmode switch 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 Link: https://patch.msgid.link/191f0f583e2d02c184ea2a2a2fe0ef473ca9fe61.1782219202.git.michal.simek@amd.com --- diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c index 5ad8c8d6426..50dd49927be 100644 --- a/board/xilinx/versal-net/board.c +++ b/board/xilinx/versal-net/board.c @@ -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; }