Commit 85d5b70d8a0681a362d075bf0d19b4ee8c6767ee
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Merge tag 'upstream-3.8-rc1' of git://git.infradead.org/linux-ubi
Pull UBI update from Artem Bityutskiy: "Nothing exciting, just clean-ups and nicification. Oh, and one small optimization which makes UBI to use less RAM." * tag 'upstream-3.8-rc1' of git://git.infradead.org/linux-ubi: UBI: embed ubi_debug_info field in ubi_device struct UBI: introduce helpers dbg_chk_{io, gen} UBI: replace memcpy with struct assignment UBI: remove spurious comment UBI: gluebi: rename misleading variables UBI: do not allocate the memory unnecessarily UBI: use list_move_tail instead of list_del/list_add_tail
Showing 12 changed files Side-by-side Diff
drivers/mtd/ubi/attach.c
... | ... | @@ -322,7 +322,6 @@ |
322 | 322 | int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb, |
323 | 323 | int pnum, const struct ubi_vid_hdr *vid_hdr) |
324 | 324 | { |
325 | - void *buf; | |
326 | 325 | int len, err, second_is_newer, bitflips = 0, corrupted = 0; |
327 | 326 | uint32_t data_crc, crc; |
328 | 327 | struct ubi_vid_hdr *vh = NULL; |
329 | 328 | |
330 | 329 | |
331 | 330 | |
... | ... | @@ -393,18 +392,14 @@ |
393 | 392 | /* Read the data of the copy and check the CRC */ |
394 | 393 | |
395 | 394 | len = be32_to_cpu(vid_hdr->data_size); |
396 | - buf = vmalloc(len); | |
397 | - if (!buf) { | |
398 | - err = -ENOMEM; | |
399 | - goto out_free_vidh; | |
400 | - } | |
401 | 395 | |
402 | - err = ubi_io_read_data(ubi, buf, pnum, 0, len); | |
396 | + mutex_lock(&ubi->buf_mutex); | |
397 | + err = ubi_io_read_data(ubi, ubi->peb_buf, pnum, 0, len); | |
403 | 398 | if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err)) |
404 | - goto out_free_buf; | |
399 | + goto out_unlock; | |
405 | 400 | |
406 | 401 | data_crc = be32_to_cpu(vid_hdr->data_crc); |
407 | - crc = crc32(UBI_CRC32_INIT, buf, len); | |
402 | + crc = crc32(UBI_CRC32_INIT, ubi->peb_buf, len); | |
408 | 403 | if (crc != data_crc) { |
409 | 404 | dbg_bld("PEB %d CRC error: calculated %#08x, must be %#08x", |
410 | 405 | pnum, crc, data_crc); |
411 | 406 | |
... | ... | @@ -415,8 +410,8 @@ |
415 | 410 | dbg_bld("PEB %d CRC is OK", pnum); |
416 | 411 | bitflips = !!err; |
417 | 412 | } |
413 | + mutex_unlock(&ubi->buf_mutex); | |
418 | 414 | |
419 | - vfree(buf); | |
420 | 415 | ubi_free_vid_hdr(ubi, vh); |
421 | 416 | |
422 | 417 | if (second_is_newer) |
... | ... | @@ -426,8 +421,8 @@ |
426 | 421 | |
427 | 422 | return second_is_newer | (bitflips << 1) | (corrupted << 2); |
428 | 423 | |
429 | -out_free_buf: | |
430 | - vfree(buf); | |
424 | +out_unlock: | |
425 | + mutex_unlock(&ubi->buf_mutex); | |
431 | 426 | out_free_vidh: |
432 | 427 | ubi_free_vid_hdr(ubi, vh); |
433 | 428 | return err; |
... | ... | @@ -1453,7 +1448,7 @@ |
1453 | 1448 | goto out_wl; |
1454 | 1449 | |
1455 | 1450 | #ifdef CONFIG_MTD_UBI_FASTMAP |
1456 | - if (ubi->fm && ubi->dbg->chk_gen) { | |
1451 | + if (ubi->fm && ubi_dbg_chk_gen(ubi)) { | |
1457 | 1452 | struct ubi_attach_info *scan_ai; |
1458 | 1453 | |
1459 | 1454 | scan_ai = alloc_ai("ubi_ckh_aeb_slab_cache"); |
... | ... | @@ -1503,7 +1498,7 @@ |
1503 | 1498 | struct ubi_ainf_peb *aeb, *last_aeb; |
1504 | 1499 | uint8_t *buf; |
1505 | 1500 | |
1506 | - if (!ubi->dbg->chk_gen) | |
1501 | + if (!ubi_dbg_chk_gen(ubi)) | |
1507 | 1502 | return 0; |
1508 | 1503 | |
1509 | 1504 | /* |
drivers/mtd/ubi/build.c
... | ... | @@ -825,8 +825,7 @@ |
825 | 825 | * No available PEBs to re-size the volume, clear the flag on |
826 | 826 | * flash and exit. |
827 | 827 | */ |
828 | - memcpy(&vtbl_rec, &ubi->vtbl[vol_id], | |
829 | - sizeof(struct ubi_vtbl_record)); | |
828 | + vtbl_rec = ubi->vtbl[vol_id]; | |
830 | 829 | err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); |
831 | 830 | if (err) |
832 | 831 | ubi_err("cannot clean auto-resize flag for volume %d", |
833 | 832 | |
... | ... | @@ -986,14 +985,10 @@ |
986 | 985 | if (!ubi->fm_buf) |
987 | 986 | goto out_free; |
988 | 987 | #endif |
989 | - err = ubi_debugging_init_dev(ubi); | |
990 | - if (err) | |
991 | - goto out_free; | |
992 | - | |
993 | 988 | err = ubi_attach(ubi, 0); |
994 | 989 | if (err) { |
995 | 990 | ubi_err("failed to attach mtd%d, error %d", mtd->index, err); |
996 | - goto out_debugging; | |
991 | + goto out_free; | |
997 | 992 | } |
998 | 993 | |
999 | 994 | if (ubi->autoresize_vol_id != -1) { |
... | ... | @@ -1060,8 +1055,6 @@ |
1060 | 1055 | ubi_wl_close(ubi); |
1061 | 1056 | ubi_free_internal_volumes(ubi); |
1062 | 1057 | vfree(ubi->vtbl); |
1063 | -out_debugging: | |
1064 | - ubi_debugging_exit_dev(ubi); | |
1065 | 1058 | out_free: |
1066 | 1059 | vfree(ubi->peb_buf); |
1067 | 1060 | vfree(ubi->fm_buf); |
... | ... | @@ -1139,7 +1132,6 @@ |
1139 | 1132 | ubi_free_internal_volumes(ubi); |
1140 | 1133 | vfree(ubi->vtbl); |
1141 | 1134 | put_mtd_device(ubi->mtd); |
1142 | - ubi_debugging_exit_dev(ubi); | |
1143 | 1135 | vfree(ubi->peb_buf); |
1144 | 1136 | vfree(ubi->fm_buf); |
1145 | 1137 | ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); |
drivers/mtd/ubi/debug.c
... | ... | @@ -217,32 +217,6 @@ |
217 | 217 | pr_err("\t1st 16 characters of name: %s\n", nm); |
218 | 218 | } |
219 | 219 | |
220 | -/** | |
221 | - * ubi_debugging_init_dev - initialize debugging for an UBI device. | |
222 | - * @ubi: UBI device description object | |
223 | - * | |
224 | - * This function initializes debugging-related data for UBI device @ubi. | |
225 | - * Returns zero in case of success and a negative error code in case of | |
226 | - * failure. | |
227 | - */ | |
228 | -int ubi_debugging_init_dev(struct ubi_device *ubi) | |
229 | -{ | |
230 | - ubi->dbg = kzalloc(sizeof(struct ubi_debug_info), GFP_KERNEL); | |
231 | - if (!ubi->dbg) | |
232 | - return -ENOMEM; | |
233 | - | |
234 | - return 0; | |
235 | -} | |
236 | - | |
237 | -/** | |
238 | - * ubi_debugging_exit_dev - free debugging data for an UBI device. | |
239 | - * @ubi: UBI device description object | |
240 | - */ | |
241 | -void ubi_debugging_exit_dev(struct ubi_device *ubi) | |
242 | -{ | |
243 | - kfree(ubi->dbg); | |
244 | -} | |
245 | - | |
246 | 220 | /* |
247 | 221 | * Root directory for UBI stuff in debugfs. Contains sub-directories which |
248 | 222 | * contain the stuff specific to particular UBI devices. |
... | ... | @@ -295,7 +269,7 @@ |
295 | 269 | ubi = ubi_get_device(ubi_num); |
296 | 270 | if (!ubi) |
297 | 271 | return -ENODEV; |
298 | - d = ubi->dbg; | |
272 | + d = &ubi->dbg; | |
299 | 273 | |
300 | 274 | if (dent == d->dfs_chk_gen) |
301 | 275 | val = d->chk_gen; |
... | ... | @@ -341,7 +315,7 @@ |
341 | 315 | ubi = ubi_get_device(ubi_num); |
342 | 316 | if (!ubi) |
343 | 317 | return -ENODEV; |
344 | - d = ubi->dbg; | |
318 | + d = &ubi->dbg; | |
345 | 319 | |
346 | 320 | buf_size = min_t(size_t, count, (sizeof(buf) - 1)); |
347 | 321 | if (copy_from_user(buf, user_buf, buf_size)) { |
... | ... | @@ -398,7 +372,7 @@ |
398 | 372 | unsigned long ubi_num = ubi->ubi_num; |
399 | 373 | const char *fname; |
400 | 374 | struct dentry *dent; |
401 | - struct ubi_debug_info *d = ubi->dbg; | |
375 | + struct ubi_debug_info *d = &ubi->dbg; | |
402 | 376 | |
403 | 377 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) |
404 | 378 | return 0; |
... | ... | @@ -471,6 +445,6 @@ |
471 | 445 | void ubi_debugfs_exit_dev(struct ubi_device *ubi) |
472 | 446 | { |
473 | 447 | if (IS_ENABLED(CONFIG_DEBUG_FS)) |
474 | - debugfs_remove_recursive(ubi->dbg->dfs_dir); | |
448 | + debugfs_remove_recursive(ubi->dbg.dfs_dir); | |
475 | 449 | } |
drivers/mtd/ubi/debug.h
... | ... | @@ -60,52 +60,12 @@ |
60 | 60 | void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); |
61 | 61 | int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, |
62 | 62 | int len); |
63 | -int ubi_debugging_init_dev(struct ubi_device *ubi); | |
64 | -void ubi_debugging_exit_dev(struct ubi_device *ubi); | |
65 | 63 | int ubi_debugfs_init(void); |
66 | 64 | void ubi_debugfs_exit(void); |
67 | 65 | int ubi_debugfs_init_dev(struct ubi_device *ubi); |
68 | 66 | void ubi_debugfs_exit_dev(struct ubi_device *ubi); |
69 | 67 | |
70 | -/* | |
71 | - * The UBI debugfs directory name pattern and maximum name length (3 for "ubi" | |
72 | - * + 2 for the number plus 1 for the trailing zero byte. | |
73 | - */ | |
74 | -#define UBI_DFS_DIR_NAME "ubi%d" | |
75 | -#define UBI_DFS_DIR_LEN (3 + 2 + 1) | |
76 | - | |
77 | 68 | /** |
78 | - * struct ubi_debug_info - debugging information for an UBI device. | |
79 | - * | |
80 | - * @chk_gen: if UBI general extra checks are enabled | |
81 | - * @chk_io: if UBI I/O extra checks are enabled | |
82 | - * @disable_bgt: disable the background task for testing purposes | |
83 | - * @emulate_bitflips: emulate bit-flips for testing purposes | |
84 | - * @emulate_io_failures: emulate write/erase failures for testing purposes | |
85 | - * @dfs_dir_name: name of debugfs directory containing files of this UBI device | |
86 | - * @dfs_dir: direntry object of the UBI device debugfs directory | |
87 | - * @dfs_chk_gen: debugfs knob to enable UBI general extra checks | |
88 | - * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks | |
89 | - * @dfs_disable_bgt: debugfs knob to disable the background task | |
90 | - * @dfs_emulate_bitflips: debugfs knob to emulate bit-flips | |
91 | - * @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures | |
92 | - */ | |
93 | -struct ubi_debug_info { | |
94 | - unsigned int chk_gen:1; | |
95 | - unsigned int chk_io:1; | |
96 | - unsigned int disable_bgt:1; | |
97 | - unsigned int emulate_bitflips:1; | |
98 | - unsigned int emulate_io_failures:1; | |
99 | - char dfs_dir_name[UBI_DFS_DIR_LEN + 1]; | |
100 | - struct dentry *dfs_dir; | |
101 | - struct dentry *dfs_chk_gen; | |
102 | - struct dentry *dfs_chk_io; | |
103 | - struct dentry *dfs_disable_bgt; | |
104 | - struct dentry *dfs_emulate_bitflips; | |
105 | - struct dentry *dfs_emulate_io_failures; | |
106 | -}; | |
107 | - | |
108 | -/** | |
109 | 69 | * ubi_dbg_is_bgt_disabled - if the background thread is disabled. |
110 | 70 | * @ubi: UBI device description object |
111 | 71 | * |
... | ... | @@ -114,7 +74,7 @@ |
114 | 74 | */ |
115 | 75 | static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) |
116 | 76 | { |
117 | - return ubi->dbg->disable_bgt; | |
77 | + return ubi->dbg.disable_bgt; | |
118 | 78 | } |
119 | 79 | |
120 | 80 | /** |
... | ... | @@ -125,7 +85,7 @@ |
125 | 85 | */ |
126 | 86 | static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) |
127 | 87 | { |
128 | - if (ubi->dbg->emulate_bitflips) | |
88 | + if (ubi->dbg.emulate_bitflips) | |
129 | 89 | return !(random32() % 200); |
130 | 90 | return 0; |
131 | 91 | } |
... | ... | @@ -139,7 +99,7 @@ |
139 | 99 | */ |
140 | 100 | static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) |
141 | 101 | { |
142 | - if (ubi->dbg->emulate_io_failures) | |
102 | + if (ubi->dbg.emulate_io_failures) | |
143 | 103 | return !(random32() % 500); |
144 | 104 | return 0; |
145 | 105 | } |
146 | 106 | |
... | ... | @@ -153,10 +113,19 @@ |
153 | 113 | */ |
154 | 114 | static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) |
155 | 115 | { |
156 | - if (ubi->dbg->emulate_io_failures) | |
116 | + if (ubi->dbg.emulate_io_failures) | |
157 | 117 | return !(random32() % 400); |
158 | 118 | return 0; |
159 | 119 | } |
160 | 120 | |
121 | +static inline int ubi_dbg_chk_io(const struct ubi_device *ubi) | |
122 | +{ | |
123 | + return ubi->dbg.chk_io; | |
124 | +} | |
125 | + | |
126 | +static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi) | |
127 | +{ | |
128 | + return ubi->dbg.chk_gen; | |
129 | +} | |
161 | 130 | #endif /* !__UBI_DEBUG_H__ */ |
drivers/mtd/ubi/fastmap.c
... | ... | @@ -814,10 +814,8 @@ |
814 | 814 | if (max_sqnum > ai->max_sqnum) |
815 | 815 | ai->max_sqnum = max_sqnum; |
816 | 816 | |
817 | - list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) { | |
818 | - list_del(&tmp_aeb->u.list); | |
819 | - list_add_tail(&tmp_aeb->u.list, &ai->free); | |
820 | - } | |
817 | + list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) | |
818 | + list_move_tail(&tmp_aeb->u.list, &ai->free); | |
821 | 819 | |
822 | 820 | /* |
823 | 821 | * If fastmap is leaking PEBs (must not happen), raise a |
drivers/mtd/ubi/gluebi.c
... | ... | @@ -171,17 +171,17 @@ |
171 | 171 | static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, |
172 | 172 | size_t *retlen, unsigned char *buf) |
173 | 173 | { |
174 | - int err = 0, lnum, offs, total_read; | |
174 | + int err = 0, lnum, offs, bytes_left; | |
175 | 175 | struct gluebi_device *gluebi; |
176 | 176 | |
177 | 177 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
178 | 178 | lnum = div_u64_rem(from, mtd->erasesize, &offs); |
179 | - total_read = len; | |
180 | - while (total_read) { | |
179 | + bytes_left = len; | |
180 | + while (bytes_left) { | |
181 | 181 | size_t to_read = mtd->erasesize - offs; |
182 | 182 | |
183 | - if (to_read > total_read) | |
184 | - to_read = total_read; | |
183 | + if (to_read > bytes_left) | |
184 | + to_read = bytes_left; | |
185 | 185 | |
186 | 186 | err = ubi_read(gluebi->desc, lnum, buf, offs, to_read); |
187 | 187 | if (err) |
188 | 188 | |
... | ... | @@ -189,11 +189,11 @@ |
189 | 189 | |
190 | 190 | lnum += 1; |
191 | 191 | offs = 0; |
192 | - total_read -= to_read; | |
192 | + bytes_left -= to_read; | |
193 | 193 | buf += to_read; |
194 | 194 | } |
195 | 195 | |
196 | - *retlen = len - total_read; | |
196 | + *retlen = len - bytes_left; | |
197 | 197 | return err; |
198 | 198 | } |
199 | 199 | |
... | ... | @@ -211,7 +211,7 @@ |
211 | 211 | static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, |
212 | 212 | size_t *retlen, const u_char *buf) |
213 | 213 | { |
214 | - int err = 0, lnum, offs, total_written; | |
214 | + int err = 0, lnum, offs, bytes_left; | |
215 | 215 | struct gluebi_device *gluebi; |
216 | 216 | |
217 | 217 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
218 | 218 | |
... | ... | @@ -220,12 +220,12 @@ |
220 | 220 | if (len % mtd->writesize || offs % mtd->writesize) |
221 | 221 | return -EINVAL; |
222 | 222 | |
223 | - total_written = len; | |
224 | - while (total_written) { | |
223 | + bytes_left = len; | |
224 | + while (bytes_left) { | |
225 | 225 | size_t to_write = mtd->erasesize - offs; |
226 | 226 | |
227 | - if (to_write > total_written) | |
228 | - to_write = total_written; | |
227 | + if (to_write > bytes_left) | |
228 | + to_write = bytes_left; | |
229 | 229 | |
230 | 230 | err = ubi_leb_write(gluebi->desc, lnum, buf, offs, to_write); |
231 | 231 | if (err) |
232 | 232 | |
... | ... | @@ -233,11 +233,11 @@ |
233 | 233 | |
234 | 234 | lnum += 1; |
235 | 235 | offs = 0; |
236 | - total_written -= to_write; | |
236 | + bytes_left -= to_write; | |
237 | 237 | buf += to_write; |
238 | 238 | } |
239 | 239 | |
240 | - *retlen = len - total_written; | |
240 | + *retlen = len - bytes_left; | |
241 | 241 | return err; |
242 | 242 | } |
243 | 243 |
drivers/mtd/ubi/io.c
... | ... | @@ -1132,7 +1132,7 @@ |
1132 | 1132 | { |
1133 | 1133 | int err; |
1134 | 1134 | |
1135 | - if (!ubi->dbg->chk_io) | |
1135 | + if (!ubi_dbg_chk_io(ubi)) | |
1136 | 1136 | return 0; |
1137 | 1137 | |
1138 | 1138 | err = ubi_io_is_bad(ubi, pnum); |
... | ... | @@ -1159,7 +1159,7 @@ |
1159 | 1159 | int err; |
1160 | 1160 | uint32_t magic; |
1161 | 1161 | |
1162 | - if (!ubi->dbg->chk_io) | |
1162 | + if (!ubi_dbg_chk_io(ubi)) | |
1163 | 1163 | return 0; |
1164 | 1164 | |
1165 | 1165 | magic = be32_to_cpu(ec_hdr->magic); |
... | ... | @@ -1197,7 +1197,7 @@ |
1197 | 1197 | uint32_t crc, hdr_crc; |
1198 | 1198 | struct ubi_ec_hdr *ec_hdr; |
1199 | 1199 | |
1200 | - if (!ubi->dbg->chk_io) | |
1200 | + if (!ubi_dbg_chk_io(ubi)) | |
1201 | 1201 | return 0; |
1202 | 1202 | |
1203 | 1203 | ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); |
... | ... | @@ -1241,7 +1241,7 @@ |
1241 | 1241 | int err; |
1242 | 1242 | uint32_t magic; |
1243 | 1243 | |
1244 | - if (!ubi->dbg->chk_io) | |
1244 | + if (!ubi_dbg_chk_io(ubi)) | |
1245 | 1245 | return 0; |
1246 | 1246 | |
1247 | 1247 | magic = be32_to_cpu(vid_hdr->magic); |
... | ... | @@ -1282,7 +1282,7 @@ |
1282 | 1282 | struct ubi_vid_hdr *vid_hdr; |
1283 | 1283 | void *p; |
1284 | 1284 | |
1285 | - if (!ubi->dbg->chk_io) | |
1285 | + if (!ubi_dbg_chk_io(ubi)) | |
1286 | 1286 | return 0; |
1287 | 1287 | |
1288 | 1288 | vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); |
... | ... | @@ -1334,7 +1334,7 @@ |
1334 | 1334 | void *buf1; |
1335 | 1335 | loff_t addr = (loff_t)pnum * ubi->peb_size + offset; |
1336 | 1336 | |
1337 | - if (!ubi->dbg->chk_io) | |
1337 | + if (!ubi_dbg_chk_io(ubi)) | |
1338 | 1338 | return 0; |
1339 | 1339 | |
1340 | 1340 | buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); |
... | ... | @@ -1398,7 +1398,7 @@ |
1398 | 1398 | void *buf; |
1399 | 1399 | loff_t addr = (loff_t)pnum * ubi->peb_size + offset; |
1400 | 1400 | |
1401 | - if (!ubi->dbg->chk_io) | |
1401 | + if (!ubi_dbg_chk_io(ubi)) | |
1402 | 1402 | return 0; |
1403 | 1403 | |
1404 | 1404 | buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); |
drivers/mtd/ubi/ubi.h
... | ... | @@ -85,6 +85,13 @@ |
85 | 85 | #define UBI_UNKNOWN -1 |
86 | 86 | |
87 | 87 | /* |
88 | + * The UBI debugfs directory name pattern and maximum name length (3 for "ubi" | |
89 | + * + 2 for the number plus 1 for the trailing zero byte. | |
90 | + */ | |
91 | +#define UBI_DFS_DIR_NAME "ubi%d" | |
92 | +#define UBI_DFS_DIR_LEN (3 + 2 + 1) | |
93 | + | |
94 | +/* | |
88 | 95 | * Error codes returned by the I/O sub-system. |
89 | 96 | * |
90 | 97 | * UBI_IO_FF: the read region of flash contains only 0xFFs |
... | ... | @@ -342,6 +349,37 @@ |
342 | 349 | struct ubi_wl_entry; |
343 | 350 | |
344 | 351 | /** |
352 | + * struct ubi_debug_info - debugging information for an UBI device. | |
353 | + * | |
354 | + * @chk_gen: if UBI general extra checks are enabled | |
355 | + * @chk_io: if UBI I/O extra checks are enabled | |
356 | + * @disable_bgt: disable the background task for testing purposes | |
357 | + * @emulate_bitflips: emulate bit-flips for testing purposes | |
358 | + * @emulate_io_failures: emulate write/erase failures for testing purposes | |
359 | + * @dfs_dir_name: name of debugfs directory containing files of this UBI device | |
360 | + * @dfs_dir: direntry object of the UBI device debugfs directory | |
361 | + * @dfs_chk_gen: debugfs knob to enable UBI general extra checks | |
362 | + * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks | |
363 | + * @dfs_disable_bgt: debugfs knob to disable the background task | |
364 | + * @dfs_emulate_bitflips: debugfs knob to emulate bit-flips | |
365 | + * @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures | |
366 | + */ | |
367 | +struct ubi_debug_info { | |
368 | + unsigned int chk_gen:1; | |
369 | + unsigned int chk_io:1; | |
370 | + unsigned int disable_bgt:1; | |
371 | + unsigned int emulate_bitflips:1; | |
372 | + unsigned int emulate_io_failures:1; | |
373 | + char dfs_dir_name[UBI_DFS_DIR_LEN + 1]; | |
374 | + struct dentry *dfs_dir; | |
375 | + struct dentry *dfs_chk_gen; | |
376 | + struct dentry *dfs_chk_io; | |
377 | + struct dentry *dfs_disable_bgt; | |
378 | + struct dentry *dfs_emulate_bitflips; | |
379 | + struct dentry *dfs_emulate_io_failures; | |
380 | +}; | |
381 | + | |
382 | +/** | |
345 | 383 | * struct ubi_device - UBI device description structure |
346 | 384 | * @dev: UBI device object to use the the Linux device model |
347 | 385 | * @cdev: character device object to create character device |
... | ... | @@ -545,7 +583,7 @@ |
545 | 583 | struct mutex buf_mutex; |
546 | 584 | struct mutex ckvol_mutex; |
547 | 585 | |
548 | - struct ubi_debug_info *dbg; | |
586 | + struct ubi_debug_info dbg; | |
549 | 587 | }; |
550 | 588 | |
551 | 589 | /** |
drivers/mtd/ubi/upd.c
... | ... | @@ -64,8 +64,7 @@ |
64 | 64 | return 0; |
65 | 65 | } |
66 | 66 | |
67 | - memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id], | |
68 | - sizeof(struct ubi_vtbl_record)); | |
67 | + vtbl_rec = ubi->vtbl[vol->vol_id]; | |
69 | 68 | vtbl_rec.upd_marker = 1; |
70 | 69 | |
71 | 70 | mutex_lock(&ubi->device_mutex); |
... | ... | @@ -93,8 +92,7 @@ |
93 | 92 | |
94 | 93 | dbg_gen("clear update marker for volume %d", vol->vol_id); |
95 | 94 | |
96 | - memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id], | |
97 | - sizeof(struct ubi_vtbl_record)); | |
95 | + vtbl_rec = ubi->vtbl[vol->vol_id]; | |
98 | 96 | ubi_assert(vol->upd_marker && vtbl_rec.upd_marker); |
99 | 97 | vtbl_rec.upd_marker = 0; |
100 | 98 |
drivers/mtd/ubi/vmt.c
... | ... | @@ -535,7 +535,7 @@ |
535 | 535 | } |
536 | 536 | |
537 | 537 | /* Change volume table record */ |
538 | - memcpy(&vtbl_rec, &ubi->vtbl[vol_id], sizeof(struct ubi_vtbl_record)); | |
538 | + vtbl_rec = ubi->vtbl[vol_id]; | |
539 | 539 | vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs); |
540 | 540 | err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); |
541 | 541 | if (err) |
... | ... | @@ -847,7 +847,7 @@ |
847 | 847 | { |
848 | 848 | int i, err = 0; |
849 | 849 | |
850 | - if (!ubi->dbg->chk_gen) | |
850 | + if (!ubi_dbg_chk_gen(ubi)) | |
851 | 851 | return 0; |
852 | 852 | |
853 | 853 | for (i = 0; i < ubi->vtbl_slots; i++) { |
drivers/mtd/ubi/vtbl.c
drivers/mtd/ubi/wl.c
1 | 1 | /* |
2 | - * @ubi: UBI device description object | |
3 | 2 | * Copyright (c) International Business Machines Corp., 2006 |
4 | 3 | * |
5 | 4 | * This program is free software; you can redistribute it and/or modify |
... | ... | @@ -2050,7 +2049,7 @@ |
2050 | 2049 | long long read_ec; |
2051 | 2050 | struct ubi_ec_hdr *ec_hdr; |
2052 | 2051 | |
2053 | - if (!ubi->dbg->chk_gen) | |
2052 | + if (!ubi_dbg_chk_gen(ubi)) | |
2054 | 2053 | return 0; |
2055 | 2054 | |
2056 | 2055 | ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); |
... | ... | @@ -2090,7 +2089,7 @@ |
2090 | 2089 | static int self_check_in_wl_tree(const struct ubi_device *ubi, |
2091 | 2090 | struct ubi_wl_entry *e, struct rb_root *root) |
2092 | 2091 | { |
2093 | - if (!ubi->dbg->chk_gen) | |
2092 | + if (!ubi_dbg_chk_gen(ubi)) | |
2094 | 2093 | return 0; |
2095 | 2094 | |
2096 | 2095 | if (in_wl_tree(e, root)) |
... | ... | @@ -2116,7 +2115,7 @@ |
2116 | 2115 | struct ubi_wl_entry *p; |
2117 | 2116 | int i; |
2118 | 2117 | |
2119 | - if (!ubi->dbg->chk_gen) | |
2118 | + if (!ubi_dbg_chk_gen(ubi)) | |
2120 | 2119 | return 0; |
2121 | 2120 | |
2122 | 2121 | for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) |