[PATCH 01/12] mtd: Remove #ifdef guards for PM related functions

From: Paul Cercueil

Date: Thu Nov 05 2026 - 12:23:47 EST


Use the new PM macros for the suspend and resume functions to be
automatically dropped by the compiler when CONFIG_PM or
CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
---
drivers/mtd/mtdcore.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 82b1e6392b16..037fe292867b 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -40,8 +40,6 @@

struct backing_dev_info *mtd_bdi;

-#ifdef CONFIG_PM_SLEEP
-
static int mtd_cls_suspend(struct device *dev)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
@@ -58,15 +56,11 @@ static int mtd_cls_resume(struct device *dev)
return 0;
}

-static SIMPLE_DEV_PM_OPS(mtd_cls_pm_ops, mtd_cls_suspend, mtd_cls_resume);
-#define MTD_CLS_PM_OPS (&mtd_cls_pm_ops)
-#else
-#define MTD_CLS_PM_OPS NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(mtd_cls_pm_ops, mtd_cls_suspend, mtd_cls_resume);

static struct class mtd_class = {
.name = "mtd",
- .pm = MTD_CLS_PM_OPS,
+ .pm = pm_sleep_ptr(&mtd_cls_pm_ops),
};

static DEFINE_IDR(mtd_idr);
--
2.47.3