Re: [PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-11-02 Thread Boris Brezillon
On Mon, 30 Oct 2017 22:32:45 -0500
moto...@gmail.com wrote:

> From: Brent Taylor 
> 
> When mtdoops calls mtd_panic_write, it eventually calls
> panic_nand_write in nand_base.c.  In order to properly
> wait for the nand chip to be ready in panic_nand_wait,
> the chip must first be selected.
> 
> When using the atmel nand flash controller, a panic
> would occur due to a NULL pointer exception.
> 

Applied.

Thanks,

Boris

> Signed-off-by: Brent Taylor 
> ---
> Changes in v2:
>   - drop deselecting the chip
>   - move select_chip and panic_nand_wait after panic_nand_get_device
> 
>  drivers/mtd/nand/nand_base.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 12edaae17d81..2093667e2bcb 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
> loff_t to, size_t len,
>   struct mtd_oob_ops ops;
>   int ret;
>  
> - /* Wait for the device to get ready */
> - panic_nand_wait(mtd, chip, 400);
> + int chipnr = (int)(to >> chip->chip_shift);
>  
>   /* Grab the device */
>   panic_nand_get_device(chip, mtd, FL_WRITING);
>  
> + chip->select_chip(mtd, chipnr);
> +
> + /* Wait for the device to get ready */
> + panic_nand_wait(mtd, chip, 400);
> +
>   memset(, 0, sizeof(ops));
>   ops.len = len;
>   ops.datbuf = (uint8_t *)buf;



Re: [PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-11-02 Thread Boris Brezillon
On Mon, 30 Oct 2017 22:32:45 -0500
moto...@gmail.com wrote:

> From: Brent Taylor 
> 
> When mtdoops calls mtd_panic_write, it eventually calls
> panic_nand_write in nand_base.c.  In order to properly
> wait for the nand chip to be ready in panic_nand_wait,
> the chip must first be selected.
> 
> When using the atmel nand flash controller, a panic
> would occur due to a NULL pointer exception.
> 

Applied.

Thanks,

Boris

> Signed-off-by: Brent Taylor 
> ---
> Changes in v2:
>   - drop deselecting the chip
>   - move select_chip and panic_nand_wait after panic_nand_get_device
> 
>  drivers/mtd/nand/nand_base.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 12edaae17d81..2093667e2bcb 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
> loff_t to, size_t len,
>   struct mtd_oob_ops ops;
>   int ret;
>  
> - /* Wait for the device to get ready */
> - panic_nand_wait(mtd, chip, 400);
> + int chipnr = (int)(to >> chip->chip_shift);
>  
>   /* Grab the device */
>   panic_nand_get_device(chip, mtd, FL_WRITING);
>  
> + chip->select_chip(mtd, chipnr);
> +
> + /* Wait for the device to get ready */
> + panic_nand_wait(mtd, chip, 400);
> +
>   memset(, 0, sizeof(ops));
>   ops.len = len;
>   ops.datbuf = (uint8_t *)buf;



Re: [PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-10-31 Thread Boris Brezillon
On Mon, 30 Oct 2017 22:32:45 -0500
moto...@gmail.com wrote:

> From: Brent Taylor 
> 
> When mtdoops calls mtd_panic_write, it eventually calls
> panic_nand_write in nand_base.c.  In order to properly
> wait for the nand chip to be ready in panic_nand_wait,
> the chip must first be selected.
> 
> When using the atmel nand flash controller, a panic
> would occur due to a NULL pointer exception.
> 
> Signed-off-by: Brent Taylor 

I'll add

Fixes: 2af7c6539931 ("mtd: Add panic_write for NAND flashes")
Cc: 

when applying the patch.

Thanks,

Boris

> ---
> Changes in v2:
>   - drop deselecting the chip
>   - move select_chip and panic_nand_wait after panic_nand_get_device
> 
>  drivers/mtd/nand/nand_base.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 12edaae17d81..2093667e2bcb 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
> loff_t to, size_t len,
>   struct mtd_oob_ops ops;
>   int ret;
>  
> - /* Wait for the device to get ready */
> - panic_nand_wait(mtd, chip, 400);
> + int chipnr = (int)(to >> chip->chip_shift);
>  
>   /* Grab the device */
>   panic_nand_get_device(chip, mtd, FL_WRITING);
>  
> + chip->select_chip(mtd, chipnr);
> +
> + /* Wait for the device to get ready */
> + panic_nand_wait(mtd, chip, 400);
> +
>   memset(, 0, sizeof(ops));
>   ops.len = len;
>   ops.datbuf = (uint8_t *)buf;



Re: [PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-10-31 Thread Boris Brezillon
On Mon, 30 Oct 2017 22:32:45 -0500
moto...@gmail.com wrote:

> From: Brent Taylor 
> 
> When mtdoops calls mtd_panic_write, it eventually calls
> panic_nand_write in nand_base.c.  In order to properly
> wait for the nand chip to be ready in panic_nand_wait,
> the chip must first be selected.
> 
> When using the atmel nand flash controller, a panic
> would occur due to a NULL pointer exception.
> 
> Signed-off-by: Brent Taylor 

I'll add

Fixes: 2af7c6539931 ("mtd: Add panic_write for NAND flashes")
Cc: 

when applying the patch.

Thanks,

Boris

> ---
> Changes in v2:
>   - drop deselecting the chip
>   - move select_chip and panic_nand_wait after panic_nand_get_device
> 
>  drivers/mtd/nand/nand_base.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 12edaae17d81..2093667e2bcb 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
> loff_t to, size_t len,
>   struct mtd_oob_ops ops;
>   int ret;
>  
> - /* Wait for the device to get ready */
> - panic_nand_wait(mtd, chip, 400);
> + int chipnr = (int)(to >> chip->chip_shift);
>  
>   /* Grab the device */
>   panic_nand_get_device(chip, mtd, FL_WRITING);
>  
> + chip->select_chip(mtd, chipnr);
> +
> + /* Wait for the device to get ready */
> + panic_nand_wait(mtd, chip, 400);
> +
>   memset(, 0, sizeof(ops));
>   ops.len = len;
>   ops.datbuf = (uint8_t *)buf;



[PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-10-30 Thread motobud
From: Brent Taylor 

When mtdoops calls mtd_panic_write, it eventually calls
panic_nand_write in nand_base.c.  In order to properly
wait for the nand chip to be ready in panic_nand_wait,
the chip must first be selected.

When using the atmel nand flash controller, a panic
would occur due to a NULL pointer exception.

Signed-off-by: Brent Taylor 
---
Changes in v2:
  - drop deselecting the chip
  - move select_chip and panic_nand_wait after panic_nand_get_device

 drivers/mtd/nand/nand_base.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 12edaae17d81..2093667e2bcb 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
loff_t to, size_t len,
struct mtd_oob_ops ops;
int ret;
 
-   /* Wait for the device to get ready */
-   panic_nand_wait(mtd, chip, 400);
+   int chipnr = (int)(to >> chip->chip_shift);
 
/* Grab the device */
panic_nand_get_device(chip, mtd, FL_WRITING);
 
+   chip->select_chip(mtd, chipnr);
+
+   /* Wait for the device to get ready */
+   panic_nand_wait(mtd, chip, 400);
+
memset(, 0, sizeof(ops));
ops.len = len;
ops.datbuf = (uint8_t *)buf;
-- 
2.14.2



[PATCH v2] mtd: nand: Fix writing mtdoops to nand flash.

2017-10-30 Thread motobud
From: Brent Taylor 

When mtdoops calls mtd_panic_write, it eventually calls
panic_nand_write in nand_base.c.  In order to properly
wait for the nand chip to be ready in panic_nand_wait,
the chip must first be selected.

When using the atmel nand flash controller, a panic
would occur due to a NULL pointer exception.

Signed-off-by: Brent Taylor 
---
Changes in v2:
  - drop deselecting the chip
  - move select_chip and panic_nand_wait after panic_nand_get_device

 drivers/mtd/nand/nand_base.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 12edaae17d81..2093667e2bcb 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, 
loff_t to, size_t len,
struct mtd_oob_ops ops;
int ret;
 
-   /* Wait for the device to get ready */
-   panic_nand_wait(mtd, chip, 400);
+   int chipnr = (int)(to >> chip->chip_shift);
 
/* Grab the device */
panic_nand_get_device(chip, mtd, FL_WRITING);
 
+   chip->select_chip(mtd, chipnr);
+
+   /* Wait for the device to get ready */
+   panic_nand_wait(mtd, chip, 400);
+
memset(, 0, sizeof(ops));
ops.len = len;
ops.datbuf = (uint8_t *)buf;
-- 
2.14.2