aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd/mtd.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mtd/mtd.h')
-rw-r--r--include/linux/mtd/mtd.h82
1 files changed, 32 insertions, 50 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 37be05bbfbc8..9f5b312af783 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -32,17 +32,19 @@
32#define MTD_CHAR_MAJOR 90 32#define MTD_CHAR_MAJOR 90
33#define MTD_BLOCK_MAJOR 31 33#define MTD_BLOCK_MAJOR 31
34 34
35#define MTD_ERASE_PENDING 0x01 35#define MTD_ERASE_PENDING 0x01
36#define MTD_ERASING 0x02 36#define MTD_ERASING 0x02
37#define MTD_ERASE_SUSPEND 0x04 37#define MTD_ERASE_SUSPEND 0x04
38#define MTD_ERASE_DONE 0x08 38#define MTD_ERASE_DONE 0x08
39#define MTD_ERASE_FAILED 0x10 39#define MTD_ERASE_FAILED 0x10
40 40
41#define MTD_FAIL_ADDR_UNKNOWN -1LL 41#define MTD_FAIL_ADDR_UNKNOWN -1LL
42 42
43/* If the erase fails, fail_addr might indicate exactly which block failed. If 43/*
44 fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not 44 * If the erase fails, fail_addr might indicate exactly which block failed. If
45 specific to any particular block. */ 45 * fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level
46 * or was not specific to any particular block.
47 */
46struct erase_info { 48struct erase_info {
47 struct mtd_info *mtd; 49 struct mtd_info *mtd;
48 uint64_t addr; 50 uint64_t addr;
@@ -59,26 +61,12 @@ struct erase_info {
59}; 61};
60 62
61struct mtd_erase_region_info { 63struct mtd_erase_region_info {
62 uint64_t offset; /* At which this region starts, from the beginning of the MTD */ 64 uint64_t offset; /* At which this region starts, from the beginning of the MTD */
63 uint32_t erasesize; /* For this region */ 65 uint32_t erasesize; /* For this region */
64 uint32_t numblocks; /* Number of blocks of erasesize in this region */ 66 uint32_t numblocks; /* Number of blocks of erasesize in this region */
65 unsigned long *lockmap; /* If keeping bitmap of locks */ 67 unsigned long *lockmap; /* If keeping bitmap of locks */
66}; 68};
67 69
68/*
69 * oob operation modes
70 *
71 * MTD_OOB_PLACE: oob data are placed at the given offset
72 * MTD_OOB_AUTO: oob data are automatically placed at the free areas
73 * which are defined by the ecclayout
74 * MTD_OOB_RAW: mode to read oob and data without doing ECC checking
75 */
76typedef enum {
77 MTD_OOB_PLACE,
78 MTD_OOB_AUTO,
79 MTD_OOB_RAW,
80} mtd_oob_mode_t;
81
82/** 70/**
83 * struct mtd_oob_ops - oob operation operands 71 * struct mtd_oob_ops - oob operation operands
84 * @mode: operation mode 72 * @mode: operation mode
@@ -90,7 +78,7 @@ typedef enum {
90 * @ooblen: number of oob bytes to write/read 78 * @ooblen: number of oob bytes to write/read
91 * @oobretlen: number of oob bytes written/read 79 * @oobretlen: number of oob bytes written/read
92 * @ooboffs: offset of oob data in the oob area (only relevant when 80 * @ooboffs: offset of oob data in the oob area (only relevant when
93 * mode = MTD_OOB_PLACE) 81 * mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
94 * @datbuf: data buffer - if NULL only oob data are read/written 82 * @datbuf: data buffer - if NULL only oob data are read/written
95 * @oobbuf: oob data buffer 83 * @oobbuf: oob data buffer
96 * 84 *
@@ -99,7 +87,7 @@ typedef enum {
99 * OOB area. 87 * OOB area.
100 */ 88 */
101struct mtd_oob_ops { 89struct mtd_oob_ops {
102 mtd_oob_mode_t mode; 90 unsigned int mode;
103 size_t len; 91 size_t len;
104 size_t retlen; 92 size_t retlen;
105 size_t ooblen; 93 size_t ooblen;
@@ -173,7 +161,7 @@ struct mtd_info {
173 const char *name; 161 const char *name;
174 int index; 162 int index;
175 163
176 /* ecc layout structure pointer - read only ! */ 164 /* ECC layout structure pointer - read only! */
177 struct nand_ecclayout *ecclayout; 165 struct nand_ecclayout *ecclayout;
178 166
179 /* Data for variable erase regions. If numeraseregions is zero, 167 /* Data for variable erase regions. If numeraseregions is zero,
@@ -324,10 +312,15 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
324 /* Kernel-side ioctl definitions */ 312 /* Kernel-side ioctl definitions */
325 313
326struct mtd_partition; 314struct mtd_partition;
327 315struct mtd_part_parser_data;
328extern int mtd_device_register(struct mtd_info *master, 316
329 const struct mtd_partition *parts, 317extern int mtd_device_parse_register(struct mtd_info *mtd,
330 int nr_parts); 318 const char **part_probe_types,
319 struct mtd_part_parser_data *parser_data,
320 const struct mtd_partition *defparts,
321 int defnr_parts);
322#define mtd_device_register(master, parts, nr_parts) \
323 mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
331extern int mtd_device_unregister(struct mtd_info *master); 324extern int mtd_device_unregister(struct mtd_info *master);
332extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num); 325extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
333extern int __get_mtd_device(struct mtd_info *mtd); 326extern int __get_mtd_device(struct mtd_info *mtd);
@@ -356,27 +349,16 @@ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
356 349
357void mtd_erase_callback(struct erase_info *instr); 350void mtd_erase_callback(struct erase_info *instr);
358 351
359/* 352static inline int mtd_is_bitflip(int err) {
360 * Debugging macro and defines 353 return err == -EUCLEAN;
361 */ 354}
362#define MTD_DEBUG_LEVEL0 (0) /* Quiet */ 355
363#define MTD_DEBUG_LEVEL1 (1) /* Audible */ 356static inline int mtd_is_eccerr(int err) {
364#define MTD_DEBUG_LEVEL2 (2) /* Loud */ 357 return err == -EBADMSG;
365#define MTD_DEBUG_LEVEL3 (3) /* Noisy */ 358}
366 359
367#ifdef CONFIG_MTD_DEBUG 360static inline int mtd_is_bitflip_or_eccerr(int err) {
368#define DEBUG(n, args...) \ 361 return mtd_is_bitflip(err) || mtd_is_eccerr(err);
369 do { \ 362}
370 if (n <= CONFIG_MTD_DEBUG_VERBOSE) \
371 printk(KERN_INFO args); \
372 } while(0)
373#else /* CONFIG_MTD_DEBUG */
374#define DEBUG(n, args...) \
375 do { \
376 if (0) \
377 printk(KERN_INFO args); \
378 } while(0)
379
380#endif /* CONFIG_MTD_DEBUG */
381 363
382#endif /* __MTD_MTD_H__ */ 364#endif /* __MTD_MTD_H__ */