diff options
author | Brian Norris <computersforpeace@gmail.com> | 2014-08-06 21:17:00 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-11-05 05:08:21 -0500 |
commit | b94ed087744c5bc287d2ed706b476693df07151d (patch) | |
tree | 3cc1ce27a02e529687eadfbbae70b93b4e524a30 | |
parent | 8fdc6cd45891d26e2c82ad22cc6f85cbb4d526d2 (diff) |
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: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 28 | ||||
-rw-r--r-- | include/linux/mtd/spi-nor.h | 2 |
2 files changed, 10 insertions, 20 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 93cd1043ef4f..bfb67f1e2b7d 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c | |||
@@ -195,6 +195,10 @@ static int spi_nor_ready(struct spi_nor *nor) | |||
195 | return sr && fsr; | 195 | return sr && fsr; |
196 | } | 196 | } |
197 | 197 | ||
198 | /* | ||
199 | * Service routine to read status register until ready, or timeout occurs. | ||
200 | * Returns non-zero if error. | ||
201 | */ | ||
198 | static int spi_nor_wait_till_ready(struct spi_nor *nor) | 202 | static int spi_nor_wait_till_ready(struct spi_nor *nor) |
199 | { | 203 | { |
200 | unsigned long deadline; | 204 | unsigned long deadline; |
@@ -216,15 +220,6 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor) | |||
216 | } | 220 | } |
217 | 221 | ||
218 | /* | 222 | /* |
219 | * Service routine to read status register until ready, or timeout occurs. | ||
220 | * Returns non-zero if error. | ||
221 | */ | ||
222 | static int wait_till_ready(struct spi_nor *nor) | ||
223 | { | ||
224 | return nor->wait_till_ready(nor); | ||
225 | } | ||
226 | |||
227 | /* | ||
228 | * Erase the whole flash memory | 223 | * Erase the whole flash memory |
229 | * | 224 | * |
230 | * Returns 0 if successful, non-zero otherwise. | 225 | * Returns 0 if successful, non-zero otherwise. |
@@ -708,7 +703,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
708 | 703 | ||
709 | /* write one byte. */ | 704 | /* write one byte. */ |
710 | nor->write(nor, to, 1, retlen, buf); | 705 | nor->write(nor, to, 1, retlen, buf); |
711 | ret = wait_till_ready(nor); | 706 | ret = spi_nor_wait_till_ready(nor); |
712 | if (ret) | 707 | if (ret) |
713 | goto time_out; | 708 | goto time_out; |
714 | } | 709 | } |
@@ -720,7 +715,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
720 | 715 | ||
721 | /* write two bytes. */ | 716 | /* write two bytes. */ |
722 | nor->write(nor, to, 2, retlen, buf + actual); | 717 | nor->write(nor, to, 2, retlen, buf + actual); |
723 | ret = wait_till_ready(nor); | 718 | ret = spi_nor_wait_till_ready(nor); |
724 | if (ret) | 719 | if (ret) |
725 | goto time_out; | 720 | goto time_out; |
726 | to += 2; | 721 | to += 2; |
@@ -729,7 +724,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
729 | nor->sst_write_second = false; | 724 | nor->sst_write_second = false; |
730 | 725 | ||
731 | write_disable(nor); | 726 | write_disable(nor); |
732 | ret = wait_till_ready(nor); | 727 | ret = spi_nor_wait_till_ready(nor); |
733 | if (ret) | 728 | if (ret) |
734 | goto time_out; | 729 | goto time_out; |
735 | 730 | ||
@@ -740,7 +735,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
740 | nor->program_opcode = SPINOR_OP_BP; | 735 | nor->program_opcode = SPINOR_OP_BP; |
741 | nor->write(nor, to, 1, retlen, buf + actual); | 736 | nor->write(nor, to, 1, retlen, buf + actual); |
742 | 737 | ||
743 | ret = wait_till_ready(nor); | 738 | ret = spi_nor_wait_till_ready(nor); |
744 | if (ret) | 739 | if (ret) |
745 | goto time_out; | 740 | goto time_out; |
746 | write_disable(nor); | 741 | write_disable(nor); |
@@ -786,7 +781,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
786 | if (page_size > nor->page_size) | 781 | if (page_size > nor->page_size) |
787 | page_size = nor->page_size; | 782 | page_size = nor->page_size; |
788 | 783 | ||
789 | ret = wait_till_ready(nor); | 784 | ret = spi_nor_wait_till_ready(nor); |
790 | if (ret) | 785 | if (ret) |
791 | goto write_err; | 786 | goto write_err; |
792 | 787 | ||
@@ -812,7 +807,7 @@ static int macronix_quad_enable(struct spi_nor *nor) | |||
812 | nor->cmd_buf[0] = val | SR_QUAD_EN_MX; | 807 | nor->cmd_buf[0] = val | SR_QUAD_EN_MX; |
813 | nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0); | 808 | nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0); |
814 | 809 | ||
815 | if (wait_till_ready(nor)) | 810 | if (spi_nor_wait_till_ready(nor)) |
816 | return 1; | 811 | return 1; |
817 | 812 | ||
818 | ret = read_sr(nor); | 813 | ret = read_sr(nor); |
@@ -892,9 +887,6 @@ static int spi_nor_check(struct spi_nor *nor) | |||
892 | return -EINVAL; | 887 | return -EINVAL; |
893 | } | 888 | } |
894 | 889 | ||
895 | if (!nor->wait_till_ready) | ||
896 | nor->wait_till_ready = spi_nor_wait_till_ready; | ||
897 | |||
898 | return 0; | 890 | return 0; |
899 | } | 891 | } |
900 | 892 | ||
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index d691025d9b00..63aeccf9ddc8 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h | |||
@@ -144,7 +144,6 @@ enum spi_nor_option_flags { | |||
144 | * @write_xfer: [OPTIONAL] the writefundamental primitive | 144 | * @write_xfer: [OPTIONAL] the writefundamental primitive |
145 | * @read_reg: [DRIVER-SPECIFIC] read out the register | 145 | * @read_reg: [DRIVER-SPECIFIC] read out the register |
146 | * @write_reg: [DRIVER-SPECIFIC] write data to the register | 146 | * @write_reg: [DRIVER-SPECIFIC] write data to the register |
147 | * @wait_till_ready: [REPLACEABLE] wait till the NOR becomes ready | ||
148 | * @read: [DRIVER-SPECIFIC] read data from the SPI NOR | 147 | * @read: [DRIVER-SPECIFIC] read data from the SPI NOR |
149 | * @write: [DRIVER-SPECIFIC] write data to the SPI NOR | 148 | * @write: [DRIVER-SPECIFIC] write data to the SPI NOR |
150 | * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR | 149 | * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR |
@@ -176,7 +175,6 @@ struct spi_nor { | |||
176 | int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len); | 175 | int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len); |
177 | int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len, | 176 | int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len, |
178 | int write_enable); | 177 | int write_enable); |
179 | int (*wait_till_ready)(struct spi_nor *nor); | ||
180 | 178 | ||
181 | int (*read)(struct spi_nor *nor, loff_t from, | 179 | int (*read)(struct spi_nor *nor, loff_t from, |
182 | size_t len, size_t *retlen, u_char *read_buf); | 180 | size_t len, size_t *retlen, u_char *read_buf); |