Skip to contentSkip to conversation

mtd: spi: Use CONFIG_IS_ENABLED to prevent ifdef

PATCH New Jagan Teki 1 participant 2 messages May 14, 2020 – May 19, 2020 Memory technology devices (MTD)

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH v2 5/5 mtd: spi: Use CONFIG_IS_ENABLED to prevent ifdef

Use CONFIG_IS_ENABLED to prevent ifdef in sf_probe.c

Cc Simon Glass <[email protected]>
Cc Vignesh R <[email protected]>
Cc Daniel Schwierzeck <[email protected]>

---
Changes for v2:
- CONFIG_IS_ENABLED() instead of IS_ENABLED()

 drivers/mtd/spi/sf_internal.h | 10 ++++++++++
 drivers/mtd/spi/sf_probe.c    | 17 ++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/mtd/spi/sf_internal.h +10 -0
index 940b2e4c9e..544ed74a5f 100644
@@ -81,5 +81,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_ */
drivers/mtd/spi/sf_probe.c +8 -9
index 89e384901c..a73f521777 100644
@@ -44,9 +44,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);
@@ -83,9 +82,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);
 }
@@ -150,9 +149,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;
 }
 
Signature · 1 line
2.20.1