diff mbox series

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

Message ID 20220301095640.313852-2-tudor.ambarus@microchip.com (mailing list archive)
State New, archived
Headers show
Series mtd: spi-nor: Fix Quad Enable method for MX25L12835F | expand

Commit Message

Tudor Ambarus March 1, 2022, 9:56 a.m. UTC
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@microchip.com>
---
 drivers/mtd/spi-nor/macronix.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Tudor Ambarus March 1, 2022, 11:16 a.m. UTC | #1
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@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 = {
diff mbox series

Patch

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;
 }
 
 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 = {