]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: add DM_SPI_FLASH compatibility inline functions
authorNeil Armstrong <neil.armstrong@linaro.org>
Tue, 1 Oct 2024 16:06:11 +0000 (18:06 +0200)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 24 Oct 2024 07:41:52 +0000 (09:41 +0200)
To smoothly handle the transition from the legacy SPI FLASH
API to the driver model API, add the DM functions
as dummy inline functions.

Today, client code uses #if/#else conditionals, but it's better
to use if(IS_ENABLED()) to make sure all code builds fine
and avoid configuration hell, leaving the compiler remove
the dead code.

An example is cmd/sf, which could make use of those dummy
functions to drop the conditional compilation.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20241001-uboot-topic-dfu-sf-dt-v2-1-67f7acfa3ff5@linaro.org
[mkorpershoek: removed duplicate "the" from commit msg]
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
include/spi_flash.h

index 10d19fd4b1178d2a5c1f8e0b8deb73368125da5e..2e703e85250d437e2ba9e21415c3bd1b6eb335e8 100644 (file)
@@ -139,6 +139,40 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
 void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs);
 
 #else
+/* Compatibility functions for when DM_SPI_FLASH is disabled */
+static inline int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
+                                        struct udevice **devp)
+{
+       return -ENODEV;
+}
+
+static inline int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len,
+                                   void *buf)
+{
+       return -ENODEV;
+}
+
+static inline int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
+                                    const void *buf)
+{
+       return -ENODEV;
+}
+
+static inline int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
+{
+       return -ENODEV;
+}
+
+static inline int spl_flash_get_sw_write_prot(struct udevice *dev)
+{
+       return -ENODEV;
+}
+
+static inline int spi_flash_std_probe(struct udevice *dev)
+{
+       return -ENODEV;
+}
+
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
                unsigned int max_hz, unsigned int spi_mode);