Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mtd: spi-nor: Fix the disabling of write protection at init
@ 2019-07-31  8:46 Tudor.Ambarus
  2019-08-05  6:40 ` Vignesh Raghavendra
  0 siblings, 1 reply; 2+ messages in thread
From: Tudor.Ambarus @ 2019-07-31  8:46 UTC (permalink / raw)
  To: marek.vasut, vigneshr
  Cc: Tudor.Ambarus, richard, linux-kernel, linux-mtd, miquel.raynal,
	computersforpeace, dwmw2

From: Tudor Ambarus <tudor.ambarus@microchip.com>

spi_nor_spansion_clear_sr_bp() depends on spansion_quad_enable().
While spansion_quad_enable() is selected as default when
initializing the flash parameters, the nor->quad_enable() method
can be overwritten later on when parsing BFPT.

Select the write protection disable mechanism at spi_nor_init() time,
when the nor->quad_enable() method is already known.

Fixes: 191f5c2ed4b6faba ("mtd: spi-nor: use 16-bit WRR command when QE is set on spansion flashes")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 924dbaf3fa49..28a64dbdaea9 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -4357,8 +4357,6 @@ static int spi_nor_init_params(struct spi_nor *nor,
 		default:
 			/* Kept only for backward compatibility purpose. */
 			params->quad_enable = spansion_quad_enable;
-			if (nor->clear_sr_bp)
-				nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
 			break;
 		}
 
@@ -4621,6 +4619,9 @@ static int spi_nor_init(struct spi_nor *nor)
 	int err;
 
 	if (nor->clear_sr_bp) {
+		if (nor->quad_enable == spansion_quad_enable)
+			nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
+
 		err = nor->clear_sr_bp(nor);
 		if (err) {
 			dev_err(nor->dev,
-- 
2.9.5


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: spi-nor: Fix the disabling of write protection at init
  2019-07-31  8:46 [PATCH] mtd: spi-nor: Fix the disabling of write protection at init Tudor.Ambarus
@ 2019-08-05  6:40 ` Vignesh Raghavendra
  0 siblings, 0 replies; 2+ messages in thread
From: Vignesh Raghavendra @ 2019-08-05  6:40 UTC (permalink / raw)
  To: Tudor.Ambarus, marek.vasut
  Cc: richard, linux-kernel, linux-mtd, miquel.raynal,
	computersforpeace, dwmw2



On 31/07/19 2:16 PM, Tudor.Ambarus@microchip.com wrote:
> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> spi_nor_spansion_clear_sr_bp() depends on spansion_quad_enable().
> While spansion_quad_enable() is selected as default when
> initializing the flash parameters, the nor->quad_enable() method
> can be overwritten later on when parsing BFPT.
> 
> Select the write protection disable mechanism at spi_nor_init() time,
> when the nor->quad_enable() method is already known.
> 
> Fixes: 191f5c2ed4b6faba ("mtd: spi-nor: use 16-bit WRR command when QE is set on spansion flashes")
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>

Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>

> ---
>  drivers/mtd/spi-nor/spi-nor.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 924dbaf3fa49..28a64dbdaea9 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -4357,8 +4357,6 @@ static int spi_nor_init_params(struct spi_nor *nor,
>  		default:
>  			/* Kept only for backward compatibility purpose. */
>  			params->quad_enable = spansion_quad_enable;
> -			if (nor->clear_sr_bp)
> -				nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
>  			break;
>  		}
>  
> @@ -4621,6 +4619,9 @@ static int spi_nor_init(struct spi_nor *nor)
>  	int err;
>  
>  	if (nor->clear_sr_bp) {
> +		if (nor->quad_enable == spansion_quad_enable)
> +			nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
> +
>  		err = nor->clear_sr_bp(nor);
>  		if (err) {
>  			dev_err(nor->dev,
> 

-- 
Regards
Vignesh

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31  8:46 [PATCH] mtd: spi-nor: Fix the disabling of write protection at init Tudor.Ambarus
2019-08-05  6:40 ` Vignesh Raghavendra

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox