Skip to content

Commit

Permalink
mtd: spinand: use the spi-mem poll status APIs
Browse files Browse the repository at this point in the history
Make use of spi-mem poll status APIs to let advanced controllers
optimize wait operations.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
  • Loading branch information
Patrice Chotard authored and intel-lab-lkp committed May 7, 2021
1 parent 1b0bd34 commit b8cd8db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/mtd/nand/spi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,19 @@ static int spinand_erase_op(struct spinand_device *spinand,

static int spinand_wait(struct spinand_device *spinand, u8 *s)
{
unsigned long timeo = jiffies + msecs_to_jiffies(400);
struct spi_mem_op op = SPINAND_GET_FEATURE_OP(REG_STATUS,
spinand->scratchbuf);
u8 status;
int ret;

do {
ret = spinand_read_status(spinand, &status);
if (ret)
return ret;
ret = spi_mem_poll_status(spinand->spimem, &op, STATUS_BUSY, 0,
SPINAND_STATUS_TIMEOUT_MS);
if (ret)
return ret;

if (!(status & STATUS_BUSY))
goto out;
} while (time_before(jiffies, timeo));
status = *spinand->scratchbuf;
if (!(status & STATUS_BUSY))
goto out;

/*
* Extra read, just in case the STATUS_READY bit has changed
Expand Down
1 change: 1 addition & 0 deletions include/linux/mtd/spinand.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct spinand_op;
struct spinand_device;

#define SPINAND_MAX_ID_LEN 4
#define SPINAND_STATUS_TIMEOUT_MS 400

/**
* struct spinand_id - SPI NAND id structure
Expand Down

0 comments on commit b8cd8db

Please sign in to comment.