1 From 2dd087b16946cf168f401526adf26afa771bb740 Mon Sep 17 00:00:00 2001
2 From: Michal Suchanek <hramrach@gmail.com>
3 Date: Thu, 5 May 2016 17:31:53 -0700
4 Subject: [PATCH 07/10] mtd: spi-nor: stop passing around retlen
6 Do not pass retlen to hardware driver read/write functions. Update it in
7 spi-nor generic driver instead.
9 Signed-off-by: Michal Suchanek <hramrach@gmail.com>
10 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
11 Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com>
12 Acked-by: Michal Suchanek <hramrach@gmail.com>
13 Tested-by: Michal Suchanek <hramrach@gmail.com>
15 drivers/mtd/devices/m25p80.c | 7 ++-----
16 drivers/mtd/spi-nor/fsl-quadspi.c | 17 ++++++-----------
17 drivers/mtd/spi-nor/nxp-spifi.c | 6 ++----
18 drivers/mtd/spi-nor/spi-nor.c | 21 +++++++++++++--------
19 include/linux/mtd/spi-nor.h | 4 ++--
20 6 files changed, 28 insertions(+), 35 deletions(-)
22 --- a/drivers/mtd/devices/m25p80.c
23 +++ b/drivers/mtd/devices/m25p80.c
24 @@ -74,7 +74,7 @@ static int m25p80_write_reg(struct spi_n
27 static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
28 - size_t *retlen, const u_char *buf)
31 struct m25p *flash = nor->priv;
32 struct spi_device *spi = flash->spi;
33 @@ -106,7 +106,6 @@ static ssize_t m25p80_write(struct spi_n
34 ret = m.actual_length - cmd_sz;
41 @@ -127,7 +126,7 @@ static inline unsigned int m25p80_rx_nbi
42 * may be any size provided it is within the physical boundaries.
44 static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
45 - size_t *retlen, u_char *buf)
48 struct m25p *flash = nor->priv;
49 struct spi_device *spi = flash->spi;
50 @@ -156,7 +155,6 @@ static ssize_t m25p80_read(struct spi_no
51 msg.data_nbits = m25p80_rx_nbits(nor);
53 ret = spi_flash_read(spi, &msg);
54 - *retlen = msg.retlen;
58 @@ -184,7 +182,6 @@ static ssize_t m25p80_read(struct spi_no
59 ret = m.actual_length - m25p_cmdsz(nor) - dummy;
66 --- a/drivers/mtd/spi-nor/fsl-quadspi.c
67 +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
68 @@ -577,7 +577,7 @@ static inline void fsl_qspi_invalid(stru
70 static ssize_t fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor,
71 u8 opcode, unsigned int to, u32 *txbuf,
72 - unsigned count, size_t *retlen)
77 @@ -604,11 +604,8 @@ static ssize_t fsl_qspi_nor_write(struct
79 ret = fsl_qspi_runcmd(q, opcode, to, count);
90 @@ -816,7 +813,7 @@ static int fsl_qspi_write_reg(struct spi
93 ret = fsl_qspi_nor_write(q, nor, opcode, 0,
94 - (u32 *)buf, len, NULL);
99 @@ -828,12 +825,11 @@ static int fsl_qspi_write_reg(struct spi
102 static ssize_t fsl_qspi_write(struct spi_nor *nor, loff_t to,
103 - size_t len, size_t *retlen, const u_char *buf)
104 + size_t len, const u_char *buf)
106 struct fsl_qspi *q = nor->priv;
108 ssize_t ret = fsl_qspi_nor_write(q, nor, nor->program_opcode, to,
109 - (u32 *)buf, len, retlen);
112 /* invalid the data in the AHB buffer. */
114 @@ -841,7 +837,7 @@ static ssize_t fsl_qspi_write(struct spi
117 static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from,
118 - size_t len, size_t *retlen, u_char *buf)
119 + size_t len, u_char *buf)
121 struct fsl_qspi *q = nor->priv;
122 u8 cmd = nor->read_opcode;
123 @@ -883,7 +879,6 @@ static ssize_t fsl_qspi_read(struct spi_
124 memcpy(buf, q->ahb_addr + q->chip_base_addr + from - q->memmap_offs,
131 --- a/drivers/mtd/spi-nor/nxp-spifi.c
132 +++ b/drivers/mtd/spi-nor/nxp-spifi.c
133 @@ -173,7 +173,7 @@ static int nxp_spifi_write_reg(struct sp
136 static ssize_t nxp_spifi_read(struct spi_nor *nor, loff_t from, size_t len,
137 - size_t *retlen, u_char *buf)
140 struct nxp_spifi *spifi = nor->priv;
142 @@ -183,13 +183,12 @@ static ssize_t nxp_spifi_read(struct spi
145 memcpy_fromio(buf, spifi->flash_base + from, len);
151 static ssize_t nxp_spifi_write(struct spi_nor *nor, loff_t to, size_t len,
152 - size_t *retlen, const u_char *buf)
155 struct nxp_spifi *spifi = nor->priv;
157 @@ -201,7 +200,6 @@ static ssize_t nxp_spifi_write(struct sp
160 writel(to, spifi->io_base + SPIFI_ADDR);
163 cmd = SPIFI_CMD_DOUT |
164 SPIFI_CMD_DATALEN(len) |
165 --- a/drivers/mtd/spi-nor/spi-nor.c
166 +++ b/drivers/mtd/spi-nor/spi-nor.c
167 @@ -890,12 +890,13 @@ static int spi_nor_read(struct mtd_info
171 - ret = nor->read(nor, from, len, retlen, buf);
172 + ret = nor->read(nor, from, len, buf);
174 spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
182 @@ -922,7 +923,7 @@ static int sst_write(struct mtd_info *mt
183 nor->program_opcode = SPINOR_OP_BP;
185 /* write one byte. */
186 - ret = nor->write(nor, to, 1, retlen, buf);
187 + ret = nor->write(nor, to, 1, buf);
190 WARN(ret != 1, "While writing 1 byte written %i bytes\n",
191 @@ -938,7 +939,7 @@ static int sst_write(struct mtd_info *mt
192 nor->program_opcode = SPINOR_OP_AAI_WP;
194 /* write two bytes. */
195 - ret = nor->write(nor, to, 2, retlen, buf + actual);
196 + ret = nor->write(nor, to, 2, buf + actual);
199 WARN(ret != 2, "While writing 2 bytes written %i bytes\n",
200 @@ -961,7 +962,7 @@ static int sst_write(struct mtd_info *mt
203 nor->program_opcode = SPINOR_OP_BP;
204 - ret = nor->write(nor, to, 1, retlen, buf + actual);
205 + ret = nor->write(nor, to, 1, buf + actual);
208 WARN(ret != 1, "While writing 1 byte written %i bytes\n",
209 @@ -970,8 +971,10 @@ static int sst_write(struct mtd_info *mt
217 spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
220 @@ -1000,15 +1003,17 @@ static int spi_nor_write(struct mtd_info
222 /* do all the bytes fit onto one page? */
223 if (page_offset + len <= nor->page_size) {
224 - ret = nor->write(nor, to, len, retlen, buf);
225 + ret = nor->write(nor, to, len, buf);
230 /* the size of data remaining on the first page */
231 page_size = nor->page_size - page_offset;
232 - ret = nor->write(nor, to, page_size, retlen, buf);
233 + ret = nor->write(nor, to, page_size, buf);
238 /* write everything in nor->page_size chunks */
239 for (i = ret; i < len; ) {
240 @@ -1022,10 +1027,10 @@ static int spi_nor_write(struct mtd_info
244 - ret = nor->write(nor, to + i, page_size, retlen,
246 + ret = nor->write(nor, to + i, page_size, buf + i);
253 --- a/include/linux/mtd/spi-nor.h
254 +++ b/include/linux/mtd/spi-nor.h
255 @@ -170,9 +170,9 @@ struct spi_nor {
256 int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
258 ssize_t (*read)(struct spi_nor *nor, loff_t from,
259 - size_t len, size_t *retlen, u_char *read_buf);
260 + size_t len, u_char *read_buf);
261 ssize_t (*write)(struct spi_nor *nor, loff_t to,
262 - size_t len, size_t *retlen, const u_char *write_buf);
263 + size_t len, const u_char *write_buf);
264 int (*erase)(struct spi_nor *nor, loff_t offs);
266 int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);