Skip to content

Commit

Permalink
mtd: spi-nor: core: Update flash's current address mode when changing…
Browse files Browse the repository at this point in the history
… address mode

commit 37513c5 upstream.

The bug was obswerved while reading code. There are not many users of
addr_mode_nbytes. Anyway, we should update the flash's current address
mode when changing the address mode, fix it. We don't care for now about
the set_4byte_addr_mode(nor, false) from spi_nor_restore(), as it is
used at driver remove and shutdown.

Fixes: d7931a2 ("mtd: spi-nor: core: Track flash's internal address mode")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230331074606.3559258-9-tudor.ambarus@linaro.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
ambarus authored and gregkh committed May 11, 2023
1 parent dd6c85f commit defee9b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/mtd/spi-nor/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,7 @@ static int spi_nor_quad_enable(struct spi_nor *nor)

static int spi_nor_init(struct spi_nor *nor)
{
struct spi_nor_flash_parameter *params = nor->params;
int err;

err = spi_nor_octal_dtr_enable(nor, true);
Expand Down Expand Up @@ -2773,9 +2774,10 @@ static int spi_nor_init(struct spi_nor *nor)
*/
WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET,
"enabling reset hack; may not recover from unexpected reboots\n");
err = nor->params->set_4byte_addr_mode(nor, true);
err = params->set_4byte_addr_mode(nor, true);
if (err && err != -ENOTSUPP)
return err;
params->addr_mode_nbytes = 4;
}

return 0;
Expand Down

0 comments on commit defee9b

Please sign in to comment.