stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set
@ 2022-03-08  9:11 Tudor Ambarus
  2022-04-01 20:05 ` Pratyush Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: Tudor Ambarus @ 2022-03-08  9:11 UTC (permalink / raw)
  To: p.yadav, michael
  Cc: miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel,
	Tudor Ambarus, stable

Even if SPI_NOR_NO_ERASE was specified at flash declaration, the erase
type of size nor->info->sector_size was incorrectly set as supported.
Don't set erase types when SPI_NOR_NO_ERASE is set.

Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Cc: stable@vger.kernel.org
---
v2:
- add comment, update commit message, split change in individual commit
- add fixes tag and cc to stable.

 drivers/mtd/spi-nor/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index b4f141ad9c9c..64cf7b9df621 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor)
 					SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR);
 	}
 
+	/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */
+	if (nor->info->flags & SPI_NOR_NO_ERASE)
+		return;
+
 	/*
 	 * Sector Erase settings. Sort Erase Types in ascending order, with the
 	 * smallest erase size starting at BIT(0).
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set
  2022-03-08  9:11 [PATCH v2] mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set Tudor Ambarus
@ 2022-04-01 20:05 ` Pratyush Yadav
  2022-04-29  6:14   ` Pratyush Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: Pratyush Yadav @ 2022-04-01 20:05 UTC (permalink / raw)
  To: Tudor Ambarus
  Cc: michael, miquel.raynal, richard, vigneshr, linux-mtd,
	linux-kernel, stable

On 08/03/22 11:11AM, Tudor Ambarus wrote:
> Even if SPI_NOR_NO_ERASE was specified at flash declaration, the erase
> type of size nor->info->sector_size was incorrectly set as supported.
> Don't set erase types when SPI_NOR_NO_ERASE is set.

Does this have any practical implications? Since we set MTD_NO_ERASE, 
erase should never be called for this flash anyway, right?

> 
> Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> Cc: stable@vger.kernel.org
> ---
> v2:
> - add comment, update commit message, split change in individual commit
> - add fixes tag and cc to stable.
> 
>  drivers/mtd/spi-nor/core.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index b4f141ad9c9c..64cf7b9df621 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor)
>  					SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR);
>  	}
>  
> +	/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */
> +	if (nor->info->flags & SPI_NOR_NO_ERASE)
> +		return;
> +
>  	/*
>  	 * Sector Erase settings. Sort Erase Types in ascending order, with the
>  	 * smallest erase size starting at BIT(0).
> -- 
> 2.25.1
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set
  2022-04-01 20:05 ` Pratyush Yadav
@ 2022-04-29  6:14   ` Pratyush Yadav
  0 siblings, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2022-04-29  6:14 UTC (permalink / raw)
  To: Tudor Ambarus
  Cc: michael, miquel.raynal, richard, vigneshr, linux-mtd,
	linux-kernel, stable

On 02/04/22 01:35AM, Pratyush Yadav wrote:
> On 08/03/22 11:11AM, Tudor Ambarus wrote:
> > Even if SPI_NOR_NO_ERASE was specified at flash declaration, the erase
> > type of size nor->info->sector_size was incorrectly set as supported.
> > Don't set erase types when SPI_NOR_NO_ERASE is set.
> 
> Does this have any practical implications? Since we set MTD_NO_ERASE, 
> erase should never be called for this flash anyway, right?
> 
> > 
> > Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
> > Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> > Cc: stable@vger.kernel.org
> > ---
> > v2:
> > - add comment, update commit message, split change in individual commit
> > - add fixes tag and cc to stable.
> > 
> >  drivers/mtd/spi-nor/core.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> > index b4f141ad9c9c..64cf7b9df621 100644
> > --- a/drivers/mtd/spi-nor/core.c
> > +++ b/drivers/mtd/spi-nor/core.c
> > @@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor)
> >  					SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR);
> >  	}
> >  
> > +	/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */
> > +	if (nor->info->flags & SPI_NOR_NO_ERASE)
> > +		return;

Can you instead do

	if (!(nor->info->flags & SPI_NOR_NO_ERASE)) {
		...
	}

This way when someone adds code to the bottom of this function that sets 
something other than erase types it will execute for flashes with 
SPI_NOR_NO_ERASE as well.

> > +
> >  	/*
> >  	 * Sector Erase settings. Sort Erase Types in ascending order, with the
> >  	 * smallest erase size starting at BIT(0).
> > -- 
> > 2.25.1
> > 
> 
> -- 
> Regards,
> Pratyush Yadav
> Texas Instruments Inc.
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-29  6:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08  9:11 [PATCH v2] mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set Tudor Ambarus
2022-04-01 20:05 ` Pratyush Yadav
2022-04-29  6:14   ` Pratyush Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).