Commit b94ed087 authored by Brian Norris's avatar Brian Norris

mtd: spi-nor: drop replaceable wait-till-ready function pointer

We don't need to expose a 'wait-till-ready' interface to drivers. Status
register polling should be handled by the core spi-nor.c library, and as
of now, I see no need to provide a special driver-specific hook for it.
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Reviewed-by: default avatarMarek Vasut <marex@denx.de>
parent 8fdc6cd4
...@@ -195,6 +195,10 @@ static int spi_nor_ready(struct spi_nor *nor) ...@@ -195,6 +195,10 @@ static int spi_nor_ready(struct spi_nor *nor)
return sr && fsr; return sr && fsr;
} }
/*
* Service routine to read status register until ready, or timeout occurs.
* Returns non-zero if error.
*/
static int spi_nor_wait_till_ready(struct spi_nor *nor) static int spi_nor_wait_till_ready(struct spi_nor *nor)
{ {
unsigned long deadline; unsigned long deadline;
...@@ -215,15 +219,6 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor) ...@@ -215,15 +219,6 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
/*
* Service routine to read status register until ready, or timeout occurs.
* Returns non-zero if error.
*/
static int wait_till_ready(struct spi_nor *nor)
{
return nor->wait_till_ready(nor);
}
/* /*
* Erase the whole flash memory * Erase the whole flash memory
* *
...@@ -708,7 +703,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -708,7 +703,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
/* write one byte. */ /* write one byte. */
nor->write(nor, to, 1, retlen, buf); nor->write(nor, to, 1, retlen, buf);
ret = wait_till_ready(nor); ret = spi_nor_wait_till_ready(nor);
if (ret) if (ret)
goto time_out; goto time_out;
} }
...@@ -720,7 +715,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -720,7 +715,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
/* write two bytes. */ /* write two bytes. */
nor->write(nor, to, 2, retlen, buf + actual); nor->write(nor, to, 2, retlen, buf + actual);
ret = wait_till_ready(nor); ret = spi_nor_wait_till_ready(nor);
if (ret) if (ret)
goto time_out; goto time_out;
to += 2; to += 2;
...@@ -729,7 +724,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -729,7 +724,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
nor->sst_write_second = false; nor->sst_write_second = false;
write_disable(nor); write_disable(nor);
ret = wait_till_ready(nor); ret = spi_nor_wait_till_ready(nor);
if (ret) if (ret)
goto time_out; goto time_out;
...@@ -740,7 +735,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -740,7 +735,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
nor->program_opcode = SPINOR_OP_BP; nor->program_opcode = SPINOR_OP_BP;
nor->write(nor, to, 1, retlen, buf + actual); nor->write(nor, to, 1, retlen, buf + actual);
ret = wait_till_ready(nor); ret = spi_nor_wait_till_ready(nor);
if (ret) if (ret)
goto time_out; goto time_out;
write_disable(nor); write_disable(nor);
...@@ -786,7 +781,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -786,7 +781,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
if (page_size > nor->page_size) if (page_size > nor->page_size)
page_size = nor->page_size; page_size = nor->page_size;
ret = wait_till_ready(nor); ret = spi_nor_wait_till_ready(nor);
if (ret) if (ret)
goto write_err; goto write_err;
...@@ -812,7 +807,7 @@ static int macronix_quad_enable(struct spi_nor *nor) ...@@ -812,7 +807,7 @@ static int macronix_quad_enable(struct spi_nor *nor)
nor->cmd_buf[0] = val | SR_QUAD_EN_MX; nor->cmd_buf[0] = val | SR_QUAD_EN_MX;
nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0); nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0);
if (wait_till_ready(nor)) if (spi_nor_wait_till_ready(nor))
return 1; return 1;
ret = read_sr(nor); ret = read_sr(nor);
...@@ -892,9 +887,6 @@ static int spi_nor_check(struct spi_nor *nor) ...@@ -892,9 +887,6 @@ static int spi_nor_check(struct spi_nor *nor)
return -EINVAL; return -EINVAL;
} }
if (!nor->wait_till_ready)
nor->wait_till_ready = spi_nor_wait_till_ready;
return 0; return 0;
} }
......
...@@ -144,7 +144,6 @@ enum spi_nor_option_flags { ...@@ -144,7 +144,6 @@ enum spi_nor_option_flags {
* @write_xfer: [OPTIONAL] the writefundamental primitive * @write_xfer: [OPTIONAL] the writefundamental primitive
* @read_reg: [DRIVER-SPECIFIC] read out the register * @read_reg: [DRIVER-SPECIFIC] read out the register
* @write_reg: [DRIVER-SPECIFIC] write data to the register * @write_reg: [DRIVER-SPECIFIC] write data to the register
* @wait_till_ready: [REPLACEABLE] wait till the NOR becomes ready
* @read: [DRIVER-SPECIFIC] read data from the SPI NOR * @read: [DRIVER-SPECIFIC] read data from the SPI NOR
* @write: [DRIVER-SPECIFIC] write data to the SPI NOR * @write: [DRIVER-SPECIFIC] write data to the SPI NOR
* @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR
...@@ -176,7 +175,6 @@ struct spi_nor { ...@@ -176,7 +175,6 @@ struct spi_nor {
int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len); int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len, int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
int write_enable); int write_enable);
int (*wait_till_ready)(struct spi_nor *nor);
int (*read)(struct spi_nor *nor, loff_t from, int (*read)(struct spi_nor *nor, loff_t from,
size_t len, size_t *retlen, u_char *read_buf); size_t len, size_t *retlen, u_char *read_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment