[PATCH v3 04/27] mtd: spi-nor: Init flags before manufacturer late_init() hooks
From: Miquel Raynal
Date: Tue Aug 04 2026 - 07:07:05 EST
Current init order is:
- The manufacturer-wide late_init() hook is called.
- The core initializes some chip flags
- The chip specific late_init() hook is called.
This does not seem very consistent since both late_init() may need to
touch flags, which is then not working as expected since the order is a
bit inconsistent. Moving spi_nor_init_flags() earlier, right before the
manufacturer late_init() call, ensures the hook sees the flags after
their initialization, and can therefore apply changes to them.
Since spi_nor_init_flags() only reads ->info->flags and DT properties,
it does not depend on anything a late_init() hook produces. On the other
hand, no manufacturer late_init() hook currently touches any output of
spi_nor_init_flags() either. Reordering seems safe™.
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/mtd/spi-nor/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0c8630a54985..53d9a484e434 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3014,6 +3014,9 @@ static int spi_nor_late_init_params(struct spi_nor *nor)
struct spi_nor_flash_parameter *params = nor->params;
int ret;
+ /* Needed by some late_init hooks */
+ spi_nor_init_flags(nor);
+
if (nor->manufacturer && nor->manufacturer->fixups &&
nor->manufacturer->fixups->late_init) {
ret = nor->manufacturer->fixups->late_init(nor);
@@ -3021,9 +3024,6 @@ static int spi_nor_late_init_params(struct spi_nor *nor)
return ret;
}
- /* Needed by some flashes late_init hooks. */
- spi_nor_init_flags(nor);
-
if (nor->info->fixups && nor->info->fixups->late_init) {
ret = nor->info->fixups->late_init(nor);
if (ret)
--
2.54.0