[PATCH 2/3] mtd: nand: make exec_op optional

Sascha Hauer s.hauer at pengutronix.de
Fri Jun 14 06:36:02 PDT 2024


While exec_op is the way to go for new drivers, not all drivers use it
yet. Make support for it optional to safe a few bytes of binary space
when only drivers without exec_op are compiled in.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/nand/raw/Kconfig     | 7 +++++++
 drivers/mtd/nand/raw/internals.h | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index a48670b190..e9d1b83706 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -32,12 +32,16 @@ config NAND_ALLOW_ERASE_BAD
 	  to '1' it will be allowed to erase bad blocks. This is a potientially
 	  dangerous operation, so if unsure say no to this option.
 
+config NAND_NEED_EXEC_OP
+	bool
+
 comment "Raw/parallel NAND flash controllers"
 
 config NAND_IMX
 	bool
 	prompt "i.MX21 to 53 NAND driver aka 'mxc', for NFC"
 	depends on ARCH_IMX
+	select NAND_NEED_EXEC_OP
 	help
 	  Support for NAND flash on Freescale/NXP i.MX devices.  This is for the
 	  "MXC" series:  i.MX21/25/27/31/35/51/53.
@@ -104,6 +108,7 @@ config NAND_STM32
 	select STM32_FMC2_EBI if ARCH_STM32MP
 	select RESET_CONTROLLER if ARCH_STM32MP
 	select RESET_SIMPLE if ARCH_STM32MP
+	select NAND_NEED_EXEC_OP
 	help
 	  Enables support for NAND Flash chips on SoCs containing the FMC2
 	  NAND controller. This controller is found on STM32MP SoCs.
@@ -114,6 +119,7 @@ config NAND_ATMEL
 	bool
 	prompt "Atmel (AT91SAM9xxx) NAND driver"
 	select GENERIC_ALLOCATOR if OFDEVICE
+	select NAND_NEED_EXEC_OP
 	depends on ARCH_AT91 || (OFDEVICE && COMPILE_TEST)
 
 config NAND_ATMEL_LEGACY
@@ -149,6 +155,7 @@ config MTD_NAND_NOMADIK
 config MTD_NAND_DENALI
 	tristate "Support Denali NAND controller"
 	depends on HAS_DMA
+	select NAND_NEED_EXEC_OP
 	help
 	  Enable support for the Denali NAND controller.  This should be
 	  combined with either the PCI or platform drivers to provide device
diff --git a/drivers/mtd/nand/raw/internals.h b/drivers/mtd/nand/raw/internals.h
index 6dab25ecab..191244801b 100644
--- a/drivers/mtd/nand/raw/internals.h
+++ b/drivers/mtd/nand/raw/internals.h
@@ -118,6 +118,11 @@ static inline bool nand_has_exec_op(struct nand_chip *chip)
 	    !chip->controller->ops->exec_op)
 		return false;
 
+	if (!IS_ENABLED(CONFIG_NAND_NEED_EXEC_OP)) {
+		pr_err("driver needs exec_op, but CONFIG_NAND_NEED_EXEC_OP is disabled\n");
+		return false;
+	}
+
 	return true;
 }
 
-- 
2.39.2




More information about the barebox mailing list