[PATCH v4 05/28] mtd: spi-nor: Init flags before manufacturer late_init() hooks
Miquel Raynal <[email protected]> Tue, 04 Aug 2026 16:04:27 +0200
| Newsgroups | gmane.linux.kernel,gmane.linux.drivers.mtd |
|---|---|
| Message-ID | <20260804-winbond-v7-1-spi-nor-jv-cleanup-v4-5-ee3445066e4e@bootlin.com> |
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 <[email protected]> --- 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 b4d09f14fff7..fef7f426a3a2 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