]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: spi: Use CONFIG_IS_ENABLED to prevent ifdef
authorJagan Teki <jagan@amarulasolutions.com>
Tue, 12 May 2020 18:41:27 +0000 (00:11 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 1 Jun 2020 12:25:24 +0000 (17:55 +0530)
Use CONFIG_IS_ENABLED to prevent ifdef in sf_probe.c

Cc: Simon Glass <sjg@chromium.org>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/sf_probe.c

index ce0cf4c428b1ea61e9323d16e6d871a89cd72b54..3bcb7a22df3996248369684f40aa332545abfae0 100644 (file)
@@ -82,5 +82,15 @@ int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash);
 #if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
 int spi_flash_mtd_register(struct spi_flash *flash);
 void spi_flash_mtd_unregister(void);
+#else
+static inline int spi_flash_mtd_register(struct spi_flash *flash)
+{
+       return 0;
+}
+
+static inline void spi_flash_mtd_unregister(void)
+{
+}
 #endif
+
 #endif /* _SF_INTERNAL_H_ */
index c2e51f9c68dfb77e972b24c2d7d4ec005a1475b0..ee7cbaf3f60f8631e6935d094976852fea3002cf 100644 (file)
@@ -45,9 +45,8 @@ static int spi_flash_probe_slave(struct spi_flash *flash)
        if (ret)
                goto err_read_id;
 
-#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
-       ret = spi_flash_mtd_register(flash);
-#endif
+       if (CONFIG_IS_ENABLED(SPI_FLASH_MTD))
+               ret = spi_flash_mtd_register(flash);
 
 err_read_id:
        spi_release_bus(spi);
@@ -84,9 +83,9 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
 
 void spi_flash_free(struct spi_flash *flash)
 {
-#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
-       spi_flash_mtd_unregister();
-#endif
+       if (CONFIG_IS_ENABLED(SPI_FLASH_MTD))
+               spi_flash_mtd_unregister();
+
        spi_free_slave(flash->spi);
        free(flash);
 }
@@ -153,9 +152,9 @@ int spi_flash_std_probe(struct udevice *dev)
 
 static int spi_flash_std_remove(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
-       spi_flash_mtd_unregister();
-#endif
+       if (CONFIG_IS_ENABLED(SPI_FLASH_MTD))
+               spi_flash_mtd_unregister();
+
        return 0;
 }