diff options
Diffstat (limited to 'drivers/mtd/mtdpart.c')
-rw-r--r-- | drivers/mtd/mtdpart.c | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index a0bd2de4752b..a3d44c3416b4 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -70,8 +70,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
70 | len = 0; | 70 | len = 0; |
71 | else if (from + len > mtd->size) | 71 | else if (from + len > mtd->size) |
72 | len = mtd->size - from; | 72 | len = mtd->size - from; |
73 | res = part->master->read(part->master, from + part->offset, | 73 | res = mtd_read(part->master, from + part->offset, len, retlen, buf); |
74 | len, retlen, buf); | ||
75 | if (unlikely(res)) { | 74 | if (unlikely(res)) { |
76 | if (mtd_is_bitflip(res)) | 75 | if (mtd_is_bitflip(res)) |
77 | mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected; | 76 | mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected; |
@@ -89,15 +88,15 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
89 | len = 0; | 88 | len = 0; |
90 | else if (from + len > mtd->size) | 89 | else if (from + len > mtd->size) |
91 | len = mtd->size - from; | 90 | len = mtd->size - from; |
92 | return part->master->point (part->master, from + part->offset, | 91 | return mtd_point(part->master, from + part->offset, len, retlen, |
93 | len, retlen, virt, phys); | 92 | virt, phys); |
94 | } | 93 | } |
95 | 94 | ||
96 | static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 95 | static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
97 | { | 96 | { |
98 | struct mtd_part *part = PART(mtd); | 97 | struct mtd_part *part = PART(mtd); |
99 | 98 | ||
100 | part->master->unpoint(part->master, from + part->offset, len); | 99 | mtd_unpoint(part->master, from + part->offset, len); |
101 | } | 100 | } |
102 | 101 | ||
103 | static unsigned long part_get_unmapped_area(struct mtd_info *mtd, | 102 | static unsigned long part_get_unmapped_area(struct mtd_info *mtd, |
@@ -108,8 +107,7 @@ static unsigned long part_get_unmapped_area(struct mtd_info *mtd, | |||
108 | struct mtd_part *part = PART(mtd); | 107 | struct mtd_part *part = PART(mtd); |
109 | 108 | ||
110 | offset += part->offset; | 109 | offset += part->offset; |
111 | return part->master->get_unmapped_area(part->master, len, offset, | 110 | return mtd_get_unmapped_area(part->master, len, offset, flags); |
112 | flags); | ||
113 | } | 111 | } |
114 | 112 | ||
115 | static int part_read_oob(struct mtd_info *mtd, loff_t from, | 113 | static int part_read_oob(struct mtd_info *mtd, loff_t from, |
@@ -140,7 +138,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, | |||
140 | return -EINVAL; | 138 | return -EINVAL; |
141 | } | 139 | } |
142 | 140 | ||
143 | res = part->master->read_oob(part->master, from + part->offset, ops); | 141 | res = mtd_read_oob(part->master, from + part->offset, ops); |
144 | if (unlikely(res)) { | 142 | if (unlikely(res)) { |
145 | if (mtd_is_bitflip(res)) | 143 | if (mtd_is_bitflip(res)) |
146 | mtd->ecc_stats.corrected++; | 144 | mtd->ecc_stats.corrected++; |
@@ -154,30 +152,28 @@ static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from, | |||
154 | size_t len, size_t *retlen, u_char *buf) | 152 | size_t len, size_t *retlen, u_char *buf) |
155 | { | 153 | { |
156 | struct mtd_part *part = PART(mtd); | 154 | struct mtd_part *part = PART(mtd); |
157 | return part->master->read_user_prot_reg(part->master, from, | 155 | return mtd_read_user_prot_reg(part->master, from, len, retlen, buf); |
158 | len, retlen, buf); | ||
159 | } | 156 | } |
160 | 157 | ||
161 | static int part_get_user_prot_info(struct mtd_info *mtd, | 158 | static int part_get_user_prot_info(struct mtd_info *mtd, |
162 | struct otp_info *buf, size_t len) | 159 | struct otp_info *buf, size_t len) |
163 | { | 160 | { |
164 | struct mtd_part *part = PART(mtd); | 161 | struct mtd_part *part = PART(mtd); |
165 | return part->master->get_user_prot_info(part->master, buf, len); | 162 | return mtd_get_user_prot_info(part->master, buf, len); |
166 | } | 163 | } |
167 | 164 | ||
168 | static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, | 165 | static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, |
169 | size_t len, size_t *retlen, u_char *buf) | 166 | size_t len, size_t *retlen, u_char *buf) |
170 | { | 167 | { |
171 | struct mtd_part *part = PART(mtd); | 168 | struct mtd_part *part = PART(mtd); |
172 | return part->master->read_fact_prot_reg(part->master, from, | 169 | return mtd_read_fact_prot_reg(part->master, from, len, retlen, buf); |
173 | len, retlen, buf); | ||
174 | } | 170 | } |
175 | 171 | ||
176 | static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 172 | static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, |
177 | size_t len) | 173 | size_t len) |
178 | { | 174 | { |
179 | struct mtd_part *part = PART(mtd); | 175 | struct mtd_part *part = PART(mtd); |
180 | return part->master->get_fact_prot_info(part->master, buf, len); | 176 | return mtd_get_fact_prot_info(part->master, buf, len); |
181 | } | 177 | } |
182 | 178 | ||
183 | static int part_write(struct mtd_info *mtd, loff_t to, size_t len, | 179 | static int part_write(struct mtd_info *mtd, loff_t to, size_t len, |
@@ -190,8 +186,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
190 | len = 0; | 186 | len = 0; |
191 | else if (to + len > mtd->size) | 187 | else if (to + len > mtd->size) |
192 | len = mtd->size - to; | 188 | len = mtd->size - to; |
193 | return part->master->write(part->master, to + part->offset, | 189 | return mtd_write(part->master, to + part->offset, len, retlen, buf); |
194 | len, retlen, buf); | ||
195 | } | 190 | } |
196 | 191 | ||
197 | static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | 192 | static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, |
@@ -204,8 +199,8 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
204 | len = 0; | 199 | len = 0; |
205 | else if (to + len > mtd->size) | 200 | else if (to + len > mtd->size) |
206 | len = mtd->size - to; | 201 | len = mtd->size - to; |
207 | return part->master->panic_write(part->master, to + part->offset, | 202 | return mtd_panic_write(part->master, to + part->offset, len, retlen, |
208 | len, retlen, buf); | 203 | buf); |
209 | } | 204 | } |
210 | 205 | ||
211 | static int part_write_oob(struct mtd_info *mtd, loff_t to, | 206 | static int part_write_oob(struct mtd_info *mtd, loff_t to, |
@@ -220,22 +215,21 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, | |||
220 | return -EINVAL; | 215 | return -EINVAL; |
221 | if (ops->datbuf && to + ops->len > mtd->size) | 216 | if (ops->datbuf && to + ops->len > mtd->size) |
222 | return -EINVAL; | 217 | return -EINVAL; |
223 | return part->master->write_oob(part->master, to + part->offset, ops); | 218 | return mtd_write_oob(part->master, to + part->offset, ops); |
224 | } | 219 | } |
225 | 220 | ||
226 | static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from, | 221 | static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from, |
227 | size_t len, size_t *retlen, u_char *buf) | 222 | size_t len, size_t *retlen, u_char *buf) |
228 | { | 223 | { |
229 | struct mtd_part *part = PART(mtd); | 224 | struct mtd_part *part = PART(mtd); |
230 | return part->master->write_user_prot_reg(part->master, from, | 225 | return mtd_write_user_prot_reg(part->master, from, len, retlen, buf); |
231 | len, retlen, buf); | ||
232 | } | 226 | } |
233 | 227 | ||
234 | static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, | 228 | static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, |
235 | size_t len) | 229 | size_t len) |
236 | { | 230 | { |
237 | struct mtd_part *part = PART(mtd); | 231 | struct mtd_part *part = PART(mtd); |
238 | return part->master->lock_user_prot_reg(part->master, from, len); | 232 | return mtd_lock_user_prot_reg(part->master, from, len); |
239 | } | 233 | } |
240 | 234 | ||
241 | static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, | 235 | static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, |
@@ -244,8 +238,8 @@ static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
244 | struct mtd_part *part = PART(mtd); | 238 | struct mtd_part *part = PART(mtd); |
245 | if (!(mtd->flags & MTD_WRITEABLE)) | 239 | if (!(mtd->flags & MTD_WRITEABLE)) |
246 | return -EROFS; | 240 | return -EROFS; |
247 | return part->master->writev(part->master, vecs, count, | 241 | return mtd_writev(part->master, vecs, count, to + part->offset, |
248 | to + part->offset, retlen); | 242 | retlen); |
249 | } | 243 | } |
250 | 244 | ||
251 | static int part_erase(struct mtd_info *mtd, struct erase_info *instr) | 245 | static int part_erase(struct mtd_info *mtd, struct erase_info *instr) |
@@ -257,7 +251,7 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
257 | if (instr->addr >= mtd->size) | 251 | if (instr->addr >= mtd->size) |
258 | return -EINVAL; | 252 | return -EINVAL; |
259 | instr->addr += part->offset; | 253 | instr->addr += part->offset; |
260 | ret = part->master->erase(part->master, instr); | 254 | ret = mtd_erase(part->master, instr); |
261 | if (ret) { | 255 | if (ret) { |
262 | if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) | 256 | if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) |
263 | instr->fail_addr -= part->offset; | 257 | instr->fail_addr -= part->offset; |
@@ -285,7 +279,7 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
285 | struct mtd_part *part = PART(mtd); | 279 | struct mtd_part *part = PART(mtd); |
286 | if ((len + ofs) > mtd->size) | 280 | if ((len + ofs) > mtd->size) |
287 | return -EINVAL; | 281 | return -EINVAL; |
288 | return part->master->lock(part->master, ofs + part->offset, len); | 282 | return mtd_lock(part->master, ofs + part->offset, len); |
289 | } | 283 | } |
290 | 284 | ||
291 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 285 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
@@ -293,7 +287,7 @@ static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
293 | struct mtd_part *part = PART(mtd); | 287 | struct mtd_part *part = PART(mtd); |
294 | if ((len + ofs) > mtd->size) | 288 | if ((len + ofs) > mtd->size) |
295 | return -EINVAL; | 289 | return -EINVAL; |
296 | return part->master->unlock(part->master, ofs + part->offset, len); | 290 | return mtd_unlock(part->master, ofs + part->offset, len); |
297 | } | 291 | } |
298 | 292 | ||
299 | static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 293 | static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
@@ -301,25 +295,25 @@ static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
301 | struct mtd_part *part = PART(mtd); | 295 | struct mtd_part *part = PART(mtd); |
302 | if ((len + ofs) > mtd->size) | 296 | if ((len + ofs) > mtd->size) |
303 | return -EINVAL; | 297 | return -EINVAL; |
304 | return part->master->is_locked(part->master, ofs + part->offset, len); | 298 | return mtd_is_locked(part->master, ofs + part->offset, len); |
305 | } | 299 | } |
306 | 300 | ||
307 | static void part_sync(struct mtd_info *mtd) | 301 | static void part_sync(struct mtd_info *mtd) |
308 | { | 302 | { |
309 | struct mtd_part *part = PART(mtd); | 303 | struct mtd_part *part = PART(mtd); |
310 | part->master->sync(part->master); | 304 | mtd_sync(part->master); |
311 | } | 305 | } |
312 | 306 | ||
313 | static int part_suspend(struct mtd_info *mtd) | 307 | static int part_suspend(struct mtd_info *mtd) |
314 | { | 308 | { |
315 | struct mtd_part *part = PART(mtd); | 309 | struct mtd_part *part = PART(mtd); |
316 | return part->master->suspend(part->master); | 310 | return mtd_suspend(part->master); |
317 | } | 311 | } |
318 | 312 | ||
319 | static void part_resume(struct mtd_info *mtd) | 313 | static void part_resume(struct mtd_info *mtd) |
320 | { | 314 | { |
321 | struct mtd_part *part = PART(mtd); | 315 | struct mtd_part *part = PART(mtd); |
322 | part->master->resume(part->master); | 316 | mtd_resume(part->master); |
323 | } | 317 | } |
324 | 318 | ||
325 | static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) | 319 | static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) |
@@ -328,7 +322,7 @@ static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) | |||
328 | if (ofs >= mtd->size) | 322 | if (ofs >= mtd->size) |
329 | return -EINVAL; | 323 | return -EINVAL; |
330 | ofs += part->offset; | 324 | ofs += part->offset; |
331 | return part->master->block_isbad(part->master, ofs); | 325 | return mtd_block_isbad(part->master, ofs); |
332 | } | 326 | } |
333 | 327 | ||
334 | static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) | 328 | static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) |
@@ -341,7 +335,7 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
341 | if (ofs >= mtd->size) | 335 | if (ofs >= mtd->size) |
342 | return -EINVAL; | 336 | return -EINVAL; |
343 | ofs += part->offset; | 337 | ofs += part->offset; |
344 | res = part->master->block_markbad(part->master, ofs); | 338 | res = mtd_block_markbad(part->master, ofs); |
345 | if (!res) | 339 | if (!res) |
346 | mtd->ecc_stats.badblocks++; | 340 | mtd->ecc_stats.badblocks++; |
347 | return res; | 341 | return res; |
@@ -559,8 +553,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, | |||
559 | uint64_t offs = 0; | 553 | uint64_t offs = 0; |
560 | 554 | ||
561 | while (offs < slave->mtd.size) { | 555 | while (offs < slave->mtd.size) { |
562 | if (master->block_isbad(master, | 556 | if (mtd_block_isbad(master, offs + slave->offset)) |
563 | offs + slave->offset)) | ||
564 | slave->mtd.ecc_stats.badblocks++; | 557 | slave->mtd.ecc_stats.badblocks++; |
565 | offs += slave->mtd.erasesize; | 558 | offs += slave->mtd.erasesize; |
566 | } | 559 | } |