1 /*
2 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 *
6 */
7
8 #ifndef __MTD_MTD_H__
9 #define __MTD_MTD_H__
10
11 #ifndef __UBOOT__
12 #include <linux/types.h>
13 #include <linux/uio.h>
14 #include <linux/notifier.h>
15 #include <linux/device.h>
16
17 #include <mtd/mtd-abi.h>
18
19 #include <asm/div64.h>
20 #else
21 #include <linux/compat.h>
22 #include <mtd/mtd-abi.h>
23 #include <linux/errno.h>
24 #include <linux/list.h>
25 #include <div64.h>
26 #if IS_ENABLED(CONFIG_DM)
27 #include <dm/device.h>
28 #endif
29
30 #define MAX_MTD_DEVICES 32
31 #endif
32
33 #define MTD_ERASE_PENDING 0x01
34 #define MTD_ERASING 0x02
35 #define MTD_ERASE_SUSPEND 0x04
36 #define MTD_ERASE_DONE 0x08
37 #define MTD_ERASE_FAILED 0x10
38
39 #define MTD_FAIL_ADDR_UNKNOWN -1LL
40
41 /*
42 * If the erase fails, fail_addr might indicate exactly which block failed. If
43 * fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level
44 * or was not specific to any particular block.
45 */
46 struct erase_info {
47 struct mtd_info *mtd;
48 uint64_t addr;
49 uint64_t len;
50 uint64_t fail_addr;
51 u_long time;
52 u_long retries;
53 unsigned dev;
54 unsigned cell;
55 void (*callback) (struct erase_info *self);
56 u_long priv;
57 u_char state;
58 struct erase_info *next;
59 int scrub;
60 };
61
62 struct mtd_erase_region_info {
63 uint64_t offset; /* At which this region starts, from the beginning of the MTD */
64 uint32_t erasesize; /* For this region */
65 uint32_t numblocks; /* Number of blocks of erasesize in this region */
66 unsigned long *lockmap; /* If keeping bitmap of locks */
67 };
68
69 /**
70 * struct mtd_oob_ops - oob operation operands
71 * @mode: operation mode
72 *
73 * @len: number of data bytes to write/read
74 *
75 * @retlen: number of data bytes written/read
76 *
77 * @ooblen: number of oob bytes to write/read
78 * @oobretlen: number of oob bytes written/read
79 * @ooboffs: offset of oob data in the oob area (only relevant when
80 * mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
81 * @datbuf: data buffer - if NULL only oob data are read/written
82 * @oobbuf: oob data buffer
83 *
84 * Note, it is allowed to read more than one OOB area at one go, but not write.
85 * The interface assumes that the OOB write requests program only one page's
86 * OOB area.
87 */
88 struct mtd_oob_ops {
89 unsigned int mode;
90 size_t len;
91 size_t retlen;
92 size_t ooblen;
93 size_t oobretlen;
94 uint32_t ooboffs;
95 uint8_t *datbuf;
96 uint8_t *oobbuf;
97 };
98
99 #ifdef CONFIG_SYS_NAND_MAX_OOBFREE
100 #define MTD_MAX_OOBFREE_ENTRIES_LARGE CONFIG_SYS_NAND_MAX_OOBFREE
101 #else
102 #define MTD_MAX_OOBFREE_ENTRIES_LARGE 32
103 #endif
104
105 #ifdef CONFIG_SYS_NAND_MAX_ECCPOS
106 #define MTD_MAX_ECCPOS_ENTRIES_LARGE CONFIG_SYS_NAND_MAX_ECCPOS
107 #else
108 #define MTD_MAX_ECCPOS_ENTRIES_LARGE 680
109 #endif
110 /**
111 * struct mtd_oob_region - oob region definition
112 * @offset: region offset
113 * @length: region length
114 *
115 * This structure describes a region of the OOB area, and is used
116 * to retrieve ECC or free bytes sections.
117 * Each section is defined by an offset within the OOB area and a
118 * length.
119 */
120 struct mtd_oob_region {
121 u32 offset;
122 u32 length;
123 };
124
125 /*
126 * struct mtd_ooblayout_ops - NAND OOB layout operations
127 * @ecc: function returning an ECC region in the OOB area.
128 * Should return -ERANGE if %section exceeds the total number of
129 * ECC sections.
130 * @free: function returning a free region in the OOB area.
131 * Should return -ERANGE if %section exceeds the total number of
132 * free sections.
133 */
134 struct mtd_ooblayout_ops {
135 int (*ecc)(struct mtd_info *mtd, int section,
136 struct mtd_oob_region *oobecc);
137 int (*rfree)(struct mtd_info *mtd, int section,
138 struct mtd_oob_region *oobfree);
139 };
140
141 /*
142 * Internal ECC layout control structure. For historical reasons, there is a
143 * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained
144 * for export to user-space via the ECCGETLAYOUT ioctl.
145 * nand_ecclayout should be expandable in the future simply by the above macros.
146 */
147 struct nand_ecclayout {
148 __u32 eccbytes;
149 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE];
150 __u32 oobavail;
151 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
152 };
153
154 struct module; /* only needed for owner field in mtd_info */
155
156 struct mtd_info {
157 u_char type;
158 uint32_t flags;
159 uint64_t size; // Total size of the MTD
160
161 /* "Major" erase size for the device. Naïve users may take this
162 * to be the only erase size available, or may use the more detailed
163 * information below if they desire
164 */
165 uint32_t erasesize;
166 /* Minimal writable flash unit size. In case of NOR flash it is 1 (even
167 * though individual bits can be cleared), in case of NAND flash it is
168 * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR
169 * it is of ECC block size, etc. It is illegal to have writesize = 0.
170 * Any driver registering a struct mtd_info must ensure a writesize of
171 * 1 or larger.
172 */
173 uint32_t writesize;
174
175 /*
176 * Size of the write buffer used by the MTD. MTD devices having a write
177 * buffer can write multiple writesize chunks at a time. E.g. while
178 * writing 4 * writesize bytes to a device with 2 * writesize bytes
179 * buffer the MTD driver can (but doesn't have to) do 2 writesize
180 * operations, but not 4. Currently, all NANDs have writebufsize
181 * equivalent to writesize (NAND page size). Some NOR flashes do have
182 * writebufsize greater than writesize.
183 */
184 uint32_t writebufsize;
185
186 uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
187 uint32_t oobavail; // Available OOB bytes per block
188
189 /*
190 * If erasesize is a power of 2 then the shift is stored in
191 * erasesize_shift otherwise erasesize_shift is zero. Ditto writesize.
192 */
193 unsigned int erasesize_shift;
194 unsigned int writesize_shift;
195 /* Masks based on erasesize_shift and writesize_shift */
196 unsigned int erasesize_mask;
197 unsigned int writesize_mask;
198
199 /*
200 * read ops return -EUCLEAN if max number of bitflips corrected on any
201 * one region comprising an ecc step equals or exceeds this value.
202 * Settable by driver, else defaults to ecc_strength. User can override
203 * in sysfs. N.B. The meaning of the -EUCLEAN return code has changed;
204 * see Documentation/ABI/testing/sysfs-class-mtd for more detail.
205 */
206 unsigned int bitflip_threshold;
207
208 // Kernel-only stuff starts here.
209 #ifndef __UBOOT__
210 const char *name;
211 #else
212 char *name;
213 #endif
214 int index;
215
216 /* OOB layout description */
217 const struct mtd_ooblayout_ops *ooblayout;
218
219 /* ECC layout structure pointer - read only! */
220 struct nand_ecclayout *ecclayout;
221
222 /* the ecc step size. */
223 unsigned int ecc_step_size;
224
225 /* max number of correctible bit errors per ecc step */
226 unsigned int ecc_strength;
227
228 /* Data for variable erase regions. If numeraseregions is zero,
229 * it means that the whole device has erasesize as given above.
230 */
231 int numeraseregions;
232 struct mtd_erase_region_info *eraseregions;
233
234 /*
235 * Do not call via these pointers, use corresponding mtd_*()
236 * wrappers instead.
237 */
238 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
239 #ifndef __UBOOT__
240 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
241 size_t *retlen, void **virt, resource_size_t *phys);
242 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
243 #endif
244 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
245 unsigned long len,
246 unsigned long offset,
247 unsigned long flags);
248 int (*_read) (struct mtd_info *mtd, loff_t from, size_t len,
249 size_t *retlen, u_char *buf);
250 int (*_write) (struct mtd_info *mtd, loff_t to, size_t len,
251 size_t *retlen, const u_char *buf);
252 int (*_panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
253 size_t *retlen, const u_char *buf);
254 int (*_read_oob) (struct mtd_info *mtd, loff_t from,
255 struct mtd_oob_ops *ops);
256 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
257 struct mtd_oob_ops *ops);
258 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
259 size_t *retlen, struct otp_info *buf);
260 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
261 size_t len, size_t *retlen, u_char *buf);
262 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
263 size_t *retlen, struct otp_info *buf);
264 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
265 size_t len, size_t *retlen, u_char *buf);
266 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
267 size_t len, size_t *retlen, u_char *buf);
268 int (*_lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
269 size_t len);
270 #ifndef __UBOOT__
271 int (*_writev) (struct mtd_info *mtd, const struct kvec *vecs,
272 unsigned long count, loff_t to, size_t *retlen);
273 #endif
274 void (*_sync) (struct mtd_info *mtd);
275 int (*_lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
276 int (*_unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
277 int (*_is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
278 int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs);
279 int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs);
280 int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs);
281 #ifndef __UBOOT__
282 int (*_suspend) (struct mtd_info *mtd);
283 void (*_resume) (struct mtd_info *mtd);
284 void (*_reboot) (struct mtd_info *mtd);
285 #endif
286 /*
287 * If the driver is something smart, like UBI, it may need to maintain
288 * its own reference counting. The below functions are only for driver.
289 */
290 int (*_get_device) (struct mtd_info *mtd);
291 void (*_put_device) (struct mtd_info *mtd);
292
293 #ifndef __UBOOT__
294 /* Backing device capabilities for this device
295 * - provides mmap capabilities
296 */
297 struct backing_dev_info *backing_dev_info;
298
299 struct notifier_block reboot_notifier; /* default mode before reboot */
300 #endif
301
302 /* ECC status information */
303 struct mtd_ecc_stats ecc_stats;
304 /* Subpage shift (NAND) */
305 int subpage_sft;
306
307 void *priv;
308
309 struct module *owner;
310 #ifndef __UBOOT__
311 struct device dev;
312 #else
313 struct udevice *dev;
314 #endif
315 int usecount;
316
317 /* MTD devices do not have any parent. MTD partitions do. */
318 struct mtd_info *parent;
319
320 /*
321 * Offset of the partition relatively to the parent offset.
322 * Is 0 for real MTD devices (ie. not partitions).
323 */
324 u64 offset;
325
326 /*
327 * List node used to add an MTD partition to the parent
328 * partition list.
329 */
330 struct list_head node;
331
332 /*
333 * List of partitions attached to this MTD device (the parent
334 * MTD device can itself be a partition).
335 */
336 struct list_head partitions;
337 };
338
339 #if IS_ENABLED(CONFIG_DM)
mtd_set_of_node(struct mtd_info * mtd,const struct device_node * np)340 static inline void mtd_set_of_node(struct mtd_info *mtd,
341 const struct device_node *np)
342 {
343 mtd->dev->node.np = np;
344 }
345
mtd_get_of_node(struct mtd_info * mtd)346 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
347 {
348 return mtd->dev->node.np;
349 }
350 #else
351 struct device_node;
352
mtd_set_of_node(struct mtd_info * mtd,const struct device_node * np)353 static inline void mtd_set_of_node(struct mtd_info *mtd,
354 const struct device_node *np)
355 {
356 }
357
mtd_get_of_node(struct mtd_info * mtd)358 static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
359 {
360 return NULL;
361 }
362 #endif
363
mtd_is_partition(const struct mtd_info * mtd)364 static inline bool mtd_is_partition(const struct mtd_info *mtd)
365 {
366 return mtd->parent;
367 }
368
mtd_has_partitions(const struct mtd_info * mtd)369 static inline bool mtd_has_partitions(const struct mtd_info *mtd)
370 {
371 return !list_empty(&mtd->partitions);
372 }
373
374 bool mtd_partitions_used(struct mtd_info *master);
375
376 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
377 struct mtd_oob_region *oobecc);
378 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
379 int *section,
380 struct mtd_oob_region *oobregion);
381 int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
382 const u8 *oobbuf, int start, int nbytes);
383 int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
384 u8 *oobbuf, int start, int nbytes);
385 int mtd_ooblayout_free(struct mtd_info *mtd, int section,
386 struct mtd_oob_region *oobfree);
387 int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
388 const u8 *oobbuf, int start, int nbytes);
389 int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
390 u8 *oobbuf, int start, int nbytes);
391 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
392 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
393
mtd_set_ooblayout(struct mtd_info * mtd,const struct mtd_ooblayout_ops * ooblayout)394 static inline void mtd_set_ooblayout(struct mtd_info *mtd,
395 const struct mtd_ooblayout_ops *ooblayout)
396 {
397 mtd->ooblayout = ooblayout;
398 }
399
mtd_oobavail(struct mtd_info * mtd,struct mtd_oob_ops * ops)400 static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops)
401 {
402 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize;
403 }
404
405 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
406 #ifndef __UBOOT__
407 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
408 void **virt, resource_size_t *phys);
409 int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
410 #endif
411 unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, unsigned long len,
412 unsigned long offset, unsigned long flags);
413 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
414 u_char *buf);
415 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
416 const u_char *buf);
417 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
418 const u_char *buf);
419
420 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
421 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
422
423 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
424 struct otp_info *buf);
425 int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
426 size_t *retlen, u_char *buf);
427 int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
428 struct otp_info *buf);
429 int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
430 size_t *retlen, u_char *buf);
431 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
432 size_t *retlen, u_char *buf);
433 int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
434
435 #ifndef __UBOOT__
436 int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
437 unsigned long count, loff_t to, size_t *retlen);
438 #endif
439
mtd_sync(struct mtd_info * mtd)440 static inline void mtd_sync(struct mtd_info *mtd)
441 {
442 if (mtd->_sync)
443 mtd->_sync(mtd);
444 }
445
446 int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
447 int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
448 int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
449 int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs);
450 int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
451 int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);
452
453 #ifndef __UBOOT__
mtd_suspend(struct mtd_info * mtd)454 static inline int mtd_suspend(struct mtd_info *mtd)
455 {
456 return mtd->_suspend ? mtd->_suspend(mtd) : 0;
457 }
458
mtd_resume(struct mtd_info * mtd)459 static inline void mtd_resume(struct mtd_info *mtd)
460 {
461 if (mtd->_resume)
462 mtd->_resume(mtd);
463 }
464 #endif
465
mtd_div_by_eb(uint64_t sz,struct mtd_info * mtd)466 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
467 {
468 if (mtd->erasesize_shift)
469 return sz >> mtd->erasesize_shift;
470 do_div(sz, mtd->erasesize);
471 return sz;
472 }
473
mtd_mod_by_eb(uint64_t sz,struct mtd_info * mtd)474 static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
475 {
476 if (mtd->erasesize_shift)
477 return sz & mtd->erasesize_mask;
478 return do_div(sz, mtd->erasesize);
479 }
480
mtd_div_by_ws(uint64_t sz,struct mtd_info * mtd)481 static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
482 {
483 if (mtd->writesize_shift)
484 return sz >> mtd->writesize_shift;
485 do_div(sz, mtd->writesize);
486 return sz;
487 }
488
mtd_mod_by_ws(uint64_t sz,struct mtd_info * mtd)489 static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
490 {
491 if (mtd->writesize_shift)
492 return sz & mtd->writesize_mask;
493 return do_div(sz, mtd->writesize);
494 }
495
mtd_has_oob(const struct mtd_info * mtd)496 static inline int mtd_has_oob(const struct mtd_info *mtd)
497 {
498 return mtd->_read_oob && mtd->_write_oob;
499 }
500
mtd_type_is_nand(const struct mtd_info * mtd)501 static inline int mtd_type_is_nand(const struct mtd_info *mtd)
502 {
503 return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
504 }
505
mtd_can_have_bb(const struct mtd_info * mtd)506 static inline int mtd_can_have_bb(const struct mtd_info *mtd)
507 {
508 return !!mtd->_block_isbad;
509 }
510
511 /* Kernel-side ioctl definitions */
512
513 struct mtd_partition;
514 struct mtd_part_parser_data;
515
516 extern int mtd_device_parse_register(struct mtd_info *mtd,
517 const char * const *part_probe_types,
518 struct mtd_part_parser_data *parser_data,
519 const struct mtd_partition *defparts,
520 int defnr_parts);
521 #define mtd_device_register(master, parts, nr_parts) \
522 mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
523 extern int mtd_device_unregister(struct mtd_info *master);
524 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
525 extern int __get_mtd_device(struct mtd_info *mtd);
526 extern void __put_mtd_device(struct mtd_info *mtd);
527 extern struct mtd_info *get_mtd_device_nm(const char *name);
528 extern void put_mtd_device(struct mtd_info *mtd);
529
530
531 #ifndef __UBOOT__
532 struct mtd_notifier {
533 void (*add)(struct mtd_info *mtd);
534 void (*remove)(struct mtd_info *mtd);
535 struct list_head list;
536 };
537
538
539 extern void register_mtd_user (struct mtd_notifier *new);
540 extern int unregister_mtd_user (struct mtd_notifier *old);
541 #endif
542 void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
543
544 #ifdef CONFIG_MTD_PARTITIONS
545 void mtd_erase_callback(struct erase_info *instr);
546 #else
mtd_erase_callback(struct erase_info * instr)547 static inline void mtd_erase_callback(struct erase_info *instr)
548 {
549 if (instr->callback)
550 instr->callback(instr);
551 }
552 #endif
553
mtd_is_bitflip(int err)554 static inline int mtd_is_bitflip(int err) {
555 return err == -EUCLEAN;
556 }
557
mtd_is_eccerr(int err)558 static inline int mtd_is_eccerr(int err) {
559 return err == -EBADMSG;
560 }
561
mtd_is_bitflip_or_eccerr(int err)562 static inline int mtd_is_bitflip_or_eccerr(int err) {
563 return mtd_is_bitflip(err) || mtd_is_eccerr(err);
564 }
565
566 unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
567
568 #ifdef __UBOOT__
569 /* drivers/mtd/mtdcore.h */
570 int add_mtd_device(struct mtd_info *mtd);
571 int del_mtd_device(struct mtd_info *mtd);
572
573 #ifdef CONFIG_MTD_PARTITIONS
574 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
575 int del_mtd_partitions(struct mtd_info *);
576 #else
add_mtd_partitions(struct mtd_info * mtd,const struct mtd_partition * parts,int nparts)577 static inline int add_mtd_partitions(struct mtd_info *mtd,
578 const struct mtd_partition *parts,
579 int nparts)
580 {
581 return 0;
582 }
583
del_mtd_partitions(struct mtd_info * mtd)584 static inline int del_mtd_partitions(struct mtd_info *mtd)
585 {
586 return 0;
587 }
588 #endif
589
590 struct mtd_info *__mtd_next_device(int i);
591 #define mtd_for_each_device(mtd) \
592 for ((mtd) = __mtd_next_device(0); \
593 (mtd) != NULL; \
594 (mtd) = __mtd_next_device(mtd->index + 1))
595
596 int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
597 loff_t *maxsize, int devtype, uint64_t chipsize);
598 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
599 loff_t *size, loff_t *maxsize, int devtype,
600 uint64_t chipsize);
601
602 /* drivers/mtd/mtdcore.c */
603 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
604 const uint64_t length, uint64_t *len_incl_bad,
605 int *truncated);
606 bool mtd_dev_list_updated(void);
607
608 /* drivers/mtd/mtd_uboot.c */
609 int mtd_search_alternate_name(const char *mtdname, char *altname,
610 unsigned int max_len);
611
612 #endif
613 #endif /* __MTD_MTD_H__ */
614