kernel: update kernel 4.4 to version 4.4.30
[lede.git] / target / linux / layerscape / patches-4.4 / 1094-mtd-spi-nor-stop-passing-around-retlen.patch
1 From a99477d72b500b48cb3614aad0ce096fe4e3f437 Mon Sep 17 00:00:00 2001
2 From: Michal Suchanek <hramrach@gmail.com>
3 Date: Wed, 2 Dec 2015 10:38:20 +0000
4 Subject: [PATCH 094/113] mtd: spi-nor: stop passing around retlen
5
6 [context adjustment]
7 not apply changes of drivers/mtd/devices/m25p80.c
8 #################
9 @@ -74,7 +74,7 @@ static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
10  }
11
12  static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
13 -                       size_t *retlen, const u_char *buf)
14 +                           const u_char *buf)
15  {
16         struct m25p *flash = nor->priv;
17         struct spi_device *spi = flash->spi;
18 @@ -106,7 +106,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
19         ret = m.actual_length - cmd_sz;
20         if (ret < 0)
21                 return -EIO;
22 -       *retlen += ret;
23         return ret;
24  }
25
26 @@ -127,7 +126,7 @@ static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)
27   * may be any size provided it is within the physical boundaries.
28   */
29  static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
30 -                       size_t *retlen, u_char *buf)
31 +                          u_char *buf)
32  {
33         struct m25p *flash = nor->priv;
34         struct spi_device *spi = flash->spi;
35 @@ -161,7 +160,6 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
36         ret = m.actual_length - m25p_cmdsz(nor) - dummy;
37         if (ret < 0)
38                 return -EIO;
39 -       *retlen += ret;
40         return ret;
41  }
42
43 #################
44
45 Do not pass retlen to hardware driver read/write functions. Update it in
46 spi-nor generic driver instead.
47
48 Signed-off-by: Michal Suchanek <hramrach@gmail.com>
49 Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@freescale.com>
50 Integrated-by: Jiang Yutang <yutang.jiang@nxp.com>
51 ---
52  drivers/mtd/spi-nor/fsl-quadspi.c |   16 ++++++----------
53  drivers/mtd/spi-nor/spi-nor.c     |   21 +++++++++++++--------
54  include/linux/mtd/spi-nor.h       |    4 ++--
55  3 files changed, 21 insertions(+), 20 deletions(-)
56
57 --- a/drivers/mtd/spi-nor/fsl-quadspi.c
58 +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
59 @@ -620,7 +620,7 @@ static inline void fsl_qspi_invalid(stru
60  
61  static ssize_t fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor,
62                                 u8 opcode, unsigned int to, u32 *txbuf,
63 -                               unsigned count, size_t *retlen)
64 +                               unsigned count)
65  {
66         int ret, i, j;
67         u32 tmp;
68 @@ -647,11 +647,8 @@ static ssize_t fsl_qspi_nor_write(struct
69         /* Trigger it */
70         ret = fsl_qspi_runcmd(q, opcode, to, count);
71  
72 -       if (ret == 0) {
73 -               if (retlen)
74 -                       *retlen += count;
75 +       if (ret == 0)
76                 return count;
77 -       }
78  
79         return ret;
80  }
81 @@ -862,7 +859,7 @@ static int fsl_qspi_write_reg(struct spi
82  
83         } else if (len > 0) {
84                 ret = fsl_qspi_nor_write(q, nor, opcode, 0,
85 -                                       (u32 *)buf, len, NULL);
86 +                                       (u32 *)buf, len);
87                 if (ret > 0)
88                         return 0;
89         } else {
90 @@ -874,12 +871,11 @@ static int fsl_qspi_write_reg(struct spi
91  }
92  
93  static ssize_t fsl_qspi_write(struct spi_nor *nor, loff_t to,
94 -               size_t len, size_t *retlen, const u_char *buf)
95 +                             size_t len, const u_char *buf)
96  {
97         struct fsl_qspi *q = nor->priv;
98 -
99         ssize_t ret = fsl_qspi_nor_write(q, nor, nor->program_opcode, to,
100 -                               (u32 *)buf, len, retlen);
101 +                                        (u32 *)buf, len);
102  
103         /* invalid the data in the AHB buffer. */
104         fsl_qspi_invalid(q);
105 @@ -887,7 +883,7 @@ static ssize_t fsl_qspi_write(struct spi
106  }
107  
108  static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from,
109 -               size_t len, size_t *retlen, u_char *buf)
110 +                            size_t len, u_char *buf)
111  {
112         struct fsl_qspi *q = nor->priv;
113         u8 cmd = nor->read_opcode;
114 --- a/drivers/mtd/spi-nor/spi-nor.c
115 +++ b/drivers/mtd/spi-nor/spi-nor.c
116 @@ -920,12 +920,13 @@ static int spi_nor_read(struct mtd_info
117         if (ret)
118                 return ret;
119  
120 -       ret = nor->read(nor, from, len, retlen, buf);
121 +       ret = nor->read(nor, from, len, buf);
122  
123         spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
124         if (ret < 0)
125                 return ret;
126  
127 +       *retlen += ret;
128         return 0;
129  }
130  
131 @@ -952,7 +953,7 @@ static int sst_write(struct mtd_info *mt
132                 nor->program_opcode = SPINOR_OP_BP;
133  
134                 /* write one byte. */
135 -               ret = nor->write(nor, to, 1, retlen, buf);
136 +               ret = nor->write(nor, to, 1, buf);
137                 if (ret < 0)
138                         goto sst_write_err;
139                 WARN(ret != 1, "While writing 1 byte written %i bytes\n",
140 @@ -968,7 +969,7 @@ static int sst_write(struct mtd_info *mt
141                 nor->program_opcode = SPINOR_OP_AAI_WP;
142  
143                 /* write two bytes. */
144 -               ret = nor->write(nor, to, 2, retlen, buf + actual);
145 +               ret = nor->write(nor, to, 2, buf + actual);
146                 if (ret < 0)
147                         goto sst_write_err;
148                 WARN(ret != 2, "While writing 2 bytes written %i bytes\n",
149 @@ -991,7 +992,7 @@ static int sst_write(struct mtd_info *mt
150                 write_enable(nor);
151  
152                 nor->program_opcode = SPINOR_OP_BP;
153 -               ret = nor->write(nor, to, 1, retlen, buf + actual);
154 +               ret = nor->write(nor, to, 1, buf + actual);
155                 if (ret < 0)
156                         goto sst_write_err;
157                 WARN(ret != 1, "While writing 1 byte written %i bytes\n",
158 @@ -1000,8 +1001,10 @@ static int sst_write(struct mtd_info *mt
159                 if (ret)
160                         goto sst_write_err;
161                 write_disable(nor);
162 +               actual += 1;
163         }
164  sst_write_err:
165 +       *retlen += actual;
166         spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
167         return ret;
168  }
169 @@ -1030,15 +1033,17 @@ static int spi_nor_write(struct mtd_info
170  
171         /* do all the bytes fit onto one page? */
172         if (page_offset + len <= nor->page_size) {
173 -               ret = nor->write(nor, to, len, retlen, buf);
174 +               ret = nor->write(nor, to, len, buf);
175                 if (ret < 0)
176                         goto write_err;
177 +               *retlen += ret;
178         } else {
179                 /* the size of data remaining on the first page */
180                 page_size = nor->page_size - page_offset;
181 -               ret = nor->write(nor, to, page_size, retlen, buf);
182 +               ret = nor->write(nor, to, page_size, buf);
183                 if (ret < 0)
184                         goto write_err;
185 +               *retlen += ret;
186  
187                 /* write everything in nor->page_size chunks */
188                 for (i = ret; i < len; ) {
189 @@ -1052,10 +1057,10 @@ static int spi_nor_write(struct mtd_info
190  
191                         write_enable(nor);
192  
193 -                       ret = nor->write(nor, to + i, page_size, retlen,
194 -                                        buf + i);
195 +                       ret = nor->write(nor, to + i, page_size, buf + i);
196                         if (ret < 0)
197                                 goto write_err;
198 +                       *retlen += ret;
199                         i += ret;
200                 }
201         }
202 --- a/include/linux/mtd/spi-nor.h
203 +++ b/include/linux/mtd/spi-nor.h
204 @@ -171,9 +171,9 @@ struct spi_nor {
205         int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
206  
207         ssize_t (*read)(struct spi_nor *nor, loff_t from,
208 -                       size_t len, size_t *retlen, u_char *read_buf);
209 +                       size_t len, u_char *read_buf);
210         ssize_t (*write)(struct spi_nor *nor, loff_t to,
211 -                       size_t len, size_t *retlen, const u_char *write_buf);
212 +                       size_t len, const u_char *write_buf);
213         int (*erase)(struct spi_nor *nor, loff_t offs);
214  
215         int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);