[RFC PATCH v2 02/13] mtd: mtdswap: Initialise mtdswap_ops with a page size variable
From: Eric Curtin
Date: Tue Dec 01 2026 - 22:18:01 EST
From: Eric Curtin <eric.curtin@xxxxxxxxxx>
With arm64 boot-time page size selection PAGE_SIZE is not a
compile-time constant, so it cannot be used in the static initialiser
of mtdswap_ops, whose .blksize is PAGE_SIZE.
Define the structure with DEFINE_GLOBAL_PAGE_SIZE_VAR(), which
initialises it at boot when the page size is not fixed and is an
ordinary static initialiser otherwise.
No functional change for compile-time page sizes.
Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
drivers/mtd/mtdswap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index 7b20e49d5a25..469902a4d397 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1472,7 +1472,7 @@ static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev)
kfree(d);
}
-static struct mtd_blktrans_ops mtdswap_ops = {
+static DEFINE_GLOBAL_PAGE_SIZE_VAR(struct mtd_blktrans_ops, mtdswap_ops, {
.name = "mtdswap",
.major = 0,
.part_bits = 0,
@@ -1485,7 +1485,7 @@ static struct mtd_blktrans_ops mtdswap_ops = {
.add_mtd = mtdswap_add_mtd,
.remove_dev = mtdswap_remove_dev,
.owner = THIS_MODULE,
-};
+});
module_mtd_blktrans(mtdswap_ops);