[PATCH 1/2] mtd: spi-nor: macronix: Move set_4byte_addr_mode() to late_init()

Tudor.Ambarus at microchip.com Tudor.Ambarus at microchip.com
Tue Mar 1 03:16:20 PST 2022


On 3/1/22 11:56, Tudor Ambarus wrote:
> We'd like to get rid of the default_init() hooks to remove the spaghetti
> way of initializing the flash. set_4byte_addr_mode() is called after
> late_init(), it's safe to move where this method is set.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
> ---
>  drivers/mtd/spi-nor/macronix.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> index 45c2f2c50e56..3d0e34c9410c 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -147,11 +147,16 @@ static const struct flash_info macronix_nor_parts[] = {
>  static void macronix_nor_default_init(struct spi_nor *nor)
>  {
>  	nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
> +}
> +
> +static void macronix_nor_late_init(struct spi_nor *nor)
> +{
>  	nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode;
>  }

Meh, NACK. Actually the entering in 4 byte mode can be retrieved from BFPT[DWORD(16)].
So when flashes define BFPT we should retrieve the method from there. When they can't
we can add late_init hooks punctually for each flash, but not globally, per manufacturer.
So setting of set_4byte_addr_mode method will reside in the post_bfpt hook in your case
because the flash defines BFPT, but in an incomplete way. But this won't change the
behavior, no need to test again Heiko.

I'll clean the entire default_init() thingy and the setting of set_4byte_addr_mode
method in a patch set, probably tomorrow. Until then others that are interested can
review the other patches from [PATCH v4 0/6] mtd: spi-nor: Handle ID collisions.

Thanks again, Heiko.
Cheers,
ta

>  
>  static const struct spi_nor_fixups macronix_nor_fixups = {
>  	.default_init = macronix_nor_default_init,
> +	.late_init = macronix_nor_late_init,
>  };
>  
>  const struct spi_nor_manufacturer spi_nor_macronix = {



More information about the linux-mtd mailing list