All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spinand: Fix Macronix ECC Status Read
@ 2018-12-20 12:46 Emil Lenngren
  2018-12-20 13:03 ` Boris Brezillon
  0 siblings, 1 reply; 3+ messages in thread
From: Emil Lenngren @ 2018-12-20 12:46 UTC (permalink / raw)
  To: linux-mtd; +Cc: Emil Lenngren

The datasheet specifies the upper four bits are reserved.
Testing on real hardware shows that these bits can indeed be nonzero.

Signed-off-by: Emil Lenngren <emil.lenngren@gmail.com>
---
 drivers/mtd/nand/spi/macronix.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 98f6b9c4b6..d16b57081c 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -10,6 +10,7 @@
 #include <linux/mtd/spinand.h>
 
 #define SPINAND_MFR_MACRONIX		0xC2
+#define MACRONIX_ECCSR_MASK		0x0F
 
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
@@ -55,7 +56,12 @@ static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
 					  SPI_MEM_OP_DUMMY(1, 1),
 					  SPI_MEM_OP_DATA_IN(1, eccsr, 1));
 
-	return spi_mem_exec_op(spinand->spimem, &op);
+	int ret = spi_mem_exec_op(spinand->spimem, &op);
+	if (ret)
+		return ret;
+
+	*eccsr &= MACRONIX_ECCSR_MASK;
+	return 0;
 }
 
 static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
-- 
2.17.1

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

* Re: [PATCH] mtd: spinand: Fix Macronix ECC Status Read
  2018-12-20 12:46 [PATCH] mtd: spinand: Fix Macronix ECC Status Read Emil Lenngren
@ 2018-12-20 13:03 ` Boris Brezillon
  2018-12-20 13:20   ` Emil Lenngren
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2018-12-20 13:03 UTC (permalink / raw)
  To: Emil Lenngren; +Cc: linux-mtd, Miquel Raynal

+Miquel

Hi Emil,

Can you please Cc the NAND and MTD maintainers next time?

On Thu, 20 Dec 2018 13:46:58 +0100
Emil Lenngren <emil.lenngren@gmail.com> wrote:

> The datasheet specifies the upper four bits are reserved.
> Testing on real hardware shows that these bits can indeed be nonzero.
> 
> Signed-off-by: Emil Lenngren <emil.lenngren@gmail.com>

Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>

> ---
>  drivers/mtd/nand/spi/macronix.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index 98f6b9c4b6..d16b57081c 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -10,6 +10,7 @@
>  #include <linux/mtd/spinand.h>
>  
>  #define SPINAND_MFR_MACRONIX		0xC2
> +#define MACRONIX_ECCSR_MASK		0x0F
>  
>  static SPINAND_OP_VARIANTS(read_cache_variants,
>  		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> @@ -55,7 +56,12 @@ static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
>  					  SPI_MEM_OP_DUMMY(1, 1),
>  					  SPI_MEM_OP_DATA_IN(1, eccsr, 1));
>  
> -	return spi_mem_exec_op(spinand->spimem, &op);
> +	int ret = spi_mem_exec_op(spinand->spimem, &op);
> +	if (ret)
> +		return ret;
> +
> +	*eccsr &= MACRONIX_ECCSR_MASK;
> +	return 0;
>  }
>  
>  static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,

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

* Re: [PATCH] mtd: spinand: Fix Macronix ECC Status Read
  2018-12-20 13:03 ` Boris Brezillon
@ 2018-12-20 13:20   ` Emil Lenngren
  0 siblings, 0 replies; 3+ messages in thread
From: Emil Lenngren @ 2018-12-20 13:20 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: linux-mtd, Miquel Raynal

Den tors 20 dec. 2018 kl 14:03 skrev Boris Brezillon <bbrezillon@kernel.org>:
>
> +Miquel
>
> Hi Emil,
>
> Can you please Cc the NAND and MTD maintainers next time?

Sure!

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

end of thread, other threads:[~2018-12-20 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 12:46 [PATCH] mtd: spinand: Fix Macronix ECC Status Read Emil Lenngren
2018-12-20 13:03 ` Boris Brezillon
2018-12-20 13:20   ` Emil Lenngren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.