diff mbox series

[RFC,09/34] mtd: spi-nor: Add a flag to skip spi_nor_setup()

Message ID 20181207092637.18687-10-boris.brezillon@bootlin.com
State Superseded
Delegated to: Ambarus Tudor
Headers show
Series mtd: spi-nor: Move manufacturer/SFDP code out of the core | expand

Commit Message

Boris Brezillon Dec. 7, 2018, 9:26 a.m. UTC
Some manufacturers select the opcode to use in their fixups()
method, and they don't want the generic selection logic to override
their values. Add a flag to allow that.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 7 +++++++
 include/linux/mtd/spi-nor.h   | 1 +
 2 files changed, 8 insertions(+)

Comments

Raghavendra, Vignesh Dec. 10, 2018, 8:30 a.m. UTC | #1
On 07/12/18 2:56 PM, Boris Brezillon wrote:
> Some manufacturers select the opcode to use in their fixups()
> method, and they don't want the generic selection logic to override
> their values. Add a flag to allow that.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 7 +++++++
>  include/linux/mtd/spi-nor.h   | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index f6b1c9b8079a..30dbddabec74 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -3502,6 +3502,13 @@ static int spi_nor_setup(struct spi_nor *nor,
>  	u32 ignored_mask, shared_mask;
>  	int err;
>  
> +	/*
> +	 * Some manufacturers select the opcode to use in their fixups()
> +	 * method, and explicitly ask to skip the generic selection logic.
> +	 */
> +	if (nor->flags & SNOR_F_SKIP_SETUP)
> +		return 0;
> +

Nit, I would suggest moving above check to the place where
spi_nor_setup() is called in spi_nor_scan(). That way, its easier to
know that setup is skipped when SNOR_F_SKIP_SETUP is set when reading
spi_nor_scan() code. I am fine otherwise too.

>  	/*
>  	 * Keep only the hardware capabilities supported by both the SPI
>  	 * controller and the SPI flash memory.
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index 2c8fbd5d614d..8c64f1dcd35e 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -235,6 +235,7 @@ enum spi_nor_option_flags {
>  	SNOR_F_4B_OPCODES	= BIT(6),
>  	SNOR_F_HAS_LOCK		= BIT(7),
>  	SNOR_F_CLR_SW_PROT_BITS	= BIT(8),
> +	SNOR_F_SKIP_SETUP	= BIT(9),
>  };
>  
>  /**
>
Boris Brezillon Dec. 10, 2018, 8:37 a.m. UTC | #2
On Mon, 10 Dec 2018 14:00:59 +0530
Vignesh R <vigneshr@ti.com> wrote:

> On 07/12/18 2:56 PM, Boris Brezillon wrote:
> > Some manufacturers select the opcode to use in their fixups()
> > method, and they don't want the generic selection logic to override
> > their values. Add a flag to allow that.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> >  drivers/mtd/spi-nor/spi-nor.c | 7 +++++++
> >  include/linux/mtd/spi-nor.h   | 1 +
> >  2 files changed, 8 insertions(+)
> > 
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index f6b1c9b8079a..30dbddabec74 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -3502,6 +3502,13 @@ static int spi_nor_setup(struct spi_nor *nor,
> >  	u32 ignored_mask, shared_mask;
> >  	int err;
> >  
> > +	/*
> > +	 * Some manufacturers select the opcode to use in their fixups()
> > +	 * method, and explicitly ask to skip the generic selection logic.
> > +	 */
> > +	if (nor->flags & SNOR_F_SKIP_SETUP)
> > +		return 0;
> > +  
> 
> Nit, I would suggest moving above check to the place where
> spi_nor_setup() is called in spi_nor_scan(). That way, its easier to
> know that setup is skipped when SNOR_F_SKIP_SETUP is set when reading
> spi_nor_scan() code.

I agree. Will change that in v2.
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index f6b1c9b8079a..30dbddabec74 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -3502,6 +3502,13 @@  static int spi_nor_setup(struct spi_nor *nor,
 	u32 ignored_mask, shared_mask;
 	int err;
 
+	/*
+	 * Some manufacturers select the opcode to use in their fixups()
+	 * method, and explicitly ask to skip the generic selection logic.
+	 */
+	if (nor->flags & SNOR_F_SKIP_SETUP)
+		return 0;
+
 	/*
 	 * Keep only the hardware capabilities supported by both the SPI
 	 * controller and the SPI flash memory.
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 2c8fbd5d614d..8c64f1dcd35e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -235,6 +235,7 @@  enum spi_nor_option_flags {
 	SNOR_F_4B_OPCODES	= BIT(6),
 	SNOR_F_HAS_LOCK		= BIT(7),
 	SNOR_F_CLR_SW_PROT_BITS	= BIT(8),
+	SNOR_F_SKIP_SETUP	= BIT(9),
 };
 
 /**