From b36a261e8c0ab323d04db9cdd1f6bb4c273c4b32 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 14 May 2012 17:55:51 +0200 Subject: UBI: Kill data type hint We do not need this feature and to our shame it even was not working and there was a bug found very recently. -- Artem Bityutskiy Without the data type hint UBI2 (fastmap) will be easier to implement. Signed-off-by: Richard Weinberger Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 17cec0c01544..a6f4b13d8417 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -106,7 +106,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, return err; err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0, - ubi->vtbl_size, UBI_LONGTERM); + ubi->vtbl_size); if (err) return err; } @@ -158,7 +158,7 @@ int ubi_vtbl_rename_volumes(struct ubi_device *ubi, return err; err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0, - ubi->vtbl_size, UBI_LONGTERM); + ubi->vtbl_size); if (err) return err; } -- cgit v1.2.3-59-g8ed1b From 766381f049100db0763e1a930a7b9d16632aa49c Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:53:17 +0300 Subject: UBI: rename ubi_dbg_dump_vol_info I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vol_info()' to 'ubi_dump_vol_info()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 4 ++-- drivers/mtd/ubi/debug.h | 4 ++-- drivers/mtd/ubi/vmt.c | 2 +- drivers/mtd/ubi/vtbl.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index dce463d3c586..2d3dc2624b61 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -109,10 +109,10 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) #ifdef CONFIG_MTD_UBI_DEBUG /** - * ubi_dbg_dump_vol_info- dump volume information. + * ubi_dump_vol_info - dump volume information. * @vol: UBI volume description object */ -void ubi_dbg_dump_vol_info(const struct ubi_volume *vol) +void ubi_dump_vol_info(const struct ubi_volume *vol) { printk(KERN_DEBUG "Volume information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", vol->vol_id); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index b8672c947bb5..ca36f2db2b0e 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -60,7 +60,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); /* Initialization and build messages */ #define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__) -void ubi_dbg_dump_vol_info(const struct ubi_volume *vol); +void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv); void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type); @@ -194,7 +194,7 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) #define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) static inline void -ubi_dbg_dump_vol_info(const struct ubi_volume *vol) { return; } +ubi_dump_vol_info(const struct ubi_volume *vol) { return; } static inline void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } static inline void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) { return; } diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 863835f4aefe..906f972f950a 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -855,7 +855,7 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id) fail: ubi_err("paranoid check failed for volume %d", vol_id); if (vol) - ubi_dbg_dump_vol_info(vol); + ubi_dump_vol_info(vol); ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); dump_stack(); spin_unlock(&ubi->volumes_lock); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index a6f4b13d8417..7ef3de0ffbf7 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -701,7 +701,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad scanning information, error %d", err); ubi_dbg_dump_sv(sv); - ubi_dbg_dump_vol_info(vol); + ubi_dump_vol_info(vol); return -EINVAL; } -- cgit v1.2.3-59-g8ed1b From 1f021e1de56f79cb4575b14f9ebf1ffb9dc9db0b Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:56:50 +0300 Subject: UBI: rename ubi_dbg_dump_vtbl_record I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vtbl_record()' to 'ubi_dump_vtbl_record()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 4 ++-- drivers/mtd/ubi/debug.h | 4 ++-- drivers/mtd/ubi/vmt.c | 2 +- drivers/mtd/ubi/vtbl.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 2d3dc2624b61..9b16bcc1b172 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -139,11 +139,11 @@ void ubi_dump_vol_info(const struct ubi_volume *vol) } /** - * ubi_dbg_dump_vtbl_record - dump a &struct ubi_vtbl_record object. + * ubi_dump_vtbl_record - dump a &struct ubi_vtbl_record object. * @r: the object to dump * @idx: volume table index */ -void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) +void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { int name_len = be16_to_cpu(r->name_len); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index ca36f2db2b0e..9728da4444cc 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -61,7 +61,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); #define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__) void ubi_dump_vol_info(const struct ubi_volume *vol); -void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); +void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv); void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type); void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req); @@ -196,7 +196,7 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) static inline void ubi_dump_vol_info(const struct ubi_volume *vol) { return; } static inline void -ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } +ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } static inline void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) { return; } static inline void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type) { return; } diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 906f972f950a..a4b4c300a4e1 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -856,7 +856,7 @@ fail: ubi_err("paranoid check failed for volume %d", vol_id); if (vol) ubi_dump_vol_info(vol); - ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); + ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); dump_stack(); spin_unlock(&ubi->volumes_lock); return -EINVAL; diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 7ef3de0ffbf7..897502fba301 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -197,7 +197,7 @@ static int vtbl_check(const struct ubi_device *ubi, if (be32_to_cpu(vtbl[i].crc) != crc) { ubi_err("bad CRC at record %u: %#08x, not %#08x", i, crc, be32_to_cpu(vtbl[i].crc)); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[i], i); return 1; } @@ -277,8 +277,8 @@ static int vtbl_check(const struct ubi_device *ubi, !strncmp(vtbl[i].name, vtbl[n].name, len1)) { ubi_err("volumes %d and %d have the same name" " \"%s\"", i, n, vtbl[i].name); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); - ubi_dbg_dump_vtbl_record(&vtbl[n], n); + ubi_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[n], n); return -EINVAL; } } @@ -288,7 +288,7 @@ static int vtbl_check(const struct ubi_device *ubi, bad: ubi_err("volume table check failed: record %d, error %d", i, err); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[i], i); return -EINVAL; } -- cgit v1.2.3-59-g8ed1b From 614c74a75c60602f2a524c86650b576b14883fd5 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:59:36 +0300 Subject: UBI: rename ubi_dbg_dump_sv I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_sv()' to 'ubi_dump_sv()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 4 ++-- drivers/mtd/ubi/debug.h | 4 ++-- drivers/mtd/ubi/scan.c | 8 ++++---- drivers/mtd/ubi/vtbl.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 9b16bcc1b172..9ae8fff98f49 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -173,10 +173,10 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) } /** - * ubi_dbg_dump_sv - dump a &struct ubi_scan_volume object. + * ubi_dump_sv - dump a &struct ubi_scan_volume object. * @sv: the object to dump */ -void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) +void ubi_dump_sv(const struct ubi_scan_volume *sv) { printk(KERN_DEBUG "Volume scanning information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 9728da4444cc..5e3d4e88d7be 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -62,7 +62,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); -void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv); +void ubi_dump_sv(const struct ubi_scan_volume *sv); void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type); void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req); int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len); @@ -197,7 +197,7 @@ static inline void ubi_dump_vol_info(const struct ubi_volume *vol) { return; } static inline void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } -static inline void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) { return; } +static inline void ubi_dump_sv(const struct ubi_scan_volume *sv) { return; } static inline void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type) { return; } static inline void diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index c26b1add508d..23f7ad2d7089 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -231,7 +231,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, bad: ubi_err("inconsistent VID header at PEB %d", pnum); ubi_dump_vid_hdr(vid_hdr); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); return -EINVAL; } @@ -1584,17 +1584,17 @@ static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) bad_seb: ubi_err("bad scanning information about LEB %d", seb->lnum); ubi_dbg_dump_seb(seb, 0); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); goto out; bad_sv: ubi_err("bad scanning information about volume %d", sv->vol_id); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); goto out; bad_vid_hdr: ubi_err("bad scanning information about volume %d", sv->vol_id); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); ubi_dump_vid_hdr(vidh); out: diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 897502fba301..b37872cc5218 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -700,7 +700,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad scanning information, error %d", err); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); ubi_dump_vol_info(vol); return -EINVAL; } -- cgit v1.2.3-59-g8ed1b From aa44d1d35f3485e0acea0f22e41cb472d2c99858 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:09:08 +0300 Subject: UBI: remove Kconfig debugging option This patch kills the UBI debugging Kconfig option completely and makes all the debugging stuff to be always compiled-in. It was pain in the neck to maintain this useless option because all users I am aware of have debugging enabled anyway - how else will you diagnose errors otherwise? Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/Kconfig | 8 ------- drivers/mtd/ubi/debug.c | 4 ---- drivers/mtd/ubi/debug.h | 63 ------------------------------------------------- drivers/mtd/ubi/io.c | 12 ---------- drivers/mtd/ubi/scan.c | 8 ------- drivers/mtd/ubi/vmt.c | 7 ------ drivers/mtd/ubi/vtbl.c | 8 ------- drivers/mtd/ubi/wl.c | 10 -------- 8 files changed, 120 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 4dcc752a0c0b..738ee8dc16cd 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -52,12 +52,4 @@ config MTD_UBI_GLUEBI work on top of UBI. Do not enable this unless you use legacy software. -config MTD_UBI_DEBUG - bool "UBI debugging" - depends on SYSFS - select DEBUG_FS - select KALLSYMS - help - This option enables UBI debugging. - endif # MTD_UBI diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index bb7297ebf1c1..c6becde40314 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -106,8 +106,6 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) vid_hdr, UBI_VID_HDR_SIZE, 1); } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * ubi_dump_vol_info - dump volume information. * @vol: UBI volume description object @@ -474,5 +472,3 @@ void ubi_debugfs_exit_dev(struct ubi_device *ubi) { debugfs_remove_recursive(ubi->dbg->dfs_dir); } - -#endif /* CONFIG_MTD_UBI_DEBUG */ diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index c98d2c8d3abe..3e5b60f3fdf1 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -25,7 +25,6 @@ void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len); void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr); void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); -#ifdef CONFIG_MTD_UBI_DEBUG #include #define ubi_assert(expr) do { \ @@ -166,66 +165,4 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) return 0; } -#else - -/* Use "if (0)" to make compiler check arguments even if debugging is off */ -#define ubi_assert(expr) do { \ - if (0) { \ - printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ - __func__, __LINE__, current->pid); \ - } \ -} while (0) - -#define dbg_err(fmt, ...) do { \ - if (0) \ - ubi_err(fmt, ##__VA_ARGS__); \ -} while (0) - -#define ubi_dbg_msg(fmt, ...) do { \ - if (0) \ - printk(KERN_DEBUG fmt "\n", ##__VA_ARGS__); \ -} while (0) - -#define dbg_msg(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) -#define dbg_gen(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) -#define dbg_eba(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) -#define dbg_wl(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) -#define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) -#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) - -static inline void -ubi_dump_vol_info(const struct ubi_volume *vol) { return; } -static inline void -ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } -static inline void ubi_dump_sv(const struct ubi_scan_volume *sv) { return; } -static inline void ubi_dump_seb(const struct ubi_scan_leb *seb, - int type) { return; } -static inline void -ubi_dump_mkvol_req(const struct ubi_mkvol_req *req) { return; } -static inline void -ubi_dbg_print_hex_dump(const char *l, const char *ps, int pt, int r, - int g, const void *b, size_t len, bool a) { return; } -static inline int ubi_dbg_check_all_ff(struct ubi_device *ubi, - int pnum, int offset, - int len) { return 0; } -static inline int ubi_dbg_check_write(struct ubi_device *ubi, - const void *buf, int pnum, - int offset, int len) { return 0; } - -static inline int ubi_debugging_init_dev(struct ubi_device *ubi) { return 0; } -static inline void ubi_debugging_exit_dev(struct ubi_device *ubi) { return; } -static inline int ubi_debugfs_init(void) { return 0; } -static inline void ubi_debugfs_exit(void) { return; } -static inline int ubi_debugfs_init_dev(struct ubi_device *ubi) { return 0; } -static inline void ubi_debugfs_exit_dev(struct ubi_device *ubi) { return; } - -static inline int -ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) { return 0; } -static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) { return 0; } -static inline int -ubi_dbg_is_write_failure(const struct ubi_device *ubi) { return 0; } -static inline int -ubi_dbg_is_erase_failure(const struct ubi_device *ubi) { return 0; } - -#endif /* !CONFIG_MTD_UBI_DEBUG */ #endif /* !__UBI_DEBUG_H__ */ diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 19ee1a821557..c1628fc706c1 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -91,7 +91,6 @@ #include #include "ubi.h" -#ifdef CONFIG_MTD_UBI_DEBUG static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum); static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum); static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum, @@ -99,13 +98,6 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum, static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum); static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum, const struct ubi_vid_hdr *vid_hdr); -#else -#define paranoid_check_not_bad(ubi, pnum) 0 -#define paranoid_check_peb_ec_hdr(ubi, pnum) 0 -#define paranoid_check_ec_hdr(ubi, pnum, ec_hdr) 0 -#define paranoid_check_peb_vid_hdr(ubi, pnum) 0 -#define paranoid_check_vid_hdr(ubi, pnum, vid_hdr) 0 -#endif /** * ubi_io_read - read data from a physical eraseblock. @@ -1131,8 +1123,6 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, return err; } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_check_not_bad - ensure that a physical eraseblock is not bad. * @ubi: UBI device description object @@ -1447,5 +1437,3 @@ error: vfree(buf); return err; } - -#endif /* CONFIG_MTD_UBI_DEBUG */ diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index b09c8fa0c670..bcbfe498f415 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -88,11 +88,7 @@ #include #include "ubi.h" -#ifdef CONFIG_MTD_UBI_DEBUG static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); -#else -#define paranoid_check_si(ubi, si) 0 -#endif /* Temporary variables used during scanning */ static struct ubi_ec_hdr *ech; @@ -1329,8 +1325,6 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si) kfree(si); } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_check_si - check the scanning information. * @ubi: UBI device description object @@ -1601,5 +1595,3 @@ out: dump_stack(); return -EINVAL; } - -#endif /* CONFIG_MTD_UBI_DEBUG */ diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index a4b4c300a4e1..b38ab92094fd 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -29,11 +29,7 @@ #include #include "ubi.h" -#ifdef CONFIG_MTD_UBI_DEBUG static int paranoid_check_volumes(struct ubi_device *ubi); -#else -#define paranoid_check_volumes(ubi) 0 -#endif static ssize_t vol_attribute_show(struct device *dev, struct device_attribute *attr, char *buf); @@ -712,8 +708,6 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) volume_sysfs_close(vol); } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_check_volume - check volume information. * @ubi: UBI device description object @@ -883,4 +877,3 @@ static int paranoid_check_volumes(struct ubi_device *ubi) return err; } -#endif diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index b37872cc5218..277f1546cb9e 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -62,11 +62,7 @@ #include #include "ubi.h" -#ifdef CONFIG_MTD_UBI_DEBUG static void paranoid_vtbl_check(const struct ubi_device *ubi); -#else -#define paranoid_vtbl_check(ubi) -#endif /* Empty volume table record */ static struct ubi_vtbl_record empty_vtbl_record; @@ -858,8 +854,6 @@ out_free: return err; } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_vtbl_check - check volume table. * @ubi: UBI device description object @@ -874,5 +868,3 @@ static void paranoid_vtbl_check(const struct ubi_device *ubi) BUG(); } } - -#endif /* CONFIG_MTD_UBI_DEBUG */ diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 64ce9930dacb..f99dbd084838 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -155,18 +155,12 @@ struct ubi_work { int torture; }; -#ifdef CONFIG_MTD_UBI_DEBUG static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); static int paranoid_check_in_wl_tree(const struct ubi_device *ubi, struct ubi_wl_entry *e, struct rb_root *root); static int paranoid_check_in_pq(const struct ubi_device *ubi, struct ubi_wl_entry *e); -#else -#define paranoid_check_ec(ubi, pnum, ec) 0 -#define paranoid_check_in_wl_tree(ubi, e, root) -#define paranoid_check_in_pq(ubi, e) 0 -#endif /** * wl_tree_add - add a wear-leveling entry to a WL RB-tree. @@ -1526,8 +1520,6 @@ void ubi_wl_close(struct ubi_device *ubi) kfree(ubi->lookuptbl); } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_check_ec - make sure that the erase counter of a PEB is correct. * @ubi: UBI device description object @@ -1624,5 +1616,3 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi, dump_stack(); return -EINVAL; } - -#endif /* CONFIG_MTD_UBI_DEBUG */ -- cgit v1.2.3-59-g8ed1b From 7bf523ae252d654f1fa85c5e8759f221afe1c593 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:29:54 +0300 Subject: UBI: more of clean-up terminology for self-checks We have the "sefl-check" feature in UBI, but for historical reasons many corresponding functions and commentaries in the code use term "paranoid check" instead. Let's clean this up and use "self-check" everywhere. This patch renames functions, amends messages and kills several redundant debugging messages. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 8 ++++---- drivers/mtd/ubi/vmt.c | 31 +++++++++++++---------------- drivers/mtd/ubi/vtbl.c | 10 +++++----- drivers/mtd/ubi/wl.c | 54 ++++++++++++++++++++++++-------------------------- 4 files changed, 49 insertions(+), 54 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index bcbfe498f415..17fc6e556b38 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -88,7 +88,7 @@ #include #include "ubi.h" -static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); +static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); /* Temporary variables used during scanning */ static struct ubi_ec_hdr *ech; @@ -1218,7 +1218,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) if (seb->ec == UBI_SCAN_UNKNOWN_EC) seb->ec = si->mean_ec; - err = paranoid_check_si(ubi, si); + err = self_check_si(ubi, si); if (err) goto out_vidh; @@ -1326,14 +1326,14 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si) } /** - * paranoid_check_si - check the scanning information. + * self_check_si - check the scanning information. * @ubi: UBI device description object * @si: scanning information * * This function returns zero if the scanning information is all right, and a * negative error code if not or if an error occurred. */ -static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) +static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) { int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index b38ab92094fd..1bfd4b6ac407 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -29,7 +29,7 @@ #include #include "ubi.h" -static int paranoid_check_volumes(struct ubi_device *ubi); +static int self_check_volumes(struct ubi_device *ubi); static ssize_t vol_attribute_show(struct device *dev, struct device_attribute *attr, char *buf); @@ -356,8 +356,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) spin_unlock(&ubi->volumes_lock); ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED); - if (paranoid_check_volumes(ubi)) - dbg_err("check failed while creating volume %d", vol_id); + self_check_volumes(ubi); return err; out_sysfs: @@ -457,8 +456,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) spin_unlock(&ubi->volumes_lock); ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED); - if (!no_vtbl && paranoid_check_volumes(ubi)) - dbg_err("check failed while removing volume %d", vol_id); + if (!no_vtbl) + self_check_volumes(ubi); return err; @@ -584,8 +583,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) } ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED); - if (paranoid_check_volumes(ubi)) - dbg_err("check failed while re-sizing volume %d", vol_id); + self_check_volumes(ubi); return err; out_acc: @@ -634,8 +632,8 @@ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list) } } - if (!err && paranoid_check_volumes(ubi)) - ; + if (!err) + self_check_volumes(ubi); return err; } @@ -682,8 +680,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) return err; } - if (paranoid_check_volumes(ubi)) - dbg_err("check failed while adding volume %d", vol_id); + self_check_volumes(ubi); return err; out_cdev: @@ -709,13 +706,13 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) } /** - * paranoid_check_volume - check volume information. + * self_check_volume - check volume information. * @ubi: UBI device description object * @vol_id: volume ID * * Returns zero if volume is all right and a a negative error code if not. */ -static int paranoid_check_volume(struct ubi_device *ubi, int vol_id) +static int self_check_volume(struct ubi_device *ubi, int vol_id) { int idx = vol_id2idx(ubi, vol_id); int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker; @@ -847,7 +844,7 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id) return 0; fail: - ubi_err("paranoid check failed for volume %d", vol_id); + ubi_err("self-check failed for volume %d", vol_id); if (vol) ubi_dump_vol_info(vol); ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); @@ -857,12 +854,12 @@ fail: } /** - * paranoid_check_volumes - check information about all volumes. + * self_check_volumes - check information about all volumes. * @ubi: UBI device description object * * Returns zero if volumes are all right and a a negative error code if not. */ -static int paranoid_check_volumes(struct ubi_device *ubi) +static int self_check_volumes(struct ubi_device *ubi) { int i, err = 0; @@ -870,7 +867,7 @@ static int paranoid_check_volumes(struct ubi_device *ubi) return 0; for (i = 0; i < ubi->vtbl_slots; i++) { - err = paranoid_check_volume(ubi, i); + err = self_check_volume(ubi, i); if (err) break; } diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 277f1546cb9e..befe6f888d57 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -62,7 +62,7 @@ #include #include "ubi.h" -static void paranoid_vtbl_check(const struct ubi_device *ubi); +static void self_vtbl_check(const struct ubi_device *ubi); /* Empty volume table record */ static struct ubi_vtbl_record empty_vtbl_record; @@ -107,7 +107,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, return err; } - paranoid_vtbl_check(ubi); + self_vtbl_check(ubi); return 0; } @@ -855,16 +855,16 @@ out_free: } /** - * paranoid_vtbl_check - check volume table. + * self_vtbl_check - check volume table. * @ubi: UBI device description object */ -static void paranoid_vtbl_check(const struct ubi_device *ubi) +static void self_vtbl_check(const struct ubi_device *ubi) { if (!ubi->dbg->chk_gen) return; if (vtbl_check(ubi, ubi->vtbl)) { - ubi_err("paranoid check failed"); + ubi_err("self-check failed"); BUG(); } } diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index f99dbd084838..75d2c1f7c3a8 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -155,12 +155,11 @@ struct ubi_work { int torture; }; -static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); -static int paranoid_check_in_wl_tree(const struct ubi_device *ubi, - struct ubi_wl_entry *e, - struct rb_root *root); -static int paranoid_check_in_pq(const struct ubi_device *ubi, - struct ubi_wl_entry *e); +static int self_check_ec(struct ubi_device *ubi, int pnum, int ec); +static int self_check_in_wl_tree(const struct ubi_device *ubi, + struct ubi_wl_entry *e, struct rb_root *root); +static int self_check_in_pq(const struct ubi_device *ubi, + struct ubi_wl_entry *e); /** * wl_tree_add - add a wear-leveling entry to a WL RB-tree. @@ -404,7 +403,7 @@ retry: else e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF/2); - paranoid_check_in_wl_tree(ubi, e, &ubi->free); + self_check_in_wl_tree(ubi, e, &ubi->free); /* * Move the physical eraseblock to the protection queue where it will @@ -441,7 +440,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum) if (!e) return -ENODEV; - if (paranoid_check_in_pq(ubi, e)) + if (self_check_in_pq(ubi, e)) return -ENODEV; list_del(&e->u.list); @@ -467,7 +466,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, dbg_wl("erase PEB %d, old EC %llu", e->pnum, ec); - err = paranoid_check_ec(ubi, e->pnum, e->ec); + err = self_check_ec(ubi, e->pnum, e->ec); if (err) return -EINVAL; @@ -667,7 +666,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, e1->ec, e2->ec); goto out_cancel; } - paranoid_check_in_wl_tree(ubi, e1, &ubi->used); + self_check_in_wl_tree(ubi, e1, &ubi->used); rb_erase(&e1->u.rb, &ubi->used); dbg_wl("move PEB %d EC %d to PEB %d EC %d", e1->pnum, e1->ec, e2->pnum, e2->ec); @@ -676,12 +675,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, scrubbing = 1; e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, u.rb); e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); - paranoid_check_in_wl_tree(ubi, e1, &ubi->scrub); + self_check_in_wl_tree(ubi, e1, &ubi->scrub); rb_erase(&e1->u.rb, &ubi->scrub); dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum); } - paranoid_check_in_wl_tree(ubi, e2, &ubi->free); + self_check_in_wl_tree(ubi, e2, &ubi->free); rb_erase(&e2->u.rb, &ubi->free); ubi->move_from = e1; ubi->move_to = e2; @@ -1128,13 +1127,13 @@ retry: return 0; } else { if (in_wl_tree(e, &ubi->used)) { - paranoid_check_in_wl_tree(ubi, e, &ubi->used); + self_check_in_wl_tree(ubi, e, &ubi->used); rb_erase(&e->u.rb, &ubi->used); } else if (in_wl_tree(e, &ubi->scrub)) { - paranoid_check_in_wl_tree(ubi, e, &ubi->scrub); + self_check_in_wl_tree(ubi, e, &ubi->scrub); rb_erase(&e->u.rb, &ubi->scrub); } else if (in_wl_tree(e, &ubi->erroneous)) { - paranoid_check_in_wl_tree(ubi, e, &ubi->erroneous); + self_check_in_wl_tree(ubi, e, &ubi->erroneous); rb_erase(&e->u.rb, &ubi->erroneous); ubi->erroneous_peb_count -= 1; ubi_assert(ubi->erroneous_peb_count >= 0); @@ -1201,7 +1200,7 @@ retry: } if (in_wl_tree(e, &ubi->used)) { - paranoid_check_in_wl_tree(ubi, e, &ubi->used); + self_check_in_wl_tree(ubi, e, &ubi->used); rb_erase(&e->u.rb, &ubi->used); } else { int err; @@ -1521,7 +1520,7 @@ void ubi_wl_close(struct ubi_device *ubi) } /** - * paranoid_check_ec - make sure that the erase counter of a PEB is correct. + * self_check_ec - make sure that the erase counter of a PEB is correct. * @ubi: UBI device description object * @pnum: the physical eraseblock number to check * @ec: the erase counter to check @@ -1530,7 +1529,7 @@ void ubi_wl_close(struct ubi_device *ubi) * is equivalent to @ec, and a negative error code if not or if an error * occurred. */ -static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec) +static int self_check_ec(struct ubi_device *ubi, int pnum, int ec) { int err; long long read_ec; @@ -1552,7 +1551,7 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec) read_ec = be64_to_cpu(ec_hdr->ec); if (ec != read_ec) { - ubi_err("paranoid check failed for PEB %d", pnum); + ubi_err("self-check failed for PEB %d", pnum); ubi_err("read EC is %lld, should be %d", read_ec, ec); dump_stack(); err = 1; @@ -1565,7 +1564,7 @@ out_free: } /** - * paranoid_check_in_wl_tree - check that wear-leveling entry is in WL RB-tree. + * self_check_in_wl_tree - check that wear-leveling entry is in WL RB-tree. * @ubi: UBI device description object * @e: the wear-leveling entry to check * @root: the root of the tree @@ -1573,9 +1572,8 @@ out_free: * This function returns zero if @e is in the @root RB-tree and %-EINVAL if it * is not. */ -static int paranoid_check_in_wl_tree(const struct ubi_device *ubi, - struct ubi_wl_entry *e, - struct rb_root *root) +static int self_check_in_wl_tree(const struct ubi_device *ubi, + struct ubi_wl_entry *e, struct rb_root *root) { if (!ubi->dbg->chk_gen) return 0; @@ -1583,22 +1581,22 @@ static int paranoid_check_in_wl_tree(const struct ubi_device *ubi, if (in_wl_tree(e, root)) return 0; - ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ", + ubi_err("self-check failed for PEB %d, EC %d, RB-tree %p ", e->pnum, e->ec, root); dump_stack(); return -EINVAL; } /** - * paranoid_check_in_pq - check if wear-leveling entry is in the protection + * self_check_in_pq - check if wear-leveling entry is in the protection * queue. * @ubi: UBI device description object * @e: the wear-leveling entry to check * * This function returns zero if @e is in @ubi->pq and %-EINVAL if it is not. */ -static int paranoid_check_in_pq(const struct ubi_device *ubi, - struct ubi_wl_entry *e) +static int self_check_in_pq(const struct ubi_device *ubi, + struct ubi_wl_entry *e) { struct ubi_wl_entry *p; int i; @@ -1611,7 +1609,7 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi, if (p == e) return 0; - ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue", + ubi_err("self-check failed for PEB %d, EC %d, Protect queue", e->pnum, e->ec); dump_stack(); return -EINVAL; -- cgit v1.2.3-59-g8ed1b From e2986827d5d0759788d00f3759bcd46fc28f96c5 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:39:56 +0300 Subject: UBI: get rid of dbg_err This patch removes the 'dbg_err()' macro and we now use 'ubi_err' instead. The idea of 'dbg_err()' was to compile out some error message to make the binary a bit smaller - but I think it was a bad idea. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 8 ++++---- drivers/mtd/ubi/cdev.c | 24 ++++++++++++------------ drivers/mtd/ubi/debug.h | 2 -- drivers/mtd/ubi/io.c | 36 ++++++++++++++++++------------------ drivers/mtd/ubi/kapi.c | 2 +- drivers/mtd/ubi/scan.c | 10 +++++----- drivers/mtd/ubi/vmt.c | 18 +++++++++--------- drivers/mtd/ubi/vtbl.c | 6 +++--- 8 files changed, 52 insertions(+), 54 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 0fde9fc7d2e5..2d5728294a66 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -881,7 +881,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) for (i = 0; i < UBI_MAX_DEVICES; i++) { ubi = ubi_devices[i]; if (ubi && mtd->index == ubi->mtd->index) { - dbg_err("mtd%d is already attached to ubi%d", + ubi_err("mtd%d is already attached to ubi%d", mtd->index, i); return -EEXIST; } @@ -907,7 +907,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) if (!ubi_devices[ubi_num]) break; if (ubi_num == UBI_MAX_DEVICES) { - dbg_err("only %d UBI devices may be created", + ubi_err("only %d UBI devices may be created", UBI_MAX_DEVICES); return -ENFILE; } @@ -917,7 +917,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) /* Make sure ubi_num is not busy */ if (ubi_devices[ubi_num]) { - dbg_err("ubi%d already exists", ubi_num); + ubi_err("ubi%d already exists", ubi_num); return -EEXIST; } } @@ -955,7 +955,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) err = attach_by_scanning(ubi); if (err) { - dbg_err("failed to attach by scanning, error %d", err); + ubi_err("failed to attach by scanning, error %d", err); goto out_debugging; } diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 633ac82bbd22..2364c00f66d0 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c @@ -63,7 +63,7 @@ static int get_exclusive(struct ubi_volume_desc *desc) users = vol->readers + vol->writers + vol->exclusive; ubi_assert(users > 0); if (users > 1) { - dbg_err("%d users for volume %d", users, vol->vol_id); + ubi_err("%d users for volume %d", users, vol->vol_id); err = -EBUSY; } else { vol->readers = vol->writers = 0; @@ -159,7 +159,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) if (vol->updating) { /* Update is in progress, seeking is prohibited */ - dbg_err("updating"); + ubi_err("updating"); return -EBUSY; } @@ -178,7 +178,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) } if (new_offset < 0 || new_offset > vol->used_bytes) { - dbg_err("bad seek %lld", new_offset); + ubi_err("bad seek %lld", new_offset); return -EINVAL; } @@ -216,11 +216,11 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count, count, *offp, vol->vol_id); if (vol->updating) { - dbg_err("updating"); + ubi_err("updating"); return -EBUSY; } if (vol->upd_marker) { - dbg_err("damaged volume, update marker is set"); + ubi_err("damaged volume, update marker is set"); return -EBADF; } if (*offp == vol->used_bytes || count == 0) @@ -300,7 +300,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); if (off & (ubi->min_io_size - 1)) { - dbg_err("unaligned position"); + ubi_err("unaligned position"); return -EINVAL; } @@ -309,7 +309,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, /* We can write only in fractions of the minimum I/O unit */ if (count & (ubi->min_io_size - 1)) { - dbg_err("unaligned write length"); + ubi_err("unaligned write length"); return -EINVAL; } @@ -643,7 +643,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, return 0; bad: - dbg_err("bad volume creation request"); + ubi_err("bad volume creation request"); ubi_dump_mkvol_req(req); return err; } @@ -709,12 +709,12 @@ static int rename_volumes(struct ubi_device *ubi, for (i = 0; i < req->count - 1; i++) { for (n = i + 1; n < req->count; n++) { if (req->ents[i].vol_id == req->ents[n].vol_id) { - dbg_err("duplicated volume id %d", + ubi_err("duplicated volume id %d", req->ents[i].vol_id); return -EINVAL; } if (!strcmp(req->ents[i].name, req->ents[n].name)) { - dbg_err("duplicated volume name \"%s\"", + ubi_err("duplicated volume name \"%s\"", req->ents[i].name); return -EINVAL; } @@ -737,7 +737,7 @@ static int rename_volumes(struct ubi_device *ubi, re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_EXCLUSIVE); if (IS_ERR(re->desc)) { err = PTR_ERR(re->desc); - dbg_err("cannot open volume %d, error %d", vol_id, err); + ubi_err("cannot open volume %d, error %d", vol_id, err); kfree(re); goto out_free; } @@ -796,7 +796,7 @@ static int rename_volumes(struct ubi_device *ubi, continue; /* The volume exists but busy, or an error occurred */ - dbg_err("cannot open volume \"%s\", error %d", + ubi_err("cannot open volume \"%s\", error %d", re->new_name, err); goto out_free; } diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 3e5b60f3fdf1..449937431f42 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -35,8 +35,6 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); } \ } while (0) -#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) - #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \ print_hex_dump(l, ps, pt, r, g, b, len, a) diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 6843264840ad..8a83962a940b 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -272,7 +272,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, } if (ubi_dbg_is_write_failure(ubi)) { - dbg_err("cannot write %d bytes to PEB %d:%d " + ubi_err("cannot write %d bytes to PEB %d:%d " "(emulated)", len, pnum, offset); dump_stack(); return -EIO; @@ -387,7 +387,7 @@ retry: return err; if (ubi_dbg_is_erase_failure(ubi)) { - dbg_err("cannot erase PEB %d (emulated)", pnum); + ubi_err("cannot erase PEB %d (emulated)", pnum); return -EIO; } @@ -895,40 +895,40 @@ static int validate_vid_hdr(const struct ubi_device *ubi, int usable_leb_size = ubi->leb_size - data_pad; if (copy_flag != 0 && copy_flag != 1) { - dbg_err("bad copy_flag"); + ubi_err("bad copy_flag"); goto bad; } if (vol_id < 0 || lnum < 0 || data_size < 0 || used_ebs < 0 || data_pad < 0) { - dbg_err("negative values"); + ubi_err("negative values"); goto bad; } if (vol_id >= UBI_MAX_VOLUMES && vol_id < UBI_INTERNAL_VOL_START) { - dbg_err("bad vol_id"); + ubi_err("bad vol_id"); goto bad; } if (vol_id < UBI_INTERNAL_VOL_START && compat != 0) { - dbg_err("bad compat"); + ubi_err("bad compat"); goto bad; } if (vol_id >= UBI_INTERNAL_VOL_START && compat != UBI_COMPAT_DELETE && compat != UBI_COMPAT_RO && compat != UBI_COMPAT_PRESERVE && compat != UBI_COMPAT_REJECT) { - dbg_err("bad compat"); + ubi_err("bad compat"); goto bad; } if (vol_type != UBI_VID_DYNAMIC && vol_type != UBI_VID_STATIC) { - dbg_err("bad vol_type"); + ubi_err("bad vol_type"); goto bad; } if (data_pad >= ubi->leb_size / 2) { - dbg_err("bad data_pad"); + ubi_err("bad data_pad"); goto bad; } @@ -940,45 +940,45 @@ static int validate_vid_hdr(const struct ubi_device *ubi, * mapped logical eraseblocks. */ if (used_ebs == 0) { - dbg_err("zero used_ebs"); + ubi_err("zero used_ebs"); goto bad; } if (data_size == 0) { - dbg_err("zero data_size"); + ubi_err("zero data_size"); goto bad; } if (lnum < used_ebs - 1) { if (data_size != usable_leb_size) { - dbg_err("bad data_size"); + ubi_err("bad data_size"); goto bad; } } else if (lnum == used_ebs - 1) { if (data_size == 0) { - dbg_err("bad data_size at last LEB"); + ubi_err("bad data_size at last LEB"); goto bad; } } else { - dbg_err("too high lnum"); + ubi_err("too high lnum"); goto bad; } } else { if (copy_flag == 0) { if (data_crc != 0) { - dbg_err("non-zero data CRC"); + ubi_err("non-zero data CRC"); goto bad; } if (data_size != 0) { - dbg_err("non-zero data_size"); + ubi_err("non-zero data_size"); goto bad; } } else { if (data_size == 0) { - dbg_err("zero data_size of copy"); + ubi_err("zero data_size of copy"); goto bad; } } if (used_ebs != 0) { - dbg_err("bad used_ebs"); + ubi_err("bad used_ebs"); goto bad; } } diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 33ede23769db..d76fe47477e5 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c @@ -221,7 +221,7 @@ out_free: kfree(desc); out_put_ubi: ubi_put_device(ubi); - dbg_err("cannot open device %d, volume %d, error %d", + ubi_err("cannot open device %d, volume %d, error %d", ubi_num, vol_id, err); return ERR_PTR(err); } diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 17fc6e556b38..dc7f9dba5cce 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -197,7 +197,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, */ if (vol_id != sv->vol_id) { - dbg_err("inconsistent vol_id"); + ubi_err("inconsistent vol_id"); goto bad; } @@ -207,17 +207,17 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, sv_vol_type = UBI_VID_DYNAMIC; if (vol_type != sv_vol_type) { - dbg_err("inconsistent vol_type"); + ubi_err("inconsistent vol_type"); goto bad; } if (used_ebs != sv->used_ebs) { - dbg_err("inconsistent used_ebs"); + ubi_err("inconsistent used_ebs"); goto bad; } if (data_pad != sv->data_pad) { - dbg_err("inconsistent data_pad"); + ubi_err("inconsistent data_pad"); goto bad; } } @@ -369,7 +369,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb, if (err == UBI_IO_BITFLIPS) bitflips = 1; else { - dbg_err("VID of PEB %d header is bad, but it " + ubi_err("VID of PEB %d header is bad, but it " "was OK earlier, err %d", pnum, err); if (err > 0) err = -EIO; diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 1bfd4b6ac407..e4b897ab4543 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -223,7 +223,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) } if (vol_id == UBI_VOL_NUM_AUTO) { - dbg_err("out of volume IDs"); + ubi_err("out of volume IDs"); err = -ENFILE; goto out_unlock; } @@ -237,7 +237,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) /* Ensure that this volume does not exist */ err = -EEXIST; if (ubi->volumes[vol_id]) { - dbg_err("volume %d already exists", vol_id); + ubi_err("volume %d already exists", vol_id); goto out_unlock; } @@ -246,7 +246,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) if (ubi->volumes[i] && ubi->volumes[i]->name_len == req->name_len && !strcmp(ubi->volumes[i]->name, req->name)) { - dbg_err("volume \"%s\" exists (ID %d)", req->name, i); + ubi_err("volume \"%s\" exists (ID %d)", req->name, i); goto out_unlock; } @@ -257,9 +257,9 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) /* Reserve physical eraseblocks */ if (vol->reserved_pebs > ubi->avail_pebs) { - dbg_err("not enough PEBs, only %d available", ubi->avail_pebs); + ubi_err("not enough PEBs, only %d available", ubi->avail_pebs); if (ubi->corr_peb_count) - dbg_err("%d PEBs are corrupted and not used", + ubi_err("%d PEBs are corrupted and not used", ubi->corr_peb_count); err = -ENOSPC; goto out_unlock; @@ -495,7 +495,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) if (vol->vol_type == UBI_STATIC_VOLUME && reserved_pebs < vol->used_ebs) { - dbg_err("too small size %d, %d LEBs contain data", + ubi_err("too small size %d, %d LEBs contain data", reserved_pebs, vol->used_ebs); return -EINVAL; } @@ -524,10 +524,10 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) if (pebs > 0) { spin_lock(&ubi->volumes_lock); if (pebs > ubi->avail_pebs) { - dbg_err("not enough PEBs: requested %d, available %d", + ubi_err("not enough PEBs: requested %d, available %d", pebs, ubi->avail_pebs); if (ubi->corr_peb_count) - dbg_err("%d PEBs are corrupted and not used", + ubi_err("%d PEBs are corrupted and not used", ubi->corr_peb_count); spin_unlock(&ubi->volumes_lock); err = -ENOSPC; @@ -762,7 +762,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) } if (vol->upd_marker && vol->corrupted) { - dbg_err("update marker and corrupted simultaneously"); + ubi_err("update marker and corrupted simultaneously"); goto fail; } diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index befe6f888d57..f3fbaa9ec7f2 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -225,7 +225,7 @@ static int vtbl_check(const struct ubi_device *ubi, n = ubi->leb_size % alignment; if (data_pad != n) { - dbg_err("bad data_pad, has to be %d", n); + ubi_err("bad data_pad, has to be %d", n); err = 6; goto bad; } @@ -241,7 +241,7 @@ static int vtbl_check(const struct ubi_device *ubi, } if (reserved_pebs > ubi->good_peb_count) { - dbg_err("too large reserved_pebs %d, good PEBs %d", + ubi_err("too large reserved_pebs %d, good PEBs %d", reserved_pebs, ubi->good_peb_count); err = 9; goto bad; @@ -815,7 +815,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) } else { if (sv->leb_count > UBI_LAYOUT_VOLUME_EBS) { /* This must not happen with proper UBI images */ - dbg_err("too many LEBs (%d) in layout volume", + ubi_err("too many LEBs (%d) in layout volume", sv->leb_count); return -EINVAL; } -- cgit v1.2.3-59-g8ed1b From 227423d2416651abeafb5fd0c88c50eb0b99cb97 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 06:23:22 +0300 Subject: UBI: rename struct ubi_scan_leb Rename 'struct ubi_scan_leb' to 'struct ubi_ainf_leb'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 2 +- drivers/mtd/ubi/debug.c | 4 ++-- drivers/mtd/ubi/debug.h | 2 +- drivers/mtd/ubi/eba.c | 2 +- drivers/mtd/ubi/scan.c | 42 +++++++++++++++++++++--------------------- drivers/mtd/ubi/scan.h | 16 ++++++++-------- drivers/mtd/ubi/vtbl.c | 4 ++-- drivers/mtd/ubi/wl.c | 2 +- 8 files changed, 37 insertions(+), 37 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 2d5728294a66..3d555975e482 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -937,7 +937,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) spin_lock_init(&ubi->volumes_lock); ubi_msg("attaching mtd%d to ubi%d", mtd->index, ubi_num); - dbg_msg("sizeof(struct ubi_scan_leb) %zu", sizeof(struct ubi_scan_leb)); + dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb)); dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry)); err = io_init(ubi); diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index c6becde40314..a07ce2dcb968 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -188,11 +188,11 @@ void ubi_dump_sv(const struct ubi_scan_volume *sv) } /** - * ubi_dump_seb - dump a &struct ubi_scan_leb object. + * ubi_dump_seb - dump a &struct ubi_ainf_peb object. * @seb: the object to dump * @type: object type: 0 - not corrupted, 1 - corrupted */ -void ubi_dump_seb(const struct ubi_scan_leb *seb, int type) +void ubi_dump_seb(const struct ubi_ainf_peb *seb, int type) { printk(KERN_DEBUG "eraseblock scanning information dump:\n"); printk(KERN_DEBUG "\tec %d\n", seb->ec); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 4d0a4cdc9e3b..c6729ff0caa5 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -60,7 +60,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); void ubi_dump_sv(const struct ubi_scan_volume *sv); -void ubi_dump_seb(const struct ubi_scan_leb *seb, int type); +void ubi_dump_seb(const struct ubi_ainf_peb *seb, int type); void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len); diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index bd5fdbf7cb41..ac0e0efba8a5 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1217,7 +1217,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) int i, j, err, num_volumes; struct ubi_scan_volume *sv; struct ubi_volume *vol; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct rb_node *rb; dbg_eba("initialize EBA sub-system"); diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index dc7f9dba5cce..cddb60c5defe 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -29,7 +29,7 @@ * objects which are kept in volume RB-tree with root at the @volumes field. * The RB-tree is indexed by the volume ID. * - * Scanned logical eraseblocks are represented by &struct ubi_scan_leb objects. + * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects. * These objects are kept in per-volume RB-trees with the root at the * corresponding &struct ubi_scan_volume object. To put it differently, we keep * an RB-tree of per-volume objects and each of these objects is the root of @@ -113,7 +113,7 @@ static struct ubi_vid_hdr *vidh; static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, int to_head, struct list_head *list) { - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; if (list == &si->free) { dbg_bld("add to free: PEB %d, EC %d", pnum, ec); @@ -150,7 +150,7 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, int to_head, */ static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec) { - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); @@ -310,7 +310,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id, * o bit 2 is cleared: the older LEB is not corrupted; * o bit 2 is set: the older LEB is corrupted. */ -static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb, +static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, int pnum, const struct ubi_vid_hdr *vid_hdr) { void *buf; @@ -447,7 +447,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, int err, vol_id, lnum; unsigned long long sqnum; struct ubi_scan_volume *sv; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct rb_node **p, *parent = NULL; vol_id = be32_to_cpu(vid_hdr->vol_id); @@ -473,7 +473,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, int cmp_res; parent = *p; - seb = rb_entry(parent, struct ubi_scan_leb, u.rb); + seb = rb_entry(parent, struct ubi_ainf_peb, u.rb); if (lnum != seb->lnum) { if (lnum < seb->lnum) p = &(*p)->rb_left; @@ -622,14 +622,14 @@ struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, * This function returns a pointer to the scanning logical eraseblock or %NULL * if there are no data about it in the scanning volume information. */ -struct ubi_scan_leb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, int lnum) { - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct rb_node *p = sv->root.rb_node; while (p) { - seb = rb_entry(p, struct ubi_scan_leb, u.rb); + seb = rb_entry(p, struct ubi_ainf_peb, u.rb); if (lnum == seb->lnum) return seb; @@ -651,12 +651,12 @@ struct ubi_scan_leb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv) { struct rb_node *rb; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; dbg_bld("remove scanning information about volume %d", sv->vol_id); while ((rb = rb_first(&sv->root))) { - seb = rb_entry(rb, struct ubi_scan_leb, u.rb); + seb = rb_entry(rb, struct ubi_ainf_peb, u.rb); rb_erase(&seb->u.rb, &sv->root); list_add_tail(&seb->u.list, &si->erase); } @@ -725,14 +725,14 @@ out_free: * This function returns scanning physical eraseblock information in case of * success and an error code in case of failure. */ -struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi, +struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_scan_info *si) { int err = 0; - struct ubi_scan_leb *seb, *tmp_seb; + struct ubi_ainf_peb *seb, *tmp_seb; if (!list_empty(&si->free)) { - seb = list_entry(si->free.next, struct ubi_scan_leb, u.list); + seb = list_entry(si->free.next, struct ubi_ainf_peb, u.list); list_del(&seb->u.list); dbg_bld("return free PEB %d, EC %d", seb->pnum, seb->ec); return seb; @@ -1075,7 +1075,7 @@ adjust_mean_ec: */ static int check_what_we_have(struct ubi_device *ubi, struct ubi_scan_info *si) { - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; int max_corr, peb_count; peb_count = ubi->peb_count - si->bad_peb_count - si->alien_peb_count; @@ -1148,7 +1148,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) int err, pnum; struct rb_node *rb1, *rb2; struct ubi_scan_volume *sv; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct ubi_scan_info *si; si = kzalloc(sizeof(struct ubi_scan_info), GFP_KERNEL); @@ -1163,7 +1163,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) err = -ENOMEM; si->scan_leb_slab = kmem_cache_create("ubi_scan_leb_slab", - sizeof(struct ubi_scan_leb), + sizeof(struct ubi_ainf_peb), 0, 0, NULL); if (!si->scan_leb_slab) goto out_si; @@ -1246,7 +1246,7 @@ out_si: */ static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) { - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct rb_node *this = sv->root.rb_node; while (this) { @@ -1255,7 +1255,7 @@ static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) else if (this->rb_right) this = this->rb_right; else { - seb = rb_entry(this, struct ubi_scan_leb, u.rb); + seb = rb_entry(this, struct ubi_ainf_peb, u.rb); this = rb_parent(this); if (this) { if (this->rb_left == &seb->u.rb) @@ -1276,7 +1276,7 @@ static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) */ void ubi_scan_destroy_si(struct ubi_scan_info *si) { - struct ubi_scan_leb *seb, *seb_tmp; + struct ubi_ainf_peb *seb, *seb_tmp; struct ubi_scan_volume *sv; struct rb_node *rb; @@ -1338,7 +1338,7 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; struct ubi_scan_volume *sv; - struct ubi_scan_leb *seb, *last_seb; + struct ubi_ainf_peb *seb, *last_seb; uint8_t *buf; if (!ubi->dbg->chk_gen) diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index d48aef15ab5d..2cd66624dfa1 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -25,7 +25,7 @@ #define UBI_SCAN_UNKNOWN_EC (-1) /** - * struct ubi_scan_leb - scanning information about a physical eraseblock. + * struct ubi_ainf_peb - scanning information about a physical eraseblock. * @ec: erase counter (%UBI_SCAN_UNKNOWN_EC if it is unknown) * @pnum: physical eraseblock number * @lnum: logical eraseblock number @@ -33,13 +33,13 @@ * @copy_flag: this LEB is a copy (@copy_flag is set in VID header of this LEB) * @sqnum: sequence number * @u: unions RB-tree or @list links - * @u.rb: link in the per-volume RB-tree of &struct ubi_scan_leb objects + * @u.rb: link in the per-volume RB-tree of &struct ubi_ainf_peb objects * @u.list: link in one of the eraseblock lists * * One object of this type is allocated for each physical eraseblock during * scanning. */ -struct ubi_scan_leb { +struct ubi_ainf_peb { int ec; int pnum; int lnum; @@ -68,7 +68,7 @@ struct ubi_scan_leb { * @compat: compatibility flags of this volume * @rb: link in the volume RB-tree * @root: root of the RB-tree containing all the eraseblock belonging to this - * volume (&struct ubi_scan_leb objects) + * volume (&struct ubi_ainf_peb objects) * * One object of this type is allocated for each volume during scanning. */ @@ -109,7 +109,7 @@ struct ubi_scan_volume { * @mean_ec: mean erase counter value * @ec_sum: a temporary variable used when calculating @mean_ec * @ec_count: a temporary variable used when calculating @mean_ec - * @scan_leb_slab: slab cache for &struct ubi_scan_leb objects + * @scan_leb_slab: slab cache for &struct ubi_ainf_peb objects * * This data structure contains the result of scanning and may be used by other * UBI sub-systems to build final UBI data structures, further error-recovery @@ -149,7 +149,7 @@ struct ubi_vid_hdr; * @list: the list to move to */ static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv, - struct ubi_scan_leb *seb, + struct ubi_ainf_peb *seb, struct list_head *list) { rb_erase(&seb->u.rb, &sv->root); @@ -161,10 +161,10 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, int bitflips); struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, int vol_id); -struct ubi_scan_leb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, int lnum); void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv); -struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi, +struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_scan_info *si); int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, int pnum, int ec); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index f3fbaa9ec7f2..c9b828a69609 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -303,7 +303,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, { int err, tries = 0; struct ubi_vid_hdr *vid_hdr; - struct ubi_scan_leb *new_seb; + struct ubi_ainf_peb *new_seb; ubi_msg("create volume table (copy #%d)", copy + 1); @@ -378,7 +378,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, { int err; struct rb_node *rb; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct ubi_vtbl_record *leb[UBI_LAYOUT_VOLUME_EBS] = { NULL, NULL }; int leb_corrupted[UBI_LAYOUT_VOLUME_EBS] = {1, 1}; diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index b847f5529ba6..91869e8d2a90 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1385,7 +1385,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) int err, i; struct rb_node *rb1, *rb2; struct ubi_scan_volume *sv; - struct ubi_scan_leb *seb, *tmp; + struct ubi_ainf_peb *seb, *tmp; struct ubi_wl_entry *e; ubi->used = ubi->erroneous = ubi->free = ubi->scrub = RB_ROOT; -- cgit v1.2.3-59-g8ed1b From cb28a9322dd26cb6c29b7dda9a42626daca1024a Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 06:59:30 +0300 Subject: UBI: rename struct ubi_scan_volume Rename 'struct ubi_scan_volume' to 'struct ubi_ainf_volume'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 4 ++-- drivers/mtd/ubi/debug.h | 2 +- drivers/mtd/ubi/eba.c | 2 +- drivers/mtd/ubi/scan.c | 36 ++++++++++++++++++------------------ drivers/mtd/ubi/scan.h | 12 ++++++------ drivers/mtd/ubi/vtbl.c | 10 +++++----- drivers/mtd/ubi/wl.c | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index a07ce2dcb968..4885fd2526bb 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -171,10 +171,10 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) } /** - * ubi_dump_sv - dump a &struct ubi_scan_volume object. + * ubi_dump_sv - dump a &struct ubi_ainf_volume object. * @sv: the object to dump */ -void ubi_dump_sv(const struct ubi_scan_volume *sv) +void ubi_dump_sv(const struct ubi_ainf_volume *sv) { printk(KERN_DEBUG "Volume scanning information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index c6729ff0caa5..041ee4d43dec 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -59,7 +59,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); -void ubi_dump_sv(const struct ubi_scan_volume *sv); +void ubi_dump_sv(const struct ubi_ainf_volume *sv); void ubi_dump_seb(const struct ubi_ainf_peb *seb, int type); void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index ac0e0efba8a5..c8500cb9aaf4 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1215,7 +1215,7 @@ static void print_rsvd_warning(struct ubi_device *ubi, int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) { int i, j, err, num_volumes; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_volume *vol; struct ubi_ainf_peb *seb; struct rb_node *rb; diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index cddb60c5defe..5a2a0175a770 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -25,13 +25,13 @@ * headers and providing complete information about the UBI flash image. * * The scanning information is represented by a &struct ubi_scan_info' object. - * Information about found volumes is represented by &struct ubi_scan_volume + * Information about found volumes is represented by &struct ubi_ainf_volume * objects which are kept in volume RB-tree with root at the @volumes field. * The RB-tree is indexed by the volume ID. * * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects. * These objects are kept in per-volume RB-trees with the root at the - * corresponding &struct ubi_scan_volume object. To put it differently, we keep + * corresponding &struct ubi_ainf_volume object. To put it differently, we keep * an RB-tree of per-volume objects and each of these objects is the root of * RB-tree of per-eraseblock objects. * @@ -180,7 +180,7 @@ static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec) * headers of the same volume. */ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, - const struct ubi_scan_volume *sv, int pnum) + const struct ubi_ainf_volume *sv, int pnum) { int vol_type = vid_hdr->vol_type; int vol_id = be32_to_cpu(vid_hdr->vol_id); @@ -244,11 +244,11 @@ bad: * to the scanning volume object in case of success and a negative error code * in case of failure. */ -static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id, +static struct ubi_ainf_volume *add_volume(struct ubi_scan_info *si, int vol_id, int pnum, const struct ubi_vid_hdr *vid_hdr) { - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct rb_node **p = &si->volumes.rb_node, *parent = NULL; ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id)); @@ -256,7 +256,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id, /* Walk the volume RB-tree to look if this volume is already present */ while (*p) { parent = *p; - sv = rb_entry(parent, struct ubi_scan_volume, rb); + sv = rb_entry(parent, struct ubi_ainf_volume, rb); if (vol_id == sv->vol_id) return sv; @@ -268,7 +268,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id, } /* The volume is absent - add it */ - sv = kmalloc(sizeof(struct ubi_scan_volume), GFP_KERNEL); + sv = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); if (!sv) return ERR_PTR(-ENOMEM); @@ -446,7 +446,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, { int err, vol_id, lnum; unsigned long long sqnum; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_ainf_peb *seb; struct rb_node **p, *parent = NULL; @@ -593,14 +593,14 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, * This function returns a pointer to the volume description or %NULL if there * are no data about this volume in the scanning information. */ -struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, int vol_id) { - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct rb_node *p = si->volumes.rb_node; while (p) { - sv = rb_entry(p, struct ubi_scan_volume, rb); + sv = rb_entry(p, struct ubi_ainf_volume, rb); if (vol_id == sv->vol_id) return sv; @@ -622,7 +622,7 @@ struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, * This function returns a pointer to the scanning logical eraseblock or %NULL * if there are no data about it in the scanning volume information. */ -struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, int lnum) { struct ubi_ainf_peb *seb; @@ -648,7 +648,7 @@ struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, * @si: scanning information * @sv: the volume scanning information to delete */ -void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv) +void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) { struct rb_node *rb; struct ubi_ainf_peb *seb; @@ -1147,7 +1147,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) { int err, pnum; struct rb_node *rb1, *rb2; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_ainf_peb *seb; struct ubi_scan_info *si; @@ -1244,7 +1244,7 @@ out_si: * This function destroys the volume RB-tree (@sv->root) and the scanning * volume information. */ -static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) +static void destroy_sv(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) { struct ubi_ainf_peb *seb; struct rb_node *this = sv->root.rb_node; @@ -1277,7 +1277,7 @@ static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) void ubi_scan_destroy_si(struct ubi_scan_info *si) { struct ubi_ainf_peb *seb, *seb_tmp; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct rb_node *rb; list_for_each_entry_safe(seb, seb_tmp, &si->alien, u.list) { @@ -1305,7 +1305,7 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si) else if (rb->rb_right) rb = rb->rb_right; else { - sv = rb_entry(rb, struct ubi_scan_volume, rb); + sv = rb_entry(rb, struct ubi_ainf_volume, rb); rb = rb_parent(rb); if (rb) { @@ -1337,7 +1337,7 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) { int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_ainf_peb *seb, *last_seb; uint8_t *buf; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 2cd66624dfa1..5523f0b0fe1d 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -53,7 +53,7 @@ struct ubi_ainf_peb { }; /** - * struct ubi_scan_volume - scanning information about a volume. + * struct ubi_ainf_volume - scanning information about a volume. * @vol_id: volume ID * @highest_lnum: highest logical eraseblock number in this volume * @leb_count: number of logical eraseblocks in this volume @@ -72,7 +72,7 @@ struct ubi_ainf_peb { * * One object of this type is allocated for each volume during scanning. */ -struct ubi_scan_volume { +struct ubi_ainf_volume { int vol_id; int highest_lnum; int leb_count; @@ -148,7 +148,7 @@ struct ubi_vid_hdr; * @seb: scanning eraseblock information * @list: the list to move to */ -static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv, +static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, struct ubi_ainf_peb *seb, struct list_head *list) { @@ -159,11 +159,11 @@ static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv, int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); -struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, int vol_id); -struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, int lnum); -void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv); +void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_ainf_volume *sv); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_scan_info *si); int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index c9b828a69609..379f6203783a 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -374,7 +374,7 @@ out_free: */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, struct ubi_scan_info *si, - struct ubi_scan_volume *sv) + struct ubi_ainf_volume *sv) { int err; struct rb_node *rb; @@ -535,7 +535,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_volume *vol; for (i = 0; i < ubi->vtbl_slots; i++) { @@ -668,7 +668,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, * to the data read from the volume tabla, and %-EINVAL if not. */ static int check_sv(const struct ubi_volume *vol, - const struct ubi_scan_volume *sv) + const struct ubi_ainf_volume *sv) { int err; @@ -715,7 +715,7 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_scan_info *si) { int err, i; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_volume *vol; if (si->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { @@ -779,7 +779,7 @@ static int check_scanning_info(const struct ubi_device *ubi, int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) { int i, err; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; empty_vtbl_record.crc = cpu_to_be32(0xf116c36b); diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 91869e8d2a90..53ef24b48211 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1384,7 +1384,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) { int err, i; struct rb_node *rb1, *rb2; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_ainf_peb *seb, *tmp; struct ubi_wl_entry *e; -- cgit v1.2.3-59-g8ed1b From afc15a814b9b5879ec361b76d45f68dc3b2cd4c1 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 07:46:17 +0300 Subject: UBI: rename struct ubi_scan_info Rename 'struct ubi_scan_info' to 'struct ubi_attach_info'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 2 +- drivers/mtd/ubi/eba.c | 4 ++-- drivers/mtd/ubi/scan.c | 41 +++++++++++++++++++++-------------------- drivers/mtd/ubi/scan.h | 18 +++++++++--------- drivers/mtd/ubi/ubi.h | 6 +++--- drivers/mtd/ubi/vtbl.c | 13 +++++++------ drivers/mtd/ubi/wl.c | 2 +- 7 files changed, 44 insertions(+), 42 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3d555975e482..4e715df8bd00 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -583,7 +583,7 @@ static void free_internal_volumes(struct ubi_device *ubi) static int attach_by_scanning(struct ubi_device *ubi) { int err; - struct ubi_scan_info *si; + struct ubi_attach_info *si; si = ubi_scan(ubi); if (IS_ERR(si)) diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index c8500cb9aaf4..264482fc78a0 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1182,7 +1182,7 @@ out_unlock_leb: * reported by real users. */ static void print_rsvd_warning(struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { /* * The 1 << 18 (256KiB) number is picked randomly, just a reasonably @@ -1212,7 +1212,7 @@ static void print_rsvd_warning(struct ubi_device *ubi, * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) +int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) { int i, j, err, num_volumes; struct ubi_ainf_volume *sv; diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 5a2a0175a770..c9891776eb27 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -24,7 +24,7 @@ * This sub-system is responsible for scanning the flash media, checking UBI * headers and providing complete information about the UBI flash image. * - * The scanning information is represented by a &struct ubi_scan_info' object. + * The scanning information is represented by a &struct ubi_attach_info' object. * Information about found volumes is represented by &struct ubi_ainf_volume * objects which are kept in volume RB-tree with root at the @volumes field. * The RB-tree is indexed by the volume ID. @@ -88,7 +88,7 @@ #include #include "ubi.h" -static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); +static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si); /* Temporary variables used during scanning */ static struct ubi_ec_hdr *ech; @@ -110,8 +110,8 @@ static struct ubi_vid_hdr *vidh; * returns zero in case of success and a negative error code in case of * failure. */ -static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, int to_head, - struct list_head *list) +static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, + int to_head, struct list_head *list) { struct ubi_ainf_peb *seb; @@ -148,7 +148,7 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, int to_head, * The corruption was presumably not caused by a power cut. Returns zero in * case of success and a negative error code in case of failure. */ -static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec) +static int add_corrupted(struct ubi_attach_info *si, int pnum, int ec) { struct ubi_ainf_peb *seb; @@ -244,8 +244,8 @@ bad: * to the scanning volume object in case of success and a negative error code * in case of failure. */ -static struct ubi_ainf_volume *add_volume(struct ubi_scan_info *si, int vol_id, - int pnum, +static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, + int vol_id, int pnum, const struct ubi_vid_hdr *vid_hdr) { struct ubi_ainf_volume *sv; @@ -440,7 +440,7 @@ out_free_vidh: * to be picked, while the older one has to be dropped. This function returns * zero in case of success and a negative error code in case of failure. */ -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, +int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips) { @@ -593,7 +593,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, * This function returns a pointer to the volume description or %NULL if there * are no data about this volume in the scanning information. */ -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, int vol_id) { struct ubi_ainf_volume *sv; @@ -648,7 +648,7 @@ struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, * @si: scanning information * @sv: the volume scanning information to delete */ -void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) +void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { struct rb_node *rb; struct ubi_ainf_peb *seb; @@ -679,7 +679,7 @@ void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, +int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, int pnum, int ec) { int err; @@ -726,7 +726,7 @@ out_free: * success and an error code in case of failure. */ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { int err = 0; struct ubi_ainf_peb *seb, *tmp_seb; @@ -831,7 +831,7 @@ out_unlock: * This function returns a zero if the physical eraseblock was successfully * handled and a negative error code in case of failure. */ -static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, +static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, int pnum) { long long uninitialized_var(ec); @@ -1073,7 +1073,8 @@ adjust_mean_ec: * MTD device. Returns zero if we should proceed with attaching the MTD device, * and %-EINVAL if we should not. */ -static int check_what_we_have(struct ubi_device *ubi, struct ubi_scan_info *si) +static int check_what_we_have(struct ubi_device *ubi, + struct ubi_attach_info *si) { struct ubi_ainf_peb *seb; int max_corr, peb_count; @@ -1143,15 +1144,15 @@ static int check_what_we_have(struct ubi_device *ubi, struct ubi_scan_info *si) * This function does full scanning of an MTD device and returns complete * information about it. In case of failure, an error code is returned. */ -struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) +struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) { int err, pnum; struct rb_node *rb1, *rb2; struct ubi_ainf_volume *sv; struct ubi_ainf_peb *seb; - struct ubi_scan_info *si; + struct ubi_attach_info *si; - si = kzalloc(sizeof(struct ubi_scan_info), GFP_KERNEL); + si = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL); if (!si) return ERR_PTR(-ENOMEM); @@ -1244,7 +1245,7 @@ out_si: * This function destroys the volume RB-tree (@sv->root) and the scanning * volume information. */ -static void destroy_sv(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) +static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { struct ubi_ainf_peb *seb; struct rb_node *this = sv->root.rb_node; @@ -1274,7 +1275,7 @@ static void destroy_sv(struct ubi_scan_info *si, struct ubi_ainf_volume *sv) * ubi_scan_destroy_si - destroy scanning information. * @si: scanning information */ -void ubi_scan_destroy_si(struct ubi_scan_info *si) +void ubi_scan_destroy_si(struct ubi_attach_info *si) { struct ubi_ainf_peb *seb, *seb_tmp; struct ubi_ainf_volume *sv; @@ -1333,7 +1334,7 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si) * This function returns zero if the scanning information is all right, and a * negative error code if not or if an error occurred. */ -static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) +static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) { int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 5523f0b0fe1d..d32f18315a0e 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -86,7 +86,7 @@ struct ubi_ainf_volume { }; /** - * struct ubi_scan_info - UBI scanning information. + * struct ubi_attach_info - UBI scanning information. * @volumes: root of the volume RB-tree * @corr: list of corrupted physical eraseblocks * @free: list of free physical eraseblocks @@ -115,7 +115,7 @@ struct ubi_ainf_volume { * UBI sub-systems to build final UBI data structures, further error-recovery * and so on. */ -struct ubi_scan_info { +struct ubi_attach_info { struct rb_root volumes; struct list_head corr; struct list_head free; @@ -156,19 +156,19 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, list_add_tail(&seb->u.list, list); } -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, +int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, int vol_id); struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, int lnum); -void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_ainf_volume *sv); +void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_scan_info *si); -int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, + struct ubi_attach_info *si); +int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, int pnum, int ec); -struct ubi_scan_info *ubi_scan(struct ubi_device *ubi); -void ubi_scan_destroy_si(struct ubi_scan_info *si); +struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); +void ubi_scan_destroy_si(struct ubi_attach_info *si); #endif /* !__UBI_SCAN_H__ */ diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 75b9f1c61b78..0f206517d811 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -489,7 +489,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, struct ubi_vtbl_record *vtbl_rec); int ubi_vtbl_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list); -int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si); +int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si); /* vmt.c */ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); @@ -529,14 +529,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, const void *buf, int len); int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, struct ubi_vid_hdr *vid_hdr); -int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); +int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); /* wl.c */ int ubi_wl_get_peb(struct ubi_device *ubi); int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture); int ubi_wl_flush(struct ubi_device *ubi); int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); -int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); +int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); void ubi_wl_close(struct ubi_device *ubi); int ubi_thread(void *u); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 379f6203783a..fbe2d7ff6cda 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -298,7 +298,7 @@ bad: * This function returns zero in case of success and a negative error code in * case of failure. */ -static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, +static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, int copy, void *vtbl) { int err, tries = 0; @@ -373,7 +373,7 @@ out_free: * table in case of success and a negative error code in case of failure. */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, - struct ubi_scan_info *si, + struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { int err; @@ -496,7 +496,7 @@ out_free: * negative error code in case of failure. */ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { int i; struct ubi_vtbl_record *vtbl; @@ -531,7 +531,8 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, * Returns zero in case of success and a negative error code in case of * failure. */ -static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, +static int init_volumes(struct ubi_device *ubi, + const struct ubi_attach_info *si, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; @@ -712,7 +713,7 @@ bad: * information is OK and %-EINVAL if it is not. */ static int check_scanning_info(const struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { int err, i; struct ubi_ainf_volume *sv; @@ -776,7 +777,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * or creates it if needed. Returns zero in case of success and a negative * error code in case of failure. */ -int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) +int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) { int i, err; struct ubi_ainf_volume *sv; diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 53ef24b48211..12a85d5372cd 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1380,7 +1380,7 @@ static void cancel_pending(struct ubi_device *ubi) * This function returns zero in case of success, and a negative error code in * case of failure. */ -int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) +int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) { int err, i; struct rb_node *rb1, *rb2; -- cgit v1.2.3-59-g8ed1b From 2c5ec5ce66c0170829c5c128b9235429936442ac Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 08:26:24 +0300 Subject: UBI: rename seb to aeb After re-naming the 'struct ubi_scan_leb' we should adjust all variables named 'seb' to something else, because 'seb' stands for "scanning eraseblock". Let's rename it to 'aeb' which stands for "attaching eraseblock" which is a bit more consistend and has the same length. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 16 +-- drivers/mtd/ubi/debug.h | 2 +- drivers/mtd/ubi/eba.c | 10 +- drivers/mtd/ubi/scan.c | 296 ++++++++++++++++++++++++------------------------ drivers/mtd/ubi/scan.h | 10 +- drivers/mtd/ubi/vtbl.c | 36 +++--- drivers/mtd/ubi/wl.c | 22 ++-- 7 files changed, 196 insertions(+), 196 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 4885fd2526bb..e73b1fef897d 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -188,19 +188,19 @@ void ubi_dump_sv(const struct ubi_ainf_volume *sv) } /** - * ubi_dump_seb - dump a &struct ubi_ainf_peb object. - * @seb: the object to dump + * ubi_dump_aeb - dump a &struct ubi_ainf_peb object. + * @aeb: the object to dump * @type: object type: 0 - not corrupted, 1 - corrupted */ -void ubi_dump_seb(const struct ubi_ainf_peb *seb, int type) +void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type) { printk(KERN_DEBUG "eraseblock scanning information dump:\n"); - printk(KERN_DEBUG "\tec %d\n", seb->ec); - printk(KERN_DEBUG "\tpnum %d\n", seb->pnum); + printk(KERN_DEBUG "\tec %d\n", aeb->ec); + printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum); if (type == 0) { - printk(KERN_DEBUG "\tlnum %d\n", seb->lnum); - printk(KERN_DEBUG "\tscrub %d\n", seb->scrub); - printk(KERN_DEBUG "\tsqnum %llu\n", seb->sqnum); + printk(KERN_DEBUG "\tlnum %d\n", aeb->lnum); + printk(KERN_DEBUG "\tscrub %d\n", aeb->scrub); + printk(KERN_DEBUG "\tsqnum %llu\n", aeb->sqnum); } } diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 041ee4d43dec..a0911c0c1064 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -60,7 +60,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); void ubi_dump_sv(const struct ubi_ainf_volume *sv); -void ubi_dump_seb(const struct ubi_ainf_peb *seb, int type); +void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type); void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len); diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 264482fc78a0..25095026617d 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1217,7 +1217,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) int i, j, err, num_volumes; struct ubi_ainf_volume *sv; struct ubi_volume *vol; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct rb_node *rb; dbg_eba("initialize EBA sub-system"); @@ -1250,14 +1250,14 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) if (!sv) continue; - ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { - if (seb->lnum >= vol->reserved_pebs) + ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + if (aeb->lnum >= vol->reserved_pebs) /* * This may happen in case of an unclean reboot * during re-size. */ - ubi_scan_move_to_list(sv, seb, &si->erase); - vol->eba_tbl[seb->lnum] = seb->pnum; + ubi_scan_move_to_list(sv, aeb, &si->erase); + vol->eba_tbl[aeb->lnum] = aeb->pnum; } } diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index c9891776eb27..c53ef5d9b134 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -113,7 +113,7 @@ static struct ubi_vid_hdr *vidh; static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, int to_head, struct list_head *list) { - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; if (list == &si->free) { dbg_bld("add to free: PEB %d, EC %d", pnum, ec); @@ -125,16 +125,16 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, } else BUG(); - seb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); - if (!seb) + aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + if (!aeb) return -ENOMEM; - seb->pnum = pnum; - seb->ec = ec; + aeb->pnum = pnum; + aeb->ec = ec; if (to_head) - list_add(&seb->u.list, list); + list_add(&aeb->u.list, list); else - list_add_tail(&seb->u.list, list); + list_add_tail(&aeb->u.list, list); return 0; } @@ -150,18 +150,18 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, */ static int add_corrupted(struct ubi_attach_info *si, int pnum, int ec) { - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); - seb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); - if (!seb) + aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + if (!aeb) return -ENOMEM; si->corr_peb_count += 1; - seb->pnum = pnum; - seb->ec = ec; - list_add(&seb->u.list, &si->corr); + aeb->pnum = pnum; + aeb->ec = ec; + list_add(&aeb->u.list, &si->corr); return 0; } @@ -293,7 +293,7 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, /** * compare_lebs - find out which logical eraseblock is newer. * @ubi: UBI device description object - * @seb: first logical eraseblock to compare + * @aeb: first logical eraseblock to compare * @pnum: physical eraseblock number of the second logical eraseblock to * compare * @vid_hdr: volume identifier header of the second logical eraseblock @@ -302,7 +302,7 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, * case of success this function returns a positive value, in case of failure, a * negative error code is returned. The success return codes use the following * bits: - * o bit 0 is cleared: the first PEB (described by @seb) is newer than the + * o bit 0 is cleared: the first PEB (described by @aeb) is newer than the * second PEB (described by @pnum and @vid_hdr); * o bit 0 is set: the second PEB is newer; * o bit 1 is cleared: no bit-flips were detected in the newer LEB; @@ -310,7 +310,7 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, * o bit 2 is cleared: the older LEB is not corrupted; * o bit 2 is set: the older LEB is corrupted. */ -static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, +static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb, int pnum, const struct ubi_vid_hdr *vid_hdr) { void *buf; @@ -319,7 +319,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, struct ubi_vid_hdr *vh = NULL; unsigned long long sqnum2 = be64_to_cpu(vid_hdr->sqnum); - if (sqnum2 == seb->sqnum) { + if (sqnum2 == aeb->sqnum) { /* * This must be a really ancient UBI image which has been * created before sequence numbers support has been added. At @@ -333,7 +333,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, } /* Obviously the LEB with lower sequence counter is older */ - second_is_newer = (sqnum2 > seb->sqnum); + second_is_newer = (sqnum2 > aeb->sqnum); /* * Now we know which copy is newer. If the copy flag of the PEB with @@ -352,7 +352,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, return 1; } } else { - if (!seb->copy_flag) { + if (!aeb->copy_flag) { /* It is not a copy, so it is newer */ dbg_bld("first PEB %d is newer, copy_flag is unset", pnum); @@ -363,7 +363,7 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *seb, if (!vh) return -ENOMEM; - pnum = seb->pnum; + pnum = aeb->pnum; err = ubi_io_read_vid_hdr(ubi, pnum, vh, 0); if (err) { if (err == UBI_IO_BITFLIPS) @@ -447,7 +447,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int err, vol_id, lnum; unsigned long long sqnum; struct ubi_ainf_volume *sv; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct rb_node **p, *parent = NULL; vol_id = be32_to_cpu(vid_hdr->vol_id); @@ -473,9 +473,9 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int cmp_res; parent = *p; - seb = rb_entry(parent, struct ubi_ainf_peb, u.rb); - if (lnum != seb->lnum) { - if (lnum < seb->lnum) + aeb = rb_entry(parent, struct ubi_ainf_peb, u.rb); + if (lnum != aeb->lnum) { + if (lnum < aeb->lnum) p = &(*p)->rb_left; else p = &(*p)->rb_right; @@ -487,8 +487,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, * logical eraseblock present. */ - dbg_bld("this LEB already exists: PEB %d, sqnum %llu, " - "EC %d", seb->pnum, seb->sqnum, seb->ec); + dbg_bld("this LEB already exists: PEB %d, sqnum %llu, EC %d", + aeb->pnum, aeb->sqnum, aeb->ec); /* * Make sure that the logical eraseblocks have different @@ -503,10 +503,10 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, * images, but refuse attaching old images with duplicated * logical eraseblocks because there was an unclean reboot. */ - if (seb->sqnum == sqnum && sqnum != 0) { + if (aeb->sqnum == sqnum && sqnum != 0) { ubi_err("two LEBs with same sequence number %llu", sqnum); - ubi_dump_seb(seb, 0); + ubi_dump_aeb(aeb, 0); ubi_dump_vid_hdr(vid_hdr); return -EINVAL; } @@ -515,7 +515,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, * Now we have to drop the older one and preserve the newer * one. */ - cmp_res = compare_lebs(ubi, seb, pnum, vid_hdr); + cmp_res = compare_lebs(ubi, aeb, pnum, vid_hdr); if (cmp_res < 0) return cmp_res; @@ -528,16 +528,16 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, if (err) return err; - err = add_to_list(si, seb->pnum, seb->ec, cmp_res & 4, + err = add_to_list(si, aeb->pnum, aeb->ec, cmp_res & 4, &si->erase); if (err) return err; - seb->ec = ec; - seb->pnum = pnum; - seb->scrub = ((cmp_res & 2) || bitflips); - seb->copy_flag = vid_hdr->copy_flag; - seb->sqnum = sqnum; + aeb->ec = ec; + aeb->pnum = pnum; + aeb->scrub = ((cmp_res & 2) || bitflips); + aeb->copy_flag = vid_hdr->copy_flag; + aeb->sqnum = sqnum; if (sv->highest_lnum == lnum) sv->last_data_size = @@ -563,16 +563,16 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, if (err) return err; - seb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); - if (!seb) + aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + if (!aeb) return -ENOMEM; - seb->ec = ec; - seb->pnum = pnum; - seb->lnum = lnum; - seb->scrub = bitflips; - seb->copy_flag = vid_hdr->copy_flag; - seb->sqnum = sqnum; + aeb->ec = ec; + aeb->pnum = pnum; + aeb->lnum = lnum; + aeb->scrub = bitflips; + aeb->copy_flag = vid_hdr->copy_flag; + aeb->sqnum = sqnum; if (sv->highest_lnum <= lnum) { sv->highest_lnum = lnum; @@ -580,8 +580,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, } sv->leb_count += 1; - rb_link_node(&seb->u.rb, parent, p); - rb_insert_color(&seb->u.rb, &sv->root); + rb_link_node(&aeb->u.rb, parent, p); + rb_insert_color(&aeb->u.rb, &sv->root); return 0; } @@ -615,26 +615,26 @@ struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, } /** - * ubi_scan_find_seb - find LEB in the volume scanning information. + * ubi_scan_find_aeb - find LEB in the volume scanning information. * @sv: a pointer to the volume scanning information * @lnum: the requested logical eraseblock * * This function returns a pointer to the scanning logical eraseblock or %NULL * if there are no data about it in the scanning volume information. */ -struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, int lnum) { - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct rb_node *p = sv->root.rb_node; while (p) { - seb = rb_entry(p, struct ubi_ainf_peb, u.rb); + aeb = rb_entry(p, struct ubi_ainf_peb, u.rb); - if (lnum == seb->lnum) - return seb; + if (lnum == aeb->lnum) + return aeb; - if (lnum > seb->lnum) + if (lnum > aeb->lnum) p = p->rb_left; else p = p->rb_right; @@ -651,14 +651,14 @@ struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { struct rb_node *rb; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; dbg_bld("remove scanning information about volume %d", sv->vol_id); while ((rb = rb_first(&sv->root))) { - seb = rb_entry(rb, struct ubi_ainf_peb, u.rb); - rb_erase(&seb->u.rb, &sv->root); - list_add_tail(&seb->u.list, &si->erase); + aeb = rb_entry(rb, struct ubi_ainf_peb, u.rb); + rb_erase(&aeb->u.rb, &sv->root); + list_add_tail(&aeb->u.list, &si->erase); } rb_erase(&sv->rb, &si->volumes); @@ -729,13 +729,13 @@ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_attach_info *si) { int err = 0; - struct ubi_ainf_peb *seb, *tmp_seb; + struct ubi_ainf_peb *aeb, *tmp_aeb; if (!list_empty(&si->free)) { - seb = list_entry(si->free.next, struct ubi_ainf_peb, u.list); - list_del(&seb->u.list); - dbg_bld("return free PEB %d, EC %d", seb->pnum, seb->ec); - return seb; + aeb = list_entry(si->free.next, struct ubi_ainf_peb, u.list); + list_del(&aeb->u.list); + dbg_bld("return free PEB %d, EC %d", aeb->pnum, aeb->ec); + return aeb; } /* @@ -744,18 +744,18 @@ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, * so forth. We don't want to take care about bad eraseblocks here - * they'll be handled later. */ - list_for_each_entry_safe(seb, tmp_seb, &si->erase, u.list) { - if (seb->ec == UBI_SCAN_UNKNOWN_EC) - seb->ec = si->mean_ec; + list_for_each_entry_safe(aeb, tmp_aeb, &si->erase, u.list) { + if (aeb->ec == UBI_SCAN_UNKNOWN_EC) + aeb->ec = si->mean_ec; - err = ubi_scan_erase_peb(ubi, si, seb->pnum, seb->ec+1); + err = ubi_scan_erase_peb(ubi, si, aeb->pnum, aeb->ec+1); if (err) continue; - seb->ec += 1; - list_del(&seb->u.list); - dbg_bld("return PEB %d, EC %d", seb->pnum, seb->ec); - return seb; + aeb->ec += 1; + list_del(&aeb->u.list); + dbg_bld("return PEB %d, EC %d", aeb->pnum, aeb->ec); + return aeb; } ubi_err("no free eraseblocks"); @@ -1076,7 +1076,7 @@ adjust_mean_ec: static int check_what_we_have(struct ubi_device *ubi, struct ubi_attach_info *si) { - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; int max_corr, peb_count; peb_count = ubi->peb_count - si->bad_peb_count - si->alien_peb_count; @@ -1091,8 +1091,8 @@ static int check_what_we_have(struct ubi_device *ubi, ubi_err("%d PEBs are corrupted and preserved", si->corr_peb_count); printk(KERN_ERR "Corrupted PEBs are:"); - list_for_each_entry(seb, &si->corr, u.list) - printk(KERN_CONT " %d", seb->pnum); + list_for_each_entry(aeb, &si->corr, u.list) + printk(KERN_CONT " %d", aeb->pnum); printk(KERN_CONT "\n"); /* @@ -1149,7 +1149,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) int err, pnum; struct rb_node *rb1, *rb2; struct ubi_ainf_volume *sv; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct ubi_attach_info *si; si = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL); @@ -1201,23 +1201,23 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) * value. */ ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { - ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) - if (seb->ec == UBI_SCAN_UNKNOWN_EC) - seb->ec = si->mean_ec; + ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) + if (aeb->ec == UBI_SCAN_UNKNOWN_EC) + aeb->ec = si->mean_ec; } - list_for_each_entry(seb, &si->free, u.list) { - if (seb->ec == UBI_SCAN_UNKNOWN_EC) - seb->ec = si->mean_ec; + list_for_each_entry(aeb, &si->free, u.list) { + if (aeb->ec == UBI_SCAN_UNKNOWN_EC) + aeb->ec = si->mean_ec; } - list_for_each_entry(seb, &si->corr, u.list) - if (seb->ec == UBI_SCAN_UNKNOWN_EC) - seb->ec = si->mean_ec; + list_for_each_entry(aeb, &si->corr, u.list) + if (aeb->ec == UBI_SCAN_UNKNOWN_EC) + aeb->ec = si->mean_ec; - list_for_each_entry(seb, &si->erase, u.list) - if (seb->ec == UBI_SCAN_UNKNOWN_EC) - seb->ec = si->mean_ec; + list_for_each_entry(aeb, &si->erase, u.list) + if (aeb->ec == UBI_SCAN_UNKNOWN_EC) + aeb->ec = si->mean_ec; err = self_check_si(ubi, si); if (err) @@ -1247,7 +1247,7 @@ out_si: */ static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct rb_node *this = sv->root.rb_node; while (this) { @@ -1256,16 +1256,16 @@ static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) else if (this->rb_right) this = this->rb_right; else { - seb = rb_entry(this, struct ubi_ainf_peb, u.rb); + aeb = rb_entry(this, struct ubi_ainf_peb, u.rb); this = rb_parent(this); if (this) { - if (this->rb_left == &seb->u.rb) + if (this->rb_left == &aeb->u.rb) this->rb_left = NULL; else this->rb_right = NULL; } - kmem_cache_free(si->scan_leb_slab, seb); + kmem_cache_free(si->scan_leb_slab, aeb); } } kfree(sv); @@ -1277,25 +1277,25 @@ static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) */ void ubi_scan_destroy_si(struct ubi_attach_info *si) { - struct ubi_ainf_peb *seb, *seb_tmp; + struct ubi_ainf_peb *aeb, *aeb_tmp; struct ubi_ainf_volume *sv; struct rb_node *rb; - list_for_each_entry_safe(seb, seb_tmp, &si->alien, u.list) { - list_del(&seb->u.list); - kmem_cache_free(si->scan_leb_slab, seb); + list_for_each_entry_safe(aeb, aeb_tmp, &si->alien, u.list) { + list_del(&aeb->u.list); + kmem_cache_free(si->scan_leb_slab, aeb); } - list_for_each_entry_safe(seb, seb_tmp, &si->erase, u.list) { - list_del(&seb->u.list); - kmem_cache_free(si->scan_leb_slab, seb); + list_for_each_entry_safe(aeb, aeb_tmp, &si->erase, u.list) { + list_del(&aeb->u.list); + kmem_cache_free(si->scan_leb_slab, aeb); } - list_for_each_entry_safe(seb, seb_tmp, &si->corr, u.list) { - list_del(&seb->u.list); - kmem_cache_free(si->scan_leb_slab, seb); + list_for_each_entry_safe(aeb, aeb_tmp, &si->corr, u.list) { + list_del(&aeb->u.list); + kmem_cache_free(si->scan_leb_slab, aeb); } - list_for_each_entry_safe(seb, seb_tmp, &si->free, u.list) { - list_del(&seb->u.list); - kmem_cache_free(si->scan_leb_slab, seb); + list_for_each_entry_safe(aeb, aeb_tmp, &si->free, u.list) { + list_del(&aeb->u.list); + kmem_cache_free(si->scan_leb_slab, aeb); } /* Destroy the volume RB-tree */ @@ -1339,7 +1339,7 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; struct ubi_ainf_volume *sv; - struct ubi_ainf_peb *seb, *last_seb; + struct ubi_ainf_peb *aeb, *last_aeb; uint8_t *buf; if (!ubi->dbg->chk_gen) @@ -1390,51 +1390,51 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_sv; } - last_seb = NULL; - ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) { + last_aeb = NULL; + ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { cond_resched(); - last_seb = seb; + last_aeb = aeb; leb_count += 1; - if (seb->pnum < 0 || seb->ec < 0) { + if (aeb->pnum < 0 || aeb->ec < 0) { ubi_err("negative values"); - goto bad_seb; + goto bad_aeb; } - if (seb->ec < si->min_ec) { + if (aeb->ec < si->min_ec) { ubi_err("bad si->min_ec (%d), %d found", - si->min_ec, seb->ec); - goto bad_seb; + si->min_ec, aeb->ec); + goto bad_aeb; } - if (seb->ec > si->max_ec) { + if (aeb->ec > si->max_ec) { ubi_err("bad si->max_ec (%d), %d found", - si->max_ec, seb->ec); - goto bad_seb; + si->max_ec, aeb->ec); + goto bad_aeb; } - if (seb->pnum >= ubi->peb_count) { + if (aeb->pnum >= ubi->peb_count) { ubi_err("too high PEB number %d, total PEBs %d", - seb->pnum, ubi->peb_count); - goto bad_seb; + aeb->pnum, ubi->peb_count); + goto bad_aeb; } if (sv->vol_type == UBI_STATIC_VOLUME) { - if (seb->lnum >= sv->used_ebs) { + if (aeb->lnum >= sv->used_ebs) { ubi_err("bad lnum or used_ebs"); - goto bad_seb; + goto bad_aeb; } } else { if (sv->used_ebs != 0) { ubi_err("non-zero used_ebs"); - goto bad_seb; + goto bad_aeb; } } - if (seb->lnum > sv->highest_lnum) { + if (aeb->lnum > sv->highest_lnum) { ubi_err("incorrect highest_lnum or lnum"); - goto bad_seb; + goto bad_aeb; } } @@ -1444,14 +1444,14 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_sv; } - if (!last_seb) + if (!last_aeb) continue; - seb = last_seb; + aeb = last_aeb; - if (seb->lnum != sv->highest_lnum) { + if (aeb->lnum != sv->highest_lnum) { ubi_err("bad highest_lnum"); - goto bad_seb; + goto bad_aeb; } } @@ -1463,15 +1463,15 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) /* Check that scanning information is correct */ ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { - last_seb = NULL; - ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) { + last_aeb = NULL; + ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { int vol_type; cond_resched(); - last_seb = seb; + last_aeb = aeb; - err = ubi_io_read_vid_hdr(ubi, seb->pnum, vidh, 1); + err = ubi_io_read_vid_hdr(ubi, aeb->pnum, vidh, 1); if (err && err != UBI_IO_BITFLIPS) { ubi_err("VID header is not OK (%d)", err); if (err > 0) @@ -1486,8 +1486,8 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_vid_hdr; } - if (seb->sqnum != be64_to_cpu(vidh->sqnum)) { - ubi_err("bad sqnum %llu", seb->sqnum); + if (aeb->sqnum != be64_to_cpu(vidh->sqnum)) { + ubi_err("bad sqnum %llu", aeb->sqnum); goto bad_vid_hdr; } @@ -1501,8 +1501,8 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_vid_hdr; } - if (seb->lnum != be32_to_cpu(vidh->lnum)) { - ubi_err("bad lnum %d", seb->lnum); + if (aeb->lnum != be32_to_cpu(vidh->lnum)) { + ubi_err("bad lnum %d", aeb->lnum); goto bad_vid_hdr; } @@ -1517,7 +1517,7 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) } } - if (!last_seb) + if (!last_aeb) continue; if (sv->highest_lnum != be32_to_cpu(vidh->lnum)) { @@ -1549,20 +1549,20 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) } ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) - ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) - buf[seb->pnum] = 1; + ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) + buf[aeb->pnum] = 1; - list_for_each_entry(seb, &si->free, u.list) - buf[seb->pnum] = 1; + list_for_each_entry(aeb, &si->free, u.list) + buf[aeb->pnum] = 1; - list_for_each_entry(seb, &si->corr, u.list) - buf[seb->pnum] = 1; + list_for_each_entry(aeb, &si->corr, u.list) + buf[aeb->pnum] = 1; - list_for_each_entry(seb, &si->erase, u.list) - buf[seb->pnum] = 1; + list_for_each_entry(aeb, &si->erase, u.list) + buf[aeb->pnum] = 1; - list_for_each_entry(seb, &si->alien, u.list) - buf[seb->pnum] = 1; + list_for_each_entry(aeb, &si->alien, u.list) + buf[aeb->pnum] = 1; err = 0; for (pnum = 0; pnum < ubi->peb_count; pnum++) @@ -1576,9 +1576,9 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto out; return 0; -bad_seb: - ubi_err("bad scanning information about LEB %d", seb->lnum); - ubi_dump_seb(seb, 0); +bad_aeb: + ubi_err("bad scanning information about LEB %d", aeb->lnum); + ubi_dump_aeb(aeb, 0); ubi_dump_sv(sv); goto out; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 9ba00c8f453a..7e20a85b8c31 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -146,15 +146,15 @@ struct ubi_vid_hdr; * ubi_scan_move_to_list - move a PEB from the volume tree to a list. * * @sv: volume scanning information - * @seb: scanning eraseblock information + * @aeb: scanning eraseblock information * @list: the list to move to */ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, - struct ubi_ainf_peb *seb, + struct ubi_ainf_peb *aeb, struct list_head *list) { - rb_erase(&seb->u.rb, &sv->root); - list_add_tail(&seb->u.list, list); + rb_erase(&aeb->u.rb, &sv->root); + list_add_tail(&aeb->u.list, list); } int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, @@ -162,7 +162,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int bitflips); struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, int vol_id); -struct ubi_ainf_peb *ubi_scan_find_seb(const struct ubi_ainf_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, int lnum); void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index fbe2d7ff6cda..800958de64e8 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -303,7 +303,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, { int err, tries = 0; struct ubi_vid_hdr *vid_hdr; - struct ubi_ainf_peb *new_seb; + struct ubi_ainf_peb *new_aeb; ubi_msg("create volume table (copy #%d)", copy + 1); @@ -312,9 +312,9 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, return -ENOMEM; retry: - new_seb = ubi_scan_get_free_peb(ubi, si); - if (IS_ERR(new_seb)) { - err = PTR_ERR(new_seb); + new_aeb = ubi_scan_get_free_peb(ubi, si); + if (IS_ERR(new_aeb)) { + err = PTR_ERR(new_aeb); goto out_free; } @@ -327,12 +327,12 @@ retry: vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum); /* The EC header is already there, write the VID header */ - err = ubi_io_write_vid_hdr(ubi, new_seb->pnum, vid_hdr); + err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); if (err) goto write_error; /* Write the layout volume contents */ - err = ubi_io_write_data(ubi, vtbl, new_seb->pnum, 0, ubi->vtbl_size); + err = ubi_io_write_data(ubi, vtbl, new_aeb->pnum, 0, ubi->vtbl_size); if (err) goto write_error; @@ -340,9 +340,9 @@ retry: * And add it to the scanning information. Don't delete the old version * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. */ - err = ubi_scan_add_used(ubi, si, new_seb->pnum, new_seb->ec, + err = ubi_scan_add_used(ubi, si, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); - kfree(new_seb); + kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -352,10 +352,10 @@ write_error: * Probably this physical eraseblock went bad, try to pick * another one. */ - list_add(&new_seb->u.list, &si->erase); + list_add(&new_aeb->u.list, &si->erase); goto retry; } - kfree(new_seb); + kfree(new_aeb); out_free: ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -378,7 +378,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, { int err; struct rb_node *rb; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct ubi_vtbl_record *leb[UBI_LAYOUT_VOLUME_EBS] = { NULL, NULL }; int leb_corrupted[UBI_LAYOUT_VOLUME_EBS] = {1, 1}; @@ -410,14 +410,14 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, dbg_gen("check layout volume"); /* Read both LEB 0 and LEB 1 into memory */ - ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { - leb[seb->lnum] = vzalloc(ubi->vtbl_size); - if (!leb[seb->lnum]) { + ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + leb[aeb->lnum] = vzalloc(ubi->vtbl_size); + if (!leb[aeb->lnum]) { err = -ENOMEM; goto out_free; } - err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, + err = ubi_io_read_data(ubi, leb[aeb->lnum], aeb->pnum, 0, ubi->vtbl_size); if (err == UBI_IO_BITFLIPS || mtd_is_eccerr(err)) /* @@ -425,12 +425,12 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, * uncorrectable ECC error, but we have our own CRC and * the data will be checked later. If the data is OK, * the PEB will be scrubbed (because we set - * seb->scrub). If the data is not OK, the contents of + * aeb->scrub). If the data is not OK, the contents of * the PEB will be recovered from the second copy, and - * seb->scrub will be cleared in + * aeb->scrub will be cleared in * 'ubi_scan_add_used()'. */ - seb->scrub = 1; + aeb->scrub = 1; else if (err) goto out_free; } diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 12a85d5372cd..fb870f4fc924 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1385,7 +1385,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) int err, i; struct rb_node *rb1, *rb2; struct ubi_ainf_volume *sv; - struct ubi_ainf_peb *seb, *tmp; + struct ubi_ainf_peb *aeb, *tmp; struct ubi_wl_entry *e; ubi->used = ubi->erroneous = ubi->free = ubi->scrub = RB_ROOT; @@ -1406,15 +1406,15 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) INIT_LIST_HEAD(&ubi->pq[i]); ubi->pq_head = 0; - list_for_each_entry_safe(seb, tmp, &si->erase, u.list) { + list_for_each_entry_safe(aeb, tmp, &si->erase, u.list) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); if (!e) goto out_free; - e->pnum = seb->pnum; - e->ec = seb->ec; + e->pnum = aeb->pnum; + e->ec = aeb->ec; ubi->lookuptbl[e->pnum] = e; if (schedule_erase(ubi, e, 0)) { kmem_cache_free(ubi_wl_entry_slab, e); @@ -1422,32 +1422,32 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) } } - list_for_each_entry(seb, &si->free, u.list) { + list_for_each_entry(aeb, &si->free, u.list) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); if (!e) goto out_free; - e->pnum = seb->pnum; - e->ec = seb->ec; + e->pnum = aeb->pnum; + e->ec = aeb->ec; ubi_assert(e->ec >= 0); wl_tree_add(e, &ubi->free); ubi->lookuptbl[e->pnum] = e; } ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { - ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); if (!e) goto out_free; - e->pnum = seb->pnum; - e->ec = seb->ec; + e->pnum = aeb->pnum; + e->ec = aeb->ec; ubi->lookuptbl[e->pnum] = e; - if (!seb->scrub) { + if (!aeb->scrub) { dbg_wl("add PEB %d EC %d to the used tree", e->pnum, e->ec); wl_tree_add(e, &ubi->used); -- cgit v1.2.3-59-g8ed1b From a4e6042f1d073073f88e0ad6d2a7450da9a3937d Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 13:09:08 +0300 Subject: UBI: rename si to ai After re-naming the 'struct ubi_scan_info' we should adjust all variables named 'si' to something else, because 'si' stands for "scanning info". Let's rename it to 'ai' which stands for "attaching info" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 32 ++--- drivers/mtd/ubi/debug.c | 4 +- drivers/mtd/ubi/eba.c | 18 +-- drivers/mtd/ubi/scan.c | 346 ++++++++++++++++++++++++------------------------ drivers/mtd/ubi/scan.h | 14 +- drivers/mtd/ubi/ubi.h | 6 +- drivers/mtd/ubi/vtbl.c | 86 ++++++------ drivers/mtd/ubi/wl.c | 14 +- 8 files changed, 260 insertions(+), 260 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 4e715df8bd00..1ae3cfa30809 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -583,32 +583,32 @@ static void free_internal_volumes(struct ubi_device *ubi) static int attach_by_scanning(struct ubi_device *ubi) { int err; - struct ubi_attach_info *si; + struct ubi_attach_info *ai; - si = ubi_scan(ubi); - if (IS_ERR(si)) - return PTR_ERR(si); + ai = ubi_scan(ubi); + if (IS_ERR(ai)) + return PTR_ERR(ai); - ubi->bad_peb_count = si->bad_peb_count; + ubi->bad_peb_count = ai->bad_peb_count; ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count; - ubi->corr_peb_count = si->corr_peb_count; - ubi->max_ec = si->max_ec; - ubi->mean_ec = si->mean_ec; - ubi_msg("max. sequence number: %llu", si->max_sqnum); + ubi->corr_peb_count = ai->corr_peb_count; + ubi->max_ec = ai->max_ec; + ubi->mean_ec = ai->mean_ec; + ubi_msg("max. sequence number: %llu", ai->max_sqnum); - err = ubi_read_volume_table(ubi, si); + err = ubi_read_volume_table(ubi, ai); if (err) - goto out_si; + goto out_ai; - err = ubi_wl_init_scan(ubi, si); + err = ubi_wl_init_scan(ubi, ai); if (err) goto out_vtbl; - err = ubi_eba_init_scan(ubi, si); + err = ubi_eba_init_scan(ubi, ai); if (err) goto out_wl; - ubi_scan_destroy_si(si); + ubi_scan_destroy_ai(ai); return 0; out_wl: @@ -616,8 +616,8 @@ out_wl: out_vtbl: free_internal_volumes(ubi); vfree(ubi->vtbl); -out_si: - ubi_scan_destroy_si(si); +out_ai: + ubi_scan_destroy_ai(ai); return err; } diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index e73b1fef897d..84362a802999 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -176,7 +176,7 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) */ void ubi_dump_sv(const struct ubi_ainf_volume *sv) { - printk(KERN_DEBUG "Volume scanning information dump:\n"); + printk(KERN_DEBUG "Volume attaching information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum); printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count); @@ -194,7 +194,7 @@ void ubi_dump_sv(const struct ubi_ainf_volume *sv) */ void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type) { - printk(KERN_DEBUG "eraseblock scanning information dump:\n"); + printk(KERN_DEBUG "eraseblock attaching information dump:\n"); printk(KERN_DEBUG "\tec %d\n", aeb->ec); printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum); if (type == 0) { diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 25095026617d..320372715405 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1182,13 +1182,13 @@ out_unlock_leb: * reported by real users. */ static void print_rsvd_warning(struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { /* * The 1 << 18 (256KiB) number is picked randomly, just a reasonably * large number to distinguish between newly flashed and used images. */ - if (si->max_sqnum > (1 << 18)) { + if (ai->max_sqnum > (1 << 18)) { int min = ubi->beb_rsvd_level / 10; if (!min) @@ -1205,14 +1205,14 @@ static void print_rsvd_warning(struct ubi_device *ubi, } /** - * ubi_eba_init_scan - initialize the EBA sub-system using scanning information. + * ubi_eba_init_scan - initialize the EBA sub-system using attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) +int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) { int i, j, err, num_volumes; struct ubi_ainf_volume *sv; @@ -1226,7 +1226,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) mutex_init(&ubi->alc_mutex); ubi->ltree = RB_ROOT; - ubi->global_sqnum = si->max_sqnum + 1; + ubi->global_sqnum = ai->max_sqnum + 1; num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT; for (i = 0; i < num_volumes; i++) { @@ -1246,7 +1246,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) for (j = 0; j < vol->reserved_pebs; j++) vol->eba_tbl[j] = UBI_LEB_UNMAPPED; - sv = ubi_scan_find_sv(si, idx2vol_id(ubi, i)); + sv = ubi_scan_find_sv(ai, idx2vol_id(ubi, i)); if (!sv) continue; @@ -1256,7 +1256,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) * This may happen in case of an unclean reboot * during re-size. */ - ubi_scan_move_to_list(sv, aeb, &si->erase); + ubi_scan_move_to_list(sv, aeb, &ai->erase); vol->eba_tbl[aeb->lnum] = aeb->pnum; } } @@ -1279,7 +1279,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) if (ubi->avail_pebs < ubi->beb_rsvd_level) { /* No enough free physical eraseblocks */ ubi->beb_rsvd_pebs = ubi->avail_pebs; - print_rsvd_warning(ubi, si); + print_rsvd_warning(ubi, ai); } else ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index c53ef5d9b134..4145a042c8e1 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -24,10 +24,10 @@ * This sub-system is responsible for scanning the flash media, checking UBI * headers and providing complete information about the UBI flash image. * - * The scanning information is represented by a &struct ubi_attach_info' object. - * Information about found volumes is represented by &struct ubi_ainf_volume - * objects which are kept in volume RB-tree with root at the @volumes field. - * The RB-tree is indexed by the volume ID. + * The attaching information is represented by a &struct ubi_attach_info' + * object. Information about found volumes is represented by + * &struct ubi_ainf_volume objects which are kept in volume RB-tree with root + * at the @volumes field. The RB-tree is indexed by the volume ID. * * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects. * These objects are kept in per-volume RB-trees with the root at the @@ -88,7 +88,7 @@ #include #include "ubi.h" -static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si); +static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai); /* Temporary variables used during scanning */ static struct ubi_ec_hdr *ech; @@ -96,7 +96,7 @@ static struct ubi_vid_hdr *vidh; /** * add_to_list - add physical eraseblock to a list. - * @si: scanning information + * @ai: attaching information * @pnum: physical eraseblock number to add * @ec: erase counter of the physical eraseblock * @to_head: if not zero, add to the head of the list @@ -110,22 +110,22 @@ static struct ubi_vid_hdr *vidh; * returns zero in case of success and a negative error code in case of * failure. */ -static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, +static int add_to_list(struct ubi_attach_info *ai, int pnum, int ec, int to_head, struct list_head *list) { struct ubi_ainf_peb *aeb; - if (list == &si->free) { + if (list == &ai->free) { dbg_bld("add to free: PEB %d, EC %d", pnum, ec); - } else if (list == &si->erase) { + } else if (list == &ai->erase) { dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); - } else if (list == &si->alien) { + } else if (list == &ai->alien) { dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); - si->alien_peb_count += 1; + ai->alien_peb_count += 1; } else BUG(); - aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL); if (!aeb) return -ENOMEM; @@ -140,7 +140,7 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, /** * add_corrupted - add a corrupted physical eraseblock. - * @si: scanning information + * @ai: attaching information * @pnum: physical eraseblock number to add * @ec: erase counter of the physical eraseblock * @@ -148,20 +148,20 @@ static int add_to_list(struct ubi_attach_info *si, int pnum, int ec, * The corruption was presumably not caused by a power cut. Returns zero in * case of success and a negative error code in case of failure. */ -static int add_corrupted(struct ubi_attach_info *si, int pnum, int ec) +static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) { struct ubi_ainf_peb *aeb; dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); - aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL); if (!aeb) return -ENOMEM; - si->corr_peb_count += 1; + ai->corr_peb_count += 1; aeb->pnum = pnum; aeb->ec = ec; - list_add(&aeb->u.list, &si->corr); + list_add(&aeb->u.list, &ai->corr); return 0; } @@ -232,24 +232,24 @@ bad: } /** - * add_volume - add volume to the scanning information. - * @si: scanning information + * add_volume - add volume to the attaching information. + * @ai: attaching information * @vol_id: ID of the volume to add * @pnum: physical eraseblock number * @vid_hdr: volume identifier header * * If the volume corresponding to the @vid_hdr logical eraseblock is already - * present in the scanning information, this function does nothing. Otherwise - * it adds corresponding volume to the scanning information. Returns a pointer + * present in the attaching information, this function does nothing. Otherwise + * it adds corresponding volume to the attaching information. Returns a pointer * to the scanning volume object in case of success and a negative error code * in case of failure. */ -static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, +static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai, int vol_id, int pnum, const struct ubi_vid_hdr *vid_hdr) { struct ubi_ainf_volume *sv; - struct rb_node **p = &si->volumes.rb_node, *parent = NULL; + struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id)); @@ -280,12 +280,12 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *si, sv->compat = vid_hdr->compat; sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; - if (vol_id > si->highest_vol_id) - si->highest_vol_id = vol_id; + if (vol_id > ai->highest_vol_id) + ai->highest_vol_id = vol_id; rb_link_node(&sv->rb, parent, p); - rb_insert_color(&sv->rb, &si->volumes); - si->vols_found += 1; + rb_insert_color(&sv->rb, &ai->volumes); + ai->vols_found += 1; dbg_bld("added volume %d", vol_id); return sv; } @@ -425,9 +425,9 @@ out_free_vidh: } /** - * ubi_scan_add_used - add physical eraseblock to the scanning information. + * ubi_scan_add_used - add physical eraseblock to the attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * @pnum: the physical eraseblock number * @ec: erase counter * @vid_hdr: the volume identifier header @@ -440,7 +440,7 @@ out_free_vidh: * to be picked, while the older one has to be dropped. This function returns * zero in case of success and a negative error code in case of failure. */ -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, +int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips) { @@ -457,12 +457,12 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, bitflips %d", pnum, vol_id, lnum, ec, sqnum, bitflips); - sv = add_volume(si, vol_id, pnum, vid_hdr); + sv = add_volume(ai, vol_id, pnum, vid_hdr); if (IS_ERR(sv)) return PTR_ERR(sv); - if (si->max_sqnum < sqnum) - si->max_sqnum = sqnum; + if (ai->max_sqnum < sqnum) + ai->max_sqnum = sqnum; /* * Walk the RB-tree of logical eraseblocks of volume @vol_id to look @@ -528,8 +528,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, if (err) return err; - err = add_to_list(si, aeb->pnum, aeb->ec, cmp_res & 4, - &si->erase); + err = add_to_list(ai, aeb->pnum, aeb->ec, cmp_res & 4, + &ai->erase); if (err) return err; @@ -549,21 +549,21 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, * This logical eraseblock is older than the one found * previously. */ - return add_to_list(si, pnum, ec, cmp_res & 4, - &si->erase); + return add_to_list(ai, pnum, ec, cmp_res & 4, + &ai->erase); } } /* * We've met this logical eraseblock for the first time, add it to the - * scanning information. + * attaching information. */ err = validate_vid_hdr(vid_hdr, sv, pnum); if (err) return err; - aeb = kmem_cache_alloc(si->scan_leb_slab, GFP_KERNEL); + aeb = kmem_cache_alloc(ai->scan_leb_slab, GFP_KERNEL); if (!aeb) return -ENOMEM; @@ -586,18 +586,18 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, } /** - * ubi_scan_find_sv - find volume in the scanning information. - * @si: scanning information + * ubi_scan_find_sv - find volume in the attaching information. + * @ai: attaching information * @vol_id: the requested volume ID * * This function returns a pointer to the volume description or %NULL if there - * are no data about this volume in the scanning information. + * are no data about this volume in the attaching information. */ -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai, int vol_id) { struct ubi_ainf_volume *sv; - struct rb_node *p = si->volumes.rb_node; + struct rb_node *p = ai->volumes.rb_node; while (p) { sv = rb_entry(p, struct ubi_ainf_volume, rb); @@ -615,8 +615,8 @@ struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, } /** - * ubi_scan_find_aeb - find LEB in the volume scanning information. - * @sv: a pointer to the volume scanning information + * ubi_scan_find_aeb - find LEB in the volume attaching information. + * @sv: a pointer to the volume attaching information * @lnum: the requested logical eraseblock * * This function returns a pointer to the scanning logical eraseblock or %NULL @@ -644,32 +644,32 @@ struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, } /** - * ubi_scan_rm_volume - delete scanning information about a volume. - * @si: scanning information - * @sv: the volume scanning information to delete + * ubi_scan_rm_volume - delete attaching information about a volume. + * @ai: attaching information + * @sv: the volume attaching information to delete */ -void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) +void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) { struct rb_node *rb; struct ubi_ainf_peb *aeb; - dbg_bld("remove scanning information about volume %d", sv->vol_id); + dbg_bld("remove attaching information about volume %d", sv->vol_id); while ((rb = rb_first(&sv->root))) { aeb = rb_entry(rb, struct ubi_ainf_peb, u.rb); rb_erase(&aeb->u.rb, &sv->root); - list_add_tail(&aeb->u.list, &si->erase); + list_add_tail(&aeb->u.list, &ai->erase); } - rb_erase(&sv->rb, &si->volumes); + rb_erase(&sv->rb, &ai->volumes); kfree(sv); - si->vols_found -= 1; + ai->vols_found -= 1; } /** * ubi_scan_erase_peb - erase a physical eraseblock. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * @pnum: physical eraseblock number to erase; * @ec: erase counter value to write (%UBI_SCAN_UNKNOWN_EC if it is unknown) * @@ -679,7 +679,7 @@ void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, +int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai, int pnum, int ec) { int err; @@ -714,7 +714,7 @@ out_free: /** * ubi_scan_get_free_peb - get a free physical eraseblock. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function returns a free physical eraseblock. It is supposed to be * called on the UBI initialization stages when the wear-leveling sub-system is @@ -726,13 +726,13 @@ out_free: * success and an error code in case of failure. */ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { int err = 0; struct ubi_ainf_peb *aeb, *tmp_aeb; - if (!list_empty(&si->free)) { - aeb = list_entry(si->free.next, struct ubi_ainf_peb, u.list); + if (!list_empty(&ai->free)) { + aeb = list_entry(ai->free.next, struct ubi_ainf_peb, u.list); list_del(&aeb->u.list); dbg_bld("return free PEB %d, EC %d", aeb->pnum, aeb->ec); return aeb; @@ -744,11 +744,11 @@ struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, * so forth. We don't want to take care about bad eraseblocks here - * they'll be handled later. */ - list_for_each_entry_safe(aeb, tmp_aeb, &si->erase, u.list) { + list_for_each_entry_safe(aeb, tmp_aeb, &ai->erase, u.list) { if (aeb->ec == UBI_SCAN_UNKNOWN_EC) - aeb->ec = si->mean_ec; + aeb->ec = ai->mean_ec; - err = ubi_scan_erase_peb(ubi, si, aeb->pnum, aeb->ec+1); + err = ubi_scan_erase_peb(ubi, ai, aeb->pnum, aeb->ec+1); if (err) continue; @@ -823,15 +823,15 @@ out_unlock: } /** - * process_eb - read, check UBI headers, and add them to scanning information. + * process_eb - read, check UBI headers, and add them to attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * @pnum: the physical eraseblock number * * This function returns a zero if the physical eraseblock was successfully * handled and a negative error code in case of failure. */ -static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, +static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum) { long long uninitialized_var(ec); @@ -849,7 +849,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, * initialize this, but MTD does not provide enough * information. */ - si->bad_peb_count += 1; + ai->bad_peb_count += 1; return 0; } @@ -863,13 +863,13 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, bitflips = 1; break; case UBI_IO_FF: - si->empty_peb_count += 1; - return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, 0, - &si->erase); + ai->empty_peb_count += 1; + return add_to_list(ai, pnum, UBI_SCAN_UNKNOWN_EC, 0, + &ai->erase); case UBI_IO_FF_BITFLIPS: - si->empty_peb_count += 1; - return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, 1, - &si->erase); + ai->empty_peb_count += 1; + return add_to_list(ai, pnum, UBI_SCAN_UNKNOWN_EC, 1, + &ai->erase); case UBI_IO_BAD_HDR_EBADMSG: case UBI_IO_BAD_HDR: /* @@ -953,7 +953,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, * PEB, bit it is not marked as bad yet. This may also * be a result of power cut during erasure. */ - si->maybe_bad_peb_count += 1; + ai->maybe_bad_peb_count += 1; case UBI_IO_BAD_HDR: if (ec_err) /* @@ -980,23 +980,23 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, return err; else if (!err) /* This corruption is caused by a power cut */ - err = add_to_list(si, pnum, ec, 1, &si->erase); + err = add_to_list(ai, pnum, ec, 1, &ai->erase); else /* This is an unexpected corruption */ - err = add_corrupted(si, pnum, ec); + err = add_corrupted(ai, pnum, ec); if (err) return err; goto adjust_mean_ec; case UBI_IO_FF_BITFLIPS: - err = add_to_list(si, pnum, ec, 1, &si->erase); + err = add_to_list(ai, pnum, ec, 1, &ai->erase); if (err) return err; goto adjust_mean_ec; case UBI_IO_FF: if (ec_err) - err = add_to_list(si, pnum, ec, 1, &si->erase); + err = add_to_list(ai, pnum, ec, 1, &ai->erase); else - err = add_to_list(si, pnum, ec, 0, &si->free); + err = add_to_list(ai, pnum, ec, 0, &ai->free); if (err) return err; goto adjust_mean_ec; @@ -1015,7 +1015,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, case UBI_COMPAT_DELETE: ubi_msg("\"delete\" compatible internal volume %d:%d" " found, will remove it", vol_id, lnum); - err = add_to_list(si, pnum, ec, 1, &si->erase); + err = add_to_list(ai, pnum, ec, 1, &ai->erase); if (err) return err; return 0; @@ -1030,7 +1030,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, case UBI_COMPAT_PRESERVE: ubi_msg("\"preserve\" compatible internal volume %d:%d" " found", vol_id, lnum); - err = add_to_list(si, pnum, ec, 0, &si->alien); + err = add_to_list(ai, pnum, ec, 0, &ai->alien); if (err) return err; return 0; @@ -1045,18 +1045,18 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *si, if (ec_err) ubi_warn("valid VID header but corrupted EC header at PEB %d", pnum); - err = ubi_scan_add_used(ubi, si, pnum, ec, vidh, bitflips); + err = ubi_scan_add_used(ubi, ai, pnum, ec, vidh, bitflips); if (err) return err; adjust_mean_ec: if (!ec_err) { - si->ec_sum += ec; - si->ec_count += 1; - if (ec > si->max_ec) - si->max_ec = ec; - if (ec < si->min_ec) - si->min_ec = ec; + ai->ec_sum += ec; + ai->ec_count += 1; + if (ec > ai->max_ec) + ai->max_ec = ec; + if (ec < ai->min_ec) + ai->min_ec = ec; } return 0; @@ -1065,7 +1065,7 @@ adjust_mean_ec: /** * check_what_we_have - check what PEB were found by scanning. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This is a helper function which takes a look what PEBs were found by * scanning, and decides whether the flash is empty and should be formatted and @@ -1074,12 +1074,12 @@ adjust_mean_ec: * and %-EINVAL if we should not. */ static int check_what_we_have(struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { struct ubi_ainf_peb *aeb; int max_corr, peb_count; - peb_count = ubi->peb_count - si->bad_peb_count - si->alien_peb_count; + peb_count = ubi->peb_count - ai->bad_peb_count - ai->alien_peb_count; max_corr = peb_count / 20 ?: 8; /* @@ -1087,11 +1087,11 @@ static int check_what_we_have(struct ubi_device *ubi, * unclean reboots. However, many of them may indicate some problems * with the flash HW or driver. */ - if (si->corr_peb_count) { + if (ai->corr_peb_count) { ubi_err("%d PEBs are corrupted and preserved", - si->corr_peb_count); + ai->corr_peb_count); printk(KERN_ERR "Corrupted PEBs are:"); - list_for_each_entry(aeb, &si->corr, u.list) + list_for_each_entry(aeb, &ai->corr, u.list) printk(KERN_CONT " %d", aeb->pnum); printk(KERN_CONT "\n"); @@ -1099,13 +1099,13 @@ static int check_what_we_have(struct ubi_device *ubi, * If too many PEBs are corrupted, we refuse attaching, * otherwise, only print a warning. */ - if (si->corr_peb_count >= max_corr) { + if (ai->corr_peb_count >= max_corr) { ubi_err("too many corrupted PEBs, refusing"); return -EINVAL; } } - if (si->empty_peb_count + si->maybe_bad_peb_count == peb_count) { + if (ai->empty_peb_count + ai->maybe_bad_peb_count == peb_count) { /* * All PEBs are empty, or almost all - a couple PEBs look like * they may be bad PEBs which were not marked as bad yet. @@ -1121,8 +1121,8 @@ static int check_what_we_have(struct ubi_device *ubi, * 2. Flash contains non-UBI data and we do not want to format * it and destroy possibly important information. */ - if (si->maybe_bad_peb_count <= 2) { - si->is_empty = 1; + if (ai->maybe_bad_peb_count <= 2) { + ai->is_empty = 1; ubi_msg("empty MTD device detected"); get_random_bytes(&ubi->image_seq, sizeof(ubi->image_seq)); @@ -1150,28 +1150,28 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) struct rb_node *rb1, *rb2; struct ubi_ainf_volume *sv; struct ubi_ainf_peb *aeb; - struct ubi_attach_info *si; + struct ubi_attach_info *ai; - si = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL); - if (!si) + ai = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL); + if (!ai) return ERR_PTR(-ENOMEM); - INIT_LIST_HEAD(&si->corr); - INIT_LIST_HEAD(&si->free); - INIT_LIST_HEAD(&si->erase); - INIT_LIST_HEAD(&si->alien); - si->volumes = RB_ROOT; + INIT_LIST_HEAD(&ai->corr); + INIT_LIST_HEAD(&ai->free); + INIT_LIST_HEAD(&ai->erase); + INIT_LIST_HEAD(&ai->alien); + ai->volumes = RB_ROOT; err = -ENOMEM; - si->scan_leb_slab = kmem_cache_create("ubi_scan_leb_slab", + ai->scan_leb_slab = kmem_cache_create("ubi_scan_leb_slab", sizeof(struct ubi_ainf_peb), 0, 0, NULL); - if (!si->scan_leb_slab) - goto out_si; + if (!ai->scan_leb_slab) + goto out_ai; ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); if (!ech) - goto out_si; + goto out_ai; vidh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); if (!vidh) @@ -1181,7 +1181,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) cond_resched(); dbg_gen("process PEB %d", pnum); - err = process_eb(ubi, si, pnum); + err = process_eb(ubi, ai, pnum); if (err < 0) goto out_vidh; } @@ -1189,10 +1189,10 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) dbg_msg("scanning is finished"); /* Calculate mean erase counter */ - if (si->ec_count) - si->mean_ec = div_u64(si->ec_sum, si->ec_count); + if (ai->ec_count) + ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); - err = check_what_we_have(ubi, si); + err = check_what_we_have(ubi, ai); if (err) goto out_vidh; @@ -1200,52 +1200,52 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) * In case of unknown erase counter we use the mean erase counter * value. */ - ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { + ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) if (aeb->ec == UBI_SCAN_UNKNOWN_EC) - aeb->ec = si->mean_ec; + aeb->ec = ai->mean_ec; } - list_for_each_entry(aeb, &si->free, u.list) { + list_for_each_entry(aeb, &ai->free, u.list) { if (aeb->ec == UBI_SCAN_UNKNOWN_EC) - aeb->ec = si->mean_ec; + aeb->ec = ai->mean_ec; } - list_for_each_entry(aeb, &si->corr, u.list) + list_for_each_entry(aeb, &ai->corr, u.list) if (aeb->ec == UBI_SCAN_UNKNOWN_EC) - aeb->ec = si->mean_ec; + aeb->ec = ai->mean_ec; - list_for_each_entry(aeb, &si->erase, u.list) + list_for_each_entry(aeb, &ai->erase, u.list) if (aeb->ec == UBI_SCAN_UNKNOWN_EC) - aeb->ec = si->mean_ec; + aeb->ec = ai->mean_ec; - err = self_check_si(ubi, si); + err = self_check_ai(ubi, ai); if (err) goto out_vidh; ubi_free_vid_hdr(ubi, vidh); kfree(ech); - return si; + return ai; out_vidh: ubi_free_vid_hdr(ubi, vidh); out_ech: kfree(ech); -out_si: - ubi_scan_destroy_si(si); +out_ai: + ubi_scan_destroy_ai(ai); return ERR_PTR(err); } /** * destroy_sv - free the scanning volume information * @sv: scanning volume information - * @si: scanning information + * @ai: attaching information * * This function destroys the volume RB-tree (@sv->root) and the scanning * volume information. */ -static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) +static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) { struct ubi_ainf_peb *aeb; struct rb_node *this = sv->root.rb_node; @@ -1265,41 +1265,41 @@ static void destroy_sv(struct ubi_attach_info *si, struct ubi_ainf_volume *sv) this->rb_right = NULL; } - kmem_cache_free(si->scan_leb_slab, aeb); + kmem_cache_free(ai->scan_leb_slab, aeb); } } kfree(sv); } /** - * ubi_scan_destroy_si - destroy scanning information. - * @si: scanning information + * ubi_scan_destroy_ai - destroy attaching information. + * @ai: attaching information */ -void ubi_scan_destroy_si(struct ubi_attach_info *si) +void ubi_scan_destroy_ai(struct ubi_attach_info *ai) { struct ubi_ainf_peb *aeb, *aeb_tmp; struct ubi_ainf_volume *sv; struct rb_node *rb; - list_for_each_entry_safe(aeb, aeb_tmp, &si->alien, u.list) { + list_for_each_entry_safe(aeb, aeb_tmp, &ai->alien, u.list) { list_del(&aeb->u.list); - kmem_cache_free(si->scan_leb_slab, aeb); + kmem_cache_free(ai->scan_leb_slab, aeb); } - list_for_each_entry_safe(aeb, aeb_tmp, &si->erase, u.list) { + list_for_each_entry_safe(aeb, aeb_tmp, &ai->erase, u.list) { list_del(&aeb->u.list); - kmem_cache_free(si->scan_leb_slab, aeb); + kmem_cache_free(ai->scan_leb_slab, aeb); } - list_for_each_entry_safe(aeb, aeb_tmp, &si->corr, u.list) { + list_for_each_entry_safe(aeb, aeb_tmp, &ai->corr, u.list) { list_del(&aeb->u.list); - kmem_cache_free(si->scan_leb_slab, aeb); + kmem_cache_free(ai->scan_leb_slab, aeb); } - list_for_each_entry_safe(aeb, aeb_tmp, &si->free, u.list) { + list_for_each_entry_safe(aeb, aeb_tmp, &ai->free, u.list) { list_del(&aeb->u.list); - kmem_cache_free(si->scan_leb_slab, aeb); + kmem_cache_free(ai->scan_leb_slab, aeb); } /* Destroy the volume RB-tree */ - rb = si->volumes.rb_node; + rb = ai->volumes.rb_node; while (rb) { if (rb->rb_left) rb = rb->rb_left; @@ -1316,25 +1316,25 @@ void ubi_scan_destroy_si(struct ubi_attach_info *si) rb->rb_right = NULL; } - destroy_sv(si, sv); + destroy_sv(ai, sv); } } - if (si->scan_leb_slab) - kmem_cache_destroy(si->scan_leb_slab); + if (ai->scan_leb_slab) + kmem_cache_destroy(ai->scan_leb_slab); - kfree(si); + kfree(ai); } /** - * self_check_si - check the scanning information. + * self_check_ai - check the attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * - * This function returns zero if the scanning information is all right, and a + * This function returns zero if the attaching information is all right, and a * negative error code if not or if an error occurred. */ -static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) +static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) { int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; @@ -1346,16 +1346,16 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) return 0; /* - * At first, check that scanning information is OK. + * At first, check that attaching information is OK. */ - ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { + ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { int leb_count = 0; cond_resched(); vols_found += 1; - if (si->is_empty) { + if (ai->is_empty) { ubi_err("bad is_empty flag"); goto bad_sv; } @@ -1373,9 +1373,9 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_sv; } - if (sv->vol_id > si->highest_vol_id) { + if (sv->vol_id > ai->highest_vol_id) { ubi_err("highest_vol_id is %d, but vol_id %d is there", - si->highest_vol_id, sv->vol_id); + ai->highest_vol_id, sv->vol_id); goto out; } @@ -1402,15 +1402,15 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) goto bad_aeb; } - if (aeb->ec < si->min_ec) { - ubi_err("bad si->min_ec (%d), %d found", - si->min_ec, aeb->ec); + if (aeb->ec < ai->min_ec) { + ubi_err("bad ai->min_ec (%d), %d found", + ai->min_ec, aeb->ec); goto bad_aeb; } - if (aeb->ec > si->max_ec) { - ubi_err("bad si->max_ec (%d), %d found", - si->max_ec, aeb->ec); + if (aeb->ec > ai->max_ec) { + ubi_err("bad ai->max_ec (%d), %d found", + ai->max_ec, aeb->ec); goto bad_aeb; } @@ -1455,14 +1455,14 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) } } - if (vols_found != si->vols_found) { - ubi_err("bad si->vols_found %d, should be %d", - si->vols_found, vols_found); + if (vols_found != ai->vols_found) { + ubi_err("bad ai->vols_found %d, should be %d", + ai->vols_found, vols_found); goto out; } - /* Check that scanning information is correct */ - ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { + /* Check that attaching information is correct */ + ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { last_aeb = NULL; ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { int vol_type; @@ -1548,20 +1548,20 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) buf[pnum] = 1; } - ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) + ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) buf[aeb->pnum] = 1; - list_for_each_entry(aeb, &si->free, u.list) + list_for_each_entry(aeb, &ai->free, u.list) buf[aeb->pnum] = 1; - list_for_each_entry(aeb, &si->corr, u.list) + list_for_each_entry(aeb, &ai->corr, u.list) buf[aeb->pnum] = 1; - list_for_each_entry(aeb, &si->erase, u.list) + list_for_each_entry(aeb, &ai->erase, u.list) buf[aeb->pnum] = 1; - list_for_each_entry(aeb, &si->alien, u.list) + list_for_each_entry(aeb, &ai->alien, u.list) buf[aeb->pnum] = 1; err = 0; @@ -1577,18 +1577,18 @@ static int self_check_si(struct ubi_device *ubi, struct ubi_attach_info *si) return 0; bad_aeb: - ubi_err("bad scanning information about LEB %d", aeb->lnum); + ubi_err("bad attaching information about LEB %d", aeb->lnum); ubi_dump_aeb(aeb, 0); ubi_dump_sv(sv); goto out; bad_sv: - ubi_err("bad scanning information about volume %d", sv->vol_id); + ubi_err("bad attaching information about volume %d", sv->vol_id); ubi_dump_sv(sv); goto out; bad_vid_hdr: - ubi_err("bad scanning information about volume %d", sv->vol_id); + ubi_err("bad attaching information about volume %d", sv->vol_id); ubi_dump_sv(sv); ubi_dump_vid_hdr(vidh); diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 7e20a85b8c31..0f0725e18b7f 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -145,7 +145,7 @@ struct ubi_vid_hdr; /* * ubi_scan_move_to_list - move a PEB from the volume tree to a list. * - * @sv: volume scanning information + * @sv: volume attaching information * @aeb: scanning eraseblock information * @list: the list to move to */ @@ -157,19 +157,19 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, list_add_tail(&aeb->u.list, list); } -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, +int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, +struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai, int vol_id); struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, int lnum); -void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv); +void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_attach_info *si); -int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, + struct ubi_attach_info *ai); +int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai, int pnum, int ec); struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); -void ubi_scan_destroy_si(struct ubi_attach_info *si); +void ubi_scan_destroy_ai(struct ubi_attach_info *ai); #endif /* !__UBI_SCAN_H__ */ diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 0f206517d811..faaf72933bcb 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -489,7 +489,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, struct ubi_vtbl_record *vtbl_rec); int ubi_vtbl_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list); -int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si); +int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai); /* vmt.c */ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); @@ -529,14 +529,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, const void *buf, int len); int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, struct ubi_vid_hdr *vid_hdr); -int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); +int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai); /* wl.c */ int ubi_wl_get_peb(struct ubi_device *ubi); int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture); int ubi_wl_flush(struct ubi_device *ubi); int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); -int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); +int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai); void ubi_wl_close(struct ubi_device *ubi); int ubi_thread(void *u); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 800958de64e8..3e5363c9945e 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -291,14 +291,14 @@ bad: /** * create_vtbl - create a copy of volume table. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * @copy: number of the volume table copy * @vtbl: contents of the volume table * * This function returns zero in case of success and a negative error code in * case of failure. */ -static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, +static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai, int copy, void *vtbl) { int err, tries = 0; @@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, return -ENOMEM; retry: - new_aeb = ubi_scan_get_free_peb(ubi, si); + new_aeb = ubi_scan_get_free_peb(ubi, ai); if (IS_ERR(new_aeb)) { err = PTR_ERR(new_aeb); goto out_free; @@ -324,7 +324,7 @@ retry: vid_hdr->data_size = vid_hdr->used_ebs = vid_hdr->data_pad = cpu_to_be32(0); vid_hdr->lnum = cpu_to_be32(copy); - vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum); + vid_hdr->sqnum = cpu_to_be64(++ai->max_sqnum); /* The EC header is already there, write the VID header */ err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); @@ -337,10 +337,10 @@ retry: goto write_error; /* - * And add it to the scanning information. Don't delete the old version + * And add it to the attaching information. Don't delete the old version * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. */ - err = ubi_scan_add_used(ubi, si, new_aeb->pnum, new_aeb->ec, + err = ubi_scan_add_used(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); @@ -352,7 +352,7 @@ write_error: * Probably this physical eraseblock went bad, try to pick * another one. */ - list_add(&new_aeb->u.list, &si->erase); + list_add(&new_aeb->u.list, &ai->erase); goto retry; } kfree(new_aeb); @@ -365,15 +365,15 @@ out_free: /** * process_lvol - process the layout volume. * @ubi: UBI device description object - * @si: scanning information - * @sv: layout volume scanning information + * @ai: attaching information + * @sv: layout volume attaching information * * This function is responsible for reading the layout volume, ensuring it is * not corrupted, and recovering from corruptions if needed. Returns volume * table in case of success and a negative error code in case of failure. */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, - struct ubi_attach_info *si, + struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) { int err; @@ -449,7 +449,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ubi->vtbl_size); if (leb_corrupted[1]) { ubi_warn("volume table copy #2 is corrupted"); - err = create_vtbl(ubi, si, 1, leb[0]); + err = create_vtbl(ubi, ai, 1, leb[0]); if (err) goto out_free; ubi_msg("volume table was restored"); @@ -472,7 +472,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, } ubi_warn("volume table copy #1 is corrupted"); - err = create_vtbl(ubi, si, 0, leb[1]); + err = create_vtbl(ubi, ai, 0, leb[1]); if (err) goto out_free; ubi_msg("volume table was restored"); @@ -490,13 +490,13 @@ out_free: /** * create_empty_lvol - create empty layout volume. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function returns volume table contents in case of success and a * negative error code in case of failure. */ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { int i; struct ubi_vtbl_record *vtbl; @@ -511,7 +511,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { int err; - err = create_vtbl(ubi, si, i, vtbl); + err = create_vtbl(ubi, ai, i, vtbl); if (err) { vfree(vtbl); return ERR_PTR(err); @@ -524,7 +524,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, /** * init_volumes - initialize volume information for existing volumes. * @ubi: UBI device description object - * @si: scanning information + * @ai: scanning information * @vtbl: volume table * * This function allocates volume description objects for existing volumes. @@ -532,7 +532,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, * failure. */ static int init_volumes(struct ubi_device *ubi, - const struct ubi_attach_info *si, + const struct ubi_attach_info *ai, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; @@ -592,7 +592,7 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - sv = ubi_scan_find_sv(si, i); + sv = ubi_scan_find_sv(ai, i); if (!sv) { /* * No eraseblocks belonging to this volume found. We @@ -661,11 +661,11 @@ static int init_volumes(struct ubi_device *ubi, } /** - * check_sv - check volume scanning information. + * check_sv - check volume attaching information. * @vol: UBI volume description object - * @sv: volume scanning information + * @sv: volume attaching information * - * This function returns zero if the volume scanning information is consistent + * This function returns zero if the volume attaching information is consistent * to the data read from the volume tabla, and %-EINVAL if not. */ static int check_sv(const struct ubi_volume *vol, @@ -696,50 +696,50 @@ static int check_sv(const struct ubi_volume *vol, return 0; bad: - ubi_err("bad scanning information, error %d", err); + ubi_err("bad attaching information, error %d", err); ubi_dump_sv(sv); ubi_dump_vol_info(vol); return -EINVAL; } /** - * check_scanning_info - check that scanning information. + * check_scanning_info - check that attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * Even though we protect on-flash data by CRC checksums, we still don't trust - * the media. This function ensures that scanning information is consistent to + * the media. This function ensures that attaching information is consistent to * the information read from the volume table. Returns zero if the scanning * information is OK and %-EINVAL if it is not. */ static int check_scanning_info(const struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { int err, i; struct ubi_ainf_volume *sv; struct ubi_volume *vol; - if (si->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { + if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { ubi_err("scanning found %d volumes, maximum is %d + %d", - si->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); + ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); return -EINVAL; } - if (si->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && - si->highest_vol_id < UBI_INTERNAL_VOL_START) { + if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && + ai->highest_vol_id < UBI_INTERNAL_VOL_START) { ubi_err("too large volume ID %d found by scanning", - si->highest_vol_id); + ai->highest_vol_id); return -EINVAL; } for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - sv = ubi_scan_find_sv(si, i); + sv = ubi_scan_find_sv(ai, i); vol = ubi->volumes[i]; if (!vol) { if (sv) - ubi_scan_rm_volume(si, sv); + ubi_scan_rm_volume(ai, sv); continue; } @@ -757,7 +757,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * these eraseblocks. */ ubi_msg("finish volume %d removal", sv->vol_id); - ubi_scan_rm_volume(si, sv); + ubi_scan_rm_volume(ai, sv); } else if (sv) { err = check_sv(vol, sv); if (err) @@ -771,13 +771,13 @@ static int check_scanning_info(const struct ubi_device *ubi, /** * ubi_read_volume_table - read the volume table. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function reads volume table, checks it, recover from errors if needed, * or creates it if needed. Returns zero in case of success and a negative * error code in case of failure. */ -int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) +int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) { int i, err; struct ubi_ainf_volume *sv; @@ -795,7 +795,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); - sv = ubi_scan_find_sv(si, UBI_LAYOUT_VOLUME_ID); + sv = ubi_scan_find_sv(ai, UBI_LAYOUT_VOLUME_ID); if (!sv) { /* * No logical eraseblocks belonging to the layout volume were @@ -805,8 +805,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) * But if flash is not empty this must be a corruption or the * MTD device just contains garbage. */ - if (si->is_empty) { - ubi->vtbl = create_empty_lvol(ubi, si); + if (ai->is_empty) { + ubi->vtbl = create_empty_lvol(ubi, ai); if (IS_ERR(ubi->vtbl)) return PTR_ERR(ubi->vtbl); } else { @@ -821,7 +821,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) return -EINVAL; } - ubi->vtbl = process_lvol(ubi, si, sv); + ubi->vtbl = process_lvol(ubi, ai, sv); if (IS_ERR(ubi->vtbl)) return PTR_ERR(ubi->vtbl); } @@ -832,15 +832,15 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) * The layout volume is OK, initialize the corresponding in-RAM data * structures. */ - err = init_volumes(ubi, si, ubi->vtbl); + err = init_volumes(ubi, ai, ubi->vtbl); if (err) goto out_free; /* - * Make sure that the scanning information is consistent to the + * Make sure that the attaching information is consistent to the * information stored in the volume table. */ - err = check_scanning_info(ubi, si); + err = check_scanning_info(ubi, ai); if (err) goto out_free; diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index fb870f4fc924..992240dae1b1 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1373,14 +1373,14 @@ static void cancel_pending(struct ubi_device *ubi) } /** - * ubi_wl_init_scan - initialize the WL sub-system using scanning information. + * ubi_wl_init_scan - initialize the WL sub-system using attaching information. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function returns zero in case of success, and a negative error code in * case of failure. */ -int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) +int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; struct rb_node *rb1, *rb2; @@ -1392,7 +1392,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) spin_lock_init(&ubi->wl_lock); mutex_init(&ubi->move_mutex); init_rwsem(&ubi->work_sem); - ubi->max_ec = si->max_ec; + ubi->max_ec = ai->max_ec; INIT_LIST_HEAD(&ubi->works); sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); @@ -1406,7 +1406,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) INIT_LIST_HEAD(&ubi->pq[i]); ubi->pq_head = 0; - list_for_each_entry_safe(aeb, tmp, &si->erase, u.list) { + list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); @@ -1422,7 +1422,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) } } - list_for_each_entry(aeb, &si->free, u.list) { + list_for_each_entry(aeb, &ai->free, u.list) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); @@ -1436,7 +1436,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ubi->lookuptbl[e->pnum] = e; } - ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { + ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { cond_resched(); -- cgit v1.2.3-59-g8ed1b From 517af48c0540e61bbe0ebbb5f463afe937b73894 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 14:38:34 +0300 Subject: UBI: rename sv to av After re-naming the 'struct ubi_scan_volume' we should adjust all variables named 'sv' to something else, because 'sv' stands for "scanning volume". Let's rename it to 'av' which stands for "attaching volume" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/debug.c | 22 ++--- drivers/mtd/ubi/debug.h | 2 +- drivers/mtd/ubi/eba.c | 10 +- drivers/mtd/ubi/scan.c | 240 ++++++++++++++++++++++++------------------------ drivers/mtd/ubi/scan.h | 12 +-- drivers/mtd/ubi/vtbl.c | 72 +++++++-------- drivers/mtd/ubi/wl.c | 6 +- 7 files changed, 182 insertions(+), 182 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 84362a802999..9f957c2d48e9 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -171,20 +171,20 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) } /** - * ubi_dump_sv - dump a &struct ubi_ainf_volume object. - * @sv: the object to dump + * ubi_dump_av - dump a &struct ubi_ainf_volume object. + * @av: the object to dump */ -void ubi_dump_sv(const struct ubi_ainf_volume *sv) +void ubi_dump_av(const struct ubi_ainf_volume *av) { printk(KERN_DEBUG "Volume attaching information dump:\n"); - printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); - printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum); - printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count); - printk(KERN_DEBUG "\tcompat %d\n", sv->compat); - printk(KERN_DEBUG "\tvol_type %d\n", sv->vol_type); - printk(KERN_DEBUG "\tused_ebs %d\n", sv->used_ebs); - printk(KERN_DEBUG "\tlast_data_size %d\n", sv->last_data_size); - printk(KERN_DEBUG "\tdata_pad %d\n", sv->data_pad); + printk(KERN_DEBUG "\tvol_id %d\n", av->vol_id); + printk(KERN_DEBUG "\thighest_lnum %d\n", av->highest_lnum); + printk(KERN_DEBUG "\tleb_count %d\n", av->leb_count); + printk(KERN_DEBUG "\tcompat %d\n", av->compat); + printk(KERN_DEBUG "\tvol_type %d\n", av->vol_type); + printk(KERN_DEBUG "\tused_ebs %d\n", av->used_ebs); + printk(KERN_DEBUG "\tlast_data_size %d\n", av->last_data_size); + printk(KERN_DEBUG "\tdata_pad %d\n", av->data_pad); } /** diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index a0911c0c1064..d5d2645b51a7 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -59,7 +59,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dump_vol_info(const struct ubi_volume *vol); void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); -void ubi_dump_sv(const struct ubi_ainf_volume *sv); +void ubi_dump_av(const struct ubi_ainf_volume *av); void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type); void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 320372715405..572281a9a63c 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1215,7 +1215,7 @@ static void print_rsvd_warning(struct ubi_device *ubi, int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) { int i, j, err, num_volumes; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_volume *vol; struct ubi_ainf_peb *aeb; struct rb_node *rb; @@ -1246,17 +1246,17 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) for (j = 0; j < vol->reserved_pebs; j++) vol->eba_tbl[j] = UBI_LEB_UNMAPPED; - sv = ubi_scan_find_sv(ai, idx2vol_id(ubi, i)); - if (!sv) + av = ubi_scan_find_av(ai, idx2vol_id(ubi, i)); + if (!av) continue; - ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) { if (aeb->lnum >= vol->reserved_pebs) /* * This may happen in case of an unclean reboot * during re-size. */ - ubi_scan_move_to_list(sv, aeb, &ai->erase); + ubi_scan_move_to_list(av, aeb, &ai->erase); vol->eba_tbl[aeb->lnum] = aeb->pnum; } } diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 4145a042c8e1..795d5ed70424 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -168,7 +168,7 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) /** * validate_vid_hdr - check volume identifier header. * @vid_hdr: the volume identifier header to check - * @sv: information about the volume this logical eraseblock belongs to + * @av: information about the volume this logical eraseblock belongs to * @pnum: physical eraseblock number the VID header came from * * This function checks that data stored in @vid_hdr is consistent. Returns @@ -180,15 +180,15 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) * headers of the same volume. */ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, - const struct ubi_ainf_volume *sv, int pnum) + const struct ubi_ainf_volume *av, int pnum) { int vol_type = vid_hdr->vol_type; int vol_id = be32_to_cpu(vid_hdr->vol_id); int used_ebs = be32_to_cpu(vid_hdr->used_ebs); int data_pad = be32_to_cpu(vid_hdr->data_pad); - if (sv->leb_count != 0) { - int sv_vol_type; + if (av->leb_count != 0) { + int av_vol_type; /* * This is not the first logical eraseblock belonging to this @@ -196,27 +196,27 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, * to the data in previous logical eraseblock headers. */ - if (vol_id != sv->vol_id) { + if (vol_id != av->vol_id) { ubi_err("inconsistent vol_id"); goto bad; } - if (sv->vol_type == UBI_STATIC_VOLUME) - sv_vol_type = UBI_VID_STATIC; + if (av->vol_type == UBI_STATIC_VOLUME) + av_vol_type = UBI_VID_STATIC; else - sv_vol_type = UBI_VID_DYNAMIC; + av_vol_type = UBI_VID_DYNAMIC; - if (vol_type != sv_vol_type) { + if (vol_type != av_vol_type) { ubi_err("inconsistent vol_type"); goto bad; } - if (used_ebs != sv->used_ebs) { + if (used_ebs != av->used_ebs) { ubi_err("inconsistent used_ebs"); goto bad; } - if (data_pad != sv->data_pad) { + if (data_pad != av->data_pad) { ubi_err("inconsistent data_pad"); goto bad; } @@ -227,7 +227,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, bad: ubi_err("inconsistent VID header at PEB %d", pnum); ubi_dump_vid_hdr(vid_hdr); - ubi_dump_sv(sv); + ubi_dump_av(av); return -EINVAL; } @@ -248,7 +248,7 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai, int vol_id, int pnum, const struct ubi_vid_hdr *vid_hdr) { - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; ubi_assert(vol_id == be32_to_cpu(vid_hdr->vol_id)); @@ -256,38 +256,38 @@ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai, /* Walk the volume RB-tree to look if this volume is already present */ while (*p) { parent = *p; - sv = rb_entry(parent, struct ubi_ainf_volume, rb); + av = rb_entry(parent, struct ubi_ainf_volume, rb); - if (vol_id == sv->vol_id) - return sv; + if (vol_id == av->vol_id) + return av; - if (vol_id > sv->vol_id) + if (vol_id > av->vol_id) p = &(*p)->rb_left; else p = &(*p)->rb_right; } /* The volume is absent - add it */ - sv = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); - if (!sv) + av = kmalloc(sizeof(struct ubi_ainf_volume), GFP_KERNEL); + if (!av) return ERR_PTR(-ENOMEM); - sv->highest_lnum = sv->leb_count = 0; - sv->vol_id = vol_id; - sv->root = RB_ROOT; - sv->used_ebs = be32_to_cpu(vid_hdr->used_ebs); - sv->data_pad = be32_to_cpu(vid_hdr->data_pad); - sv->compat = vid_hdr->compat; - sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME + av->highest_lnum = av->leb_count = 0; + av->vol_id = vol_id; + av->root = RB_ROOT; + av->used_ebs = be32_to_cpu(vid_hdr->used_ebs); + av->data_pad = be32_to_cpu(vid_hdr->data_pad); + av->compat = vid_hdr->compat; + av->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; if (vol_id > ai->highest_vol_id) ai->highest_vol_id = vol_id; - rb_link_node(&sv->rb, parent, p); - rb_insert_color(&sv->rb, &ai->volumes); + rb_link_node(&av->rb, parent, p); + rb_insert_color(&av->rb, &ai->volumes); ai->vols_found += 1; dbg_bld("added volume %d", vol_id); - return sv; + return av; } /** @@ -446,7 +446,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, { int err, vol_id, lnum; unsigned long long sqnum; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_ainf_peb *aeb; struct rb_node **p, *parent = NULL; @@ -457,9 +457,9 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, dbg_bld("PEB %d, LEB %d:%d, EC %d, sqnum %llu, bitflips %d", pnum, vol_id, lnum, ec, sqnum, bitflips); - sv = add_volume(ai, vol_id, pnum, vid_hdr); - if (IS_ERR(sv)) - return PTR_ERR(sv); + av = add_volume(ai, vol_id, pnum, vid_hdr); + if (IS_ERR(av)) + return PTR_ERR(av); if (ai->max_sqnum < sqnum) ai->max_sqnum = sqnum; @@ -468,7 +468,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, * Walk the RB-tree of logical eraseblocks of volume @vol_id to look * if this is the first instance of this logical eraseblock or not. */ - p = &sv->root.rb_node; + p = &av->root.rb_node; while (*p) { int cmp_res; @@ -524,7 +524,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, * This logical eraseblock is newer than the one * found earlier. */ - err = validate_vid_hdr(vid_hdr, sv, pnum); + err = validate_vid_hdr(vid_hdr, av, pnum); if (err) return err; @@ -539,8 +539,8 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, aeb->copy_flag = vid_hdr->copy_flag; aeb->sqnum = sqnum; - if (sv->highest_lnum == lnum) - sv->last_data_size = + if (av->highest_lnum == lnum) + av->last_data_size = be32_to_cpu(vid_hdr->data_size); return 0; @@ -559,7 +559,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, * attaching information. */ - err = validate_vid_hdr(vid_hdr, sv, pnum); + err = validate_vid_hdr(vid_hdr, av, pnum); if (err) return err; @@ -574,38 +574,38 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, aeb->copy_flag = vid_hdr->copy_flag; aeb->sqnum = sqnum; - if (sv->highest_lnum <= lnum) { - sv->highest_lnum = lnum; - sv->last_data_size = be32_to_cpu(vid_hdr->data_size); + if (av->highest_lnum <= lnum) { + av->highest_lnum = lnum; + av->last_data_size = be32_to_cpu(vid_hdr->data_size); } - sv->leb_count += 1; + av->leb_count += 1; rb_link_node(&aeb->u.rb, parent, p); - rb_insert_color(&aeb->u.rb, &sv->root); + rb_insert_color(&aeb->u.rb, &av->root); return 0; } /** - * ubi_scan_find_sv - find volume in the attaching information. + * ubi_scan_find_av - find volume in the attaching information. * @ai: attaching information * @vol_id: the requested volume ID * * This function returns a pointer to the volume description or %NULL if there * are no data about this volume in the attaching information. */ -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai, +struct ubi_ainf_volume *ubi_scan_find_av(const struct ubi_attach_info *ai, int vol_id) { - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct rb_node *p = ai->volumes.rb_node; while (p) { - sv = rb_entry(p, struct ubi_ainf_volume, rb); + av = rb_entry(p, struct ubi_ainf_volume, rb); - if (vol_id == sv->vol_id) - return sv; + if (vol_id == av->vol_id) + return av; - if (vol_id > sv->vol_id) + if (vol_id > av->vol_id) p = p->rb_left; else p = p->rb_right; @@ -616,17 +616,17 @@ struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai, /** * ubi_scan_find_aeb - find LEB in the volume attaching information. - * @sv: a pointer to the volume attaching information + * @av: a pointer to the volume attaching information * @lnum: the requested logical eraseblock * * This function returns a pointer to the scanning logical eraseblock or %NULL * if there are no data about it in the scanning volume information. */ -struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *av, int lnum) { struct ubi_ainf_peb *aeb; - struct rb_node *p = sv->root.rb_node; + struct rb_node *p = av->root.rb_node; while (p) { aeb = rb_entry(p, struct ubi_ainf_peb, u.rb); @@ -646,23 +646,23 @@ struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, /** * ubi_scan_rm_volume - delete attaching information about a volume. * @ai: attaching information - * @sv: the volume attaching information to delete + * @av: the volume attaching information to delete */ -void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) +void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av) { struct rb_node *rb; struct ubi_ainf_peb *aeb; - dbg_bld("remove attaching information about volume %d", sv->vol_id); + dbg_bld("remove attaching information about volume %d", av->vol_id); - while ((rb = rb_first(&sv->root))) { + while ((rb = rb_first(&av->root))) { aeb = rb_entry(rb, struct ubi_ainf_peb, u.rb); - rb_erase(&aeb->u.rb, &sv->root); + rb_erase(&aeb->u.rb, &av->root); list_add_tail(&aeb->u.list, &ai->erase); } - rb_erase(&sv->rb, &ai->volumes); - kfree(sv); + rb_erase(&av->rb, &ai->volumes); + kfree(av); ai->vols_found -= 1; } @@ -1148,7 +1148,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) { int err, pnum; struct rb_node *rb1, *rb2; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_ainf_peb *aeb; struct ubi_attach_info *ai; @@ -1200,8 +1200,8 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) * In case of unknown erase counter we use the mean erase counter * value. */ - ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { - ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) { + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) if (aeb->ec == UBI_SCAN_UNKNOWN_EC) aeb->ec = ai->mean_ec; } @@ -1238,17 +1238,17 @@ out_ai: } /** - * destroy_sv - free the scanning volume information - * @sv: scanning volume information + * destroy_av - free the scanning volume information + * @av: scanning volume information * @ai: attaching information * - * This function destroys the volume RB-tree (@sv->root) and the scanning + * This function destroys the volume RB-tree (@av->root) and the scanning * volume information. */ -static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) +static void destroy_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av) { struct ubi_ainf_peb *aeb; - struct rb_node *this = sv->root.rb_node; + struct rb_node *this = av->root.rb_node; while (this) { if (this->rb_left) @@ -1268,7 +1268,7 @@ static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) kmem_cache_free(ai->scan_leb_slab, aeb); } } - kfree(sv); + kfree(av); } /** @@ -1278,7 +1278,7 @@ static void destroy_sv(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) void ubi_scan_destroy_ai(struct ubi_attach_info *ai) { struct ubi_ainf_peb *aeb, *aeb_tmp; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct rb_node *rb; list_for_each_entry_safe(aeb, aeb_tmp, &ai->alien, u.list) { @@ -1306,17 +1306,17 @@ void ubi_scan_destroy_ai(struct ubi_attach_info *ai) else if (rb->rb_right) rb = rb->rb_right; else { - sv = rb_entry(rb, struct ubi_ainf_volume, rb); + av = rb_entry(rb, struct ubi_ainf_volume, rb); rb = rb_parent(rb); if (rb) { - if (rb->rb_left == &sv->rb) + if (rb->rb_left == &av->rb) rb->rb_left = NULL; else rb->rb_right = NULL; } - destroy_sv(ai, sv); + destroy_av(ai, av); } } @@ -1338,7 +1338,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) { int pnum, err, vols_found = 0; struct rb_node *rb1, *rb2; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_ainf_peb *aeb, *last_aeb; uint8_t *buf; @@ -1348,7 +1348,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) /* * At first, check that attaching information is OK. */ - ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) { int leb_count = 0; cond_resched(); @@ -1357,41 +1357,41 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) if (ai->is_empty) { ubi_err("bad is_empty flag"); - goto bad_sv; + goto bad_av; } - if (sv->vol_id < 0 || sv->highest_lnum < 0 || - sv->leb_count < 0 || sv->vol_type < 0 || sv->used_ebs < 0 || - sv->data_pad < 0 || sv->last_data_size < 0) { + if (av->vol_id < 0 || av->highest_lnum < 0 || + av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 || + av->data_pad < 0 || av->last_data_size < 0) { ubi_err("negative values"); - goto bad_sv; + goto bad_av; } - if (sv->vol_id >= UBI_MAX_VOLUMES && - sv->vol_id < UBI_INTERNAL_VOL_START) { + if (av->vol_id >= UBI_MAX_VOLUMES && + av->vol_id < UBI_INTERNAL_VOL_START) { ubi_err("bad vol_id"); - goto bad_sv; + goto bad_av; } - if (sv->vol_id > ai->highest_vol_id) { + if (av->vol_id > ai->highest_vol_id) { ubi_err("highest_vol_id is %d, but vol_id %d is there", - ai->highest_vol_id, sv->vol_id); + ai->highest_vol_id, av->vol_id); goto out; } - if (sv->vol_type != UBI_DYNAMIC_VOLUME && - sv->vol_type != UBI_STATIC_VOLUME) { + if (av->vol_type != UBI_DYNAMIC_VOLUME && + av->vol_type != UBI_STATIC_VOLUME) { ubi_err("bad vol_type"); - goto bad_sv; + goto bad_av; } - if (sv->data_pad > ubi->leb_size / 2) { + if (av->data_pad > ubi->leb_size / 2) { ubi_err("bad data_pad"); - goto bad_sv; + goto bad_av; } last_aeb = NULL; - ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) { cond_resched(); last_aeb = aeb; @@ -1420,28 +1420,28 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) goto bad_aeb; } - if (sv->vol_type == UBI_STATIC_VOLUME) { - if (aeb->lnum >= sv->used_ebs) { + if (av->vol_type == UBI_STATIC_VOLUME) { + if (aeb->lnum >= av->used_ebs) { ubi_err("bad lnum or used_ebs"); goto bad_aeb; } } else { - if (sv->used_ebs != 0) { + if (av->used_ebs != 0) { ubi_err("non-zero used_ebs"); goto bad_aeb; } } - if (aeb->lnum > sv->highest_lnum) { + if (aeb->lnum > av->highest_lnum) { ubi_err("incorrect highest_lnum or lnum"); goto bad_aeb; } } - if (sv->leb_count != leb_count) { + if (av->leb_count != leb_count) { ubi_err("bad leb_count, %d objects in the tree", leb_count); - goto bad_sv; + goto bad_av; } if (!last_aeb) @@ -1449,7 +1449,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) aeb = last_aeb; - if (aeb->lnum != sv->highest_lnum) { + if (aeb->lnum != av->highest_lnum) { ubi_err("bad highest_lnum"); goto bad_aeb; } @@ -1462,9 +1462,9 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) } /* Check that attaching information is correct */ - ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) { last_aeb = NULL; - ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) { int vol_type; cond_resched(); @@ -1481,7 +1481,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) vol_type = vidh->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; - if (sv->vol_type != vol_type) { + if (av->vol_type != vol_type) { ubi_err("bad vol_type"); goto bad_vid_hdr; } @@ -1491,12 +1491,12 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) goto bad_vid_hdr; } - if (sv->vol_id != be32_to_cpu(vidh->vol_id)) { - ubi_err("bad vol_id %d", sv->vol_id); + if (av->vol_id != be32_to_cpu(vidh->vol_id)) { + ubi_err("bad vol_id %d", av->vol_id); goto bad_vid_hdr; } - if (sv->compat != vidh->compat) { + if (av->compat != vidh->compat) { ubi_err("bad compat %d", vidh->compat); goto bad_vid_hdr; } @@ -1506,13 +1506,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) goto bad_vid_hdr; } - if (sv->used_ebs != be32_to_cpu(vidh->used_ebs)) { - ubi_err("bad used_ebs %d", sv->used_ebs); + if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) { + ubi_err("bad used_ebs %d", av->used_ebs); goto bad_vid_hdr; } - if (sv->data_pad != be32_to_cpu(vidh->data_pad)) { - ubi_err("bad data_pad %d", sv->data_pad); + if (av->data_pad != be32_to_cpu(vidh->data_pad)) { + ubi_err("bad data_pad %d", av->data_pad); goto bad_vid_hdr; } } @@ -1520,13 +1520,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) if (!last_aeb) continue; - if (sv->highest_lnum != be32_to_cpu(vidh->lnum)) { - ubi_err("bad highest_lnum %d", sv->highest_lnum); + if (av->highest_lnum != be32_to_cpu(vidh->lnum)) { + ubi_err("bad highest_lnum %d", av->highest_lnum); goto bad_vid_hdr; } - if (sv->last_data_size != be32_to_cpu(vidh->data_size)) { - ubi_err("bad last_data_size %d", sv->last_data_size); + if (av->last_data_size != be32_to_cpu(vidh->data_size)) { + ubi_err("bad last_data_size %d", av->last_data_size); goto bad_vid_hdr; } } @@ -1548,8 +1548,8 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) buf[pnum] = 1; } - ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) - ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) buf[aeb->pnum] = 1; list_for_each_entry(aeb, &ai->free, u.list) @@ -1579,17 +1579,17 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) bad_aeb: ubi_err("bad attaching information about LEB %d", aeb->lnum); ubi_dump_aeb(aeb, 0); - ubi_dump_sv(sv); + ubi_dump_av(av); goto out; -bad_sv: - ubi_err("bad attaching information about volume %d", sv->vol_id); - ubi_dump_sv(sv); +bad_av: + ubi_err("bad attaching information about volume %d", av->vol_id); + ubi_dump_av(av); goto out; bad_vid_hdr: - ubi_err("bad attaching information about volume %d", sv->vol_id); - ubi_dump_sv(sv); + ubi_err("bad attaching information about volume %d", av->vol_id); + ubi_dump_av(av); ubi_dump_vid_hdr(vidh); out: diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 0f0725e18b7f..3e19cb665a55 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -145,26 +145,26 @@ struct ubi_vid_hdr; /* * ubi_scan_move_to_list - move a PEB from the volume tree to a list. * - * @sv: volume attaching information + * @av: volume attaching information * @aeb: scanning eraseblock information * @list: the list to move to */ -static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, +static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *av, struct ubi_ainf_peb *aeb, struct list_head *list) { - rb_erase(&aeb->u.rb, &sv->root); + rb_erase(&aeb->u.rb, &av->root); list_add_tail(&aeb->u.list, list); } int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); -struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai, +struct ubi_ainf_volume *ubi_scan_find_av(const struct ubi_attach_info *ai, int vol_id); -struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, +struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *av, int lnum); -void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv); +void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_attach_info *ai); int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai, diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 3e5363c9945e..0ea105b1a68b 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -366,7 +366,7 @@ out_free: * process_lvol - process the layout volume. * @ubi: UBI device description object * @ai: attaching information - * @sv: layout volume attaching information + * @av: layout volume attaching information * * This function is responsible for reading the layout volume, ensuring it is * not corrupted, and recovering from corruptions if needed. Returns volume @@ -374,7 +374,7 @@ out_free: */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, struct ubi_attach_info *ai, - struct ubi_ainf_volume *sv) + struct ubi_ainf_volume *av) { int err; struct rb_node *rb; @@ -410,7 +410,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, dbg_gen("check layout volume"); /* Read both LEB 0 and LEB 1 into memory */ - ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) { leb[aeb->lnum] = vzalloc(ubi->vtbl_size); if (!leb[aeb->lnum]) { err = -ENOMEM; @@ -536,7 +536,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_volume *vol; for (i = 0; i < ubi->vtbl_slots; i++) { @@ -592,8 +592,8 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - sv = ubi_scan_find_sv(ai, i); - if (!sv) { + av = ubi_scan_find_av(ai, i); + if (!av) { /* * No eraseblocks belonging to this volume found. We * don't actually know whether this static volume is @@ -605,22 +605,22 @@ static int init_volumes(struct ubi_device *ubi, continue; } - if (sv->leb_count != sv->used_ebs) { + if (av->leb_count != av->used_ebs) { /* * We found a static volume which misses several * eraseblocks. Treat it as corrupted. */ ubi_warn("static volume %d misses %d LEBs - corrupted", - sv->vol_id, sv->used_ebs - sv->leb_count); + av->vol_id, av->used_ebs - av->leb_count); vol->corrupted = 1; continue; } - vol->used_ebs = sv->used_ebs; + vol->used_ebs = av->used_ebs; vol->used_bytes = (long long)(vol->used_ebs - 1) * vol->usable_leb_size; - vol->used_bytes += sv->last_data_size; - vol->last_eb_bytes = sv->last_data_size; + vol->used_bytes += av->last_data_size; + vol->last_eb_bytes = av->last_data_size; } /* And add the layout volume */ @@ -661,35 +661,35 @@ static int init_volumes(struct ubi_device *ubi, } /** - * check_sv - check volume attaching information. + * check_av - check volume attaching information. * @vol: UBI volume description object - * @sv: volume attaching information + * @av: volume attaching information * * This function returns zero if the volume attaching information is consistent * to the data read from the volume tabla, and %-EINVAL if not. */ -static int check_sv(const struct ubi_volume *vol, - const struct ubi_ainf_volume *sv) +static int check_av(const struct ubi_volume *vol, + const struct ubi_ainf_volume *av) { int err; - if (sv->highest_lnum >= vol->reserved_pebs) { + if (av->highest_lnum >= vol->reserved_pebs) { err = 1; goto bad; } - if (sv->leb_count > vol->reserved_pebs) { + if (av->leb_count > vol->reserved_pebs) { err = 2; goto bad; } - if (sv->vol_type != vol->vol_type) { + if (av->vol_type != vol->vol_type) { err = 3; goto bad; } - if (sv->used_ebs > vol->reserved_pebs) { + if (av->used_ebs > vol->reserved_pebs) { err = 4; goto bad; } - if (sv->data_pad != vol->data_pad) { + if (av->data_pad != vol->data_pad) { err = 5; goto bad; } @@ -697,7 +697,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad attaching information, error %d", err); - ubi_dump_sv(sv); + ubi_dump_av(av); ubi_dump_vol_info(vol); return -EINVAL; } @@ -716,7 +716,7 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_volume *vol; if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { @@ -735,18 +735,18 @@ static int check_scanning_info(const struct ubi_device *ubi, for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - sv = ubi_scan_find_sv(ai, i); + av = ubi_scan_find_av(ai, i); vol = ubi->volumes[i]; if (!vol) { - if (sv) - ubi_scan_rm_volume(ai, sv); + if (av) + ubi_scan_rm_volume(ai, av); continue; } if (vol->reserved_pebs == 0) { ubi_assert(i < ubi->vtbl_slots); - if (!sv) + if (!av) continue; /* @@ -756,10 +756,10 @@ static int check_scanning_info(const struct ubi_device *ubi, * reboot while the volume was being removed. Discard * these eraseblocks. */ - ubi_msg("finish volume %d removal", sv->vol_id); - ubi_scan_rm_volume(ai, sv); - } else if (sv) { - err = check_sv(vol, sv); + ubi_msg("finish volume %d removal", av->vol_id); + ubi_scan_rm_volume(ai, av); + } else if (av) { + err = check_av(vol, av); if (err) return err; } @@ -780,7 +780,7 @@ static int check_scanning_info(const struct ubi_device *ubi, int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) { int i, err; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; empty_vtbl_record.crc = cpu_to_be32(0xf116c36b); @@ -795,8 +795,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); - sv = ubi_scan_find_sv(ai, UBI_LAYOUT_VOLUME_ID); - if (!sv) { + av = ubi_scan_find_av(ai, UBI_LAYOUT_VOLUME_ID); + if (!av) { /* * No logical eraseblocks belonging to the layout volume were * found. This could mean that the flash is just empty. In @@ -814,14 +814,14 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) return -EINVAL; } } else { - if (sv->leb_count > UBI_LAYOUT_VOLUME_EBS) { + if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) { /* This must not happen with proper UBI images */ ubi_err("too many LEBs (%d) in layout volume", - sv->leb_count); + av->leb_count); return -EINVAL; } - ubi->vtbl = process_lvol(ubi, ai, sv); + ubi->vtbl = process_lvol(ubi, ai, av); if (IS_ERR(ubi->vtbl)) return PTR_ERR(ubi->vtbl); } diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 992240dae1b1..72fbae1f0a5d 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1384,7 +1384,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; struct rb_node *rb1, *rb2; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_ainf_peb *aeb, *tmp; struct ubi_wl_entry *e; @@ -1436,8 +1436,8 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) ubi->lookuptbl[e->pnum] = e; } - ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) { - ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) { + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) { cond_resched(); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); -- cgit v1.2.3-59-g8ed1b From 3561188ac29580bdc0e8db3cf3c029b87cf2c6cd Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:31:31 +0300 Subject: UBI: rename ubi_scan_add_used The old name is not logical anymore - rename it to 'ubi_add_to_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 9 ++++----- drivers/mtd/ubi/scan.h | 5 ++--- drivers/mtd/ubi/vtbl.c | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 06151fde2cc7..366506253502 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -425,7 +425,7 @@ out_free_vidh: } /** - * ubi_scan_add_used - add physical eraseblock to the attaching information. + * ubi_add_to_av - add physical eraseblock to the attaching information. * @ubi: UBI device description object * @ai: attaching information * @pnum: the physical eraseblock number @@ -440,9 +440,8 @@ out_free_vidh: * to be picked, while the older one has to be dropped. This function returns * zero in case of success and a negative error code in case of failure. */ -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, - int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, - int bitflips) +int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, + int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips) { int err, vol_id, lnum; unsigned long long sqnum; @@ -1016,7 +1015,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *ai, if (ec_err) ubi_warn("valid VID header but corrupted EC header at PEB %d", pnum); - err = ubi_scan_add_used(ubi, ai, pnum, ec, vidh, bitflips); + err = ubi_add_to_av(ubi, ai, pnum, ec, vidh, bitflips); if (err) return err; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index ef6e903be8e0..5a9ecc0abdd2 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -157,9 +157,8 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *av, list_add_tail(&aeb->u.list, list); } -int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai, - int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, - int bitflips); +int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, + int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); struct ubi_ainf_volume *ubi_scan_find_av(const struct ubi_attach_info *ai, int vol_id); void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 0ea105b1a68b..5decd587188b 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -338,10 +338,9 @@ retry: /* * And add it to the attaching information. Don't delete the old version - * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. + * of this LEB as it will be deleted and freed in 'ubi_add_to_av()'. */ - err = ubi_scan_add_used(ubi, ai, new_aeb->pnum, new_aeb->ec, - vid_hdr, 0); + err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -428,7 +427,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, * aeb->scrub). If the data is not OK, the contents of * the PEB will be recovered from the second copy, and * aeb->scrub will be cleared in - * 'ubi_scan_add_used()'. + * 'ubi_add_to_av()'. */ aeb->scrub = 1; else if (err) -- cgit v1.2.3-59-g8ed1b From dcd85fdd1040259f0053137f252321faec0a259f Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:33:20 +0300 Subject: UBI: rename ubi_scan_find_av The old name is not logical anymore - rename it to 'ubi_find_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/eba.c | 2 +- drivers/mtd/ubi/scan.c | 6 +++--- drivers/mtd/ubi/scan.h | 4 ++-- drivers/mtd/ubi/vtbl.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 572281a9a63c..6f7f27566524 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1246,7 +1246,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai) for (j = 0; j < vol->reserved_pebs; j++) vol->eba_tbl[j] = UBI_LEB_UNMAPPED; - av = ubi_scan_find_av(ai, idx2vol_id(ubi, i)); + av = ubi_find_av(ai, idx2vol_id(ubi, i)); if (!av) continue; diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 366506253502..767b857f3054 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -585,15 +585,15 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, } /** - * ubi_scan_find_av - find volume in the attaching information. + * ubi_find_av - find volume in the attaching information. * @ai: attaching information * @vol_id: the requested volume ID * * This function returns a pointer to the volume description or %NULL if there * are no data about this volume in the attaching information. */ -struct ubi_ainf_volume *ubi_scan_find_av(const struct ubi_attach_info *ai, - int vol_id) +struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai, + int vol_id) { struct ubi_ainf_volume *av; struct rb_node *p = ai->volumes.rb_node; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 5a9ecc0abdd2..b1eeb0bda0e7 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -159,8 +159,8 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *av, int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); -struct ubi_ainf_volume *ubi_scan_find_av(const struct ubi_attach_info *ai, - int vol_id); +struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai, + int vol_id); void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_attach_info *ai); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 5decd587188b..0c8c17282c81 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -591,7 +591,7 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - av = ubi_scan_find_av(ai, i); + av = ubi_find_av(ai, i); if (!av) { /* * No eraseblocks belonging to this volume found. We @@ -734,7 +734,7 @@ static int check_scanning_info(const struct ubi_device *ubi, for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - av = ubi_scan_find_av(ai, i); + av = ubi_find_av(ai, i); vol = ubi->volumes[i]; if (!vol) { if (av) @@ -794,7 +794,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); - av = ubi_scan_find_av(ai, UBI_LAYOUT_VOLUME_ID); + av = ubi_find_av(ai, UBI_LAYOUT_VOLUME_ID); if (!av) { /* * No logical eraseblocks belonging to the layout volume were -- cgit v1.2.3-59-g8ed1b From d717dc2f85f07f68d313ac4f8f9f460f1e17dee0 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:36:39 +0300 Subject: UBI: rename ubi_scan_rm_volume The old name is not logical anymore - rename it to 'ubi_remove_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 4 ++-- drivers/mtd/ubi/scan.h | 2 +- drivers/mtd/ubi/vtbl.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 767b857f3054..ccf46308fbb6 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -614,11 +614,11 @@ struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai, } /** - * ubi_scan_rm_volume - delete attaching information about a volume. + * ubi_remove_av - delete attaching information about a volume. * @ai: attaching information * @av: the volume attaching information to delete */ -void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av) +void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av) { struct rb_node *rb; struct ubi_ainf_peb *aeb; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index b1eeb0bda0e7..7d7e65f11f14 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -161,7 +161,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips); struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai, int vol_id); -void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); +void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_attach_info *ai); struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 0c8c17282c81..cfe3830759bd 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -738,7 +738,7 @@ static int check_scanning_info(const struct ubi_device *ubi, vol = ubi->volumes[i]; if (!vol) { if (av) - ubi_scan_rm_volume(ai, av); + ubi_remove_av(ai, av); continue; } @@ -756,7 +756,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * these eraseblocks. */ ubi_msg("finish volume %d removal", av->vol_id); - ubi_scan_rm_volume(ai, av); + ubi_remove_av(ai, av); } else if (av) { err = check_av(vol, av); if (err) -- cgit v1.2.3-59-g8ed1b From c87fbd7deb08315314654de5360c102acc8716ee Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:38:56 +0300 Subject: UBI: rename ubi_scan_get_free_peb The old name is not logical anymore - rename it to 'ubi_early_get_peb()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 6 +++--- drivers/mtd/ubi/scan.h | 4 ++-- drivers/mtd/ubi/vtbl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index ccf46308fbb6..2c5a558dc844 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -682,7 +682,7 @@ out_free: } /** - * ubi_scan_get_free_peb - get a free physical eraseblock. + * ubi_early_get_peb - get a free physical eraseblock. * @ubi: UBI device description object * @ai: attaching information * @@ -695,8 +695,8 @@ out_free: * This function returns scanning physical eraseblock information in case of * success and an error code in case of failure. */ -struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_attach_info *ai) +struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi, + struct ubi_attach_info *ai) { int err = 0; struct ubi_ainf_peb *aeb, *tmp_aeb; diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 7d7e65f11f14..72ba24a13a72 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -162,8 +162,8 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai, int vol_id); void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av); -struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, - struct ubi_attach_info *ai); +struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi, + struct ubi_attach_info *ai); struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); void ubi_scan_destroy_ai(struct ubi_attach_info *ai); diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index cfe3830759bd..341c956c8cdb 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai, return -ENOMEM; retry: - new_aeb = ubi_scan_get_free_peb(ubi, ai); + new_aeb = ubi_early_get_peb(ubi, ai); if (IS_ERR(new_aeb)) { err = PTR_ERR(new_aeb); goto out_free; -- cgit v1.2.3-59-g8ed1b From fbd0107f4d33be01c9fb2c630036bd66b7e3d4dc Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 16:12:26 +0300 Subject: UBI: amend comments after all the renamings This patch amends commentaries in scan.[ch] to match the new logic. Reminder - we did the restructuring to prepare the code for adding the fastmap. This patch also renames a couple of functions - it was too difficult to separate out that change and I decided that it is not too bad to have it in the same patch with commentaries changes. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 12 ++--- drivers/mtd/ubi/io.c | 3 +- drivers/mtd/ubi/scan.c | 111 ++++++++++++++++++++++---------------------- drivers/mtd/ubi/scan.h | 2 +- drivers/mtd/ubi/ubi-media.h | 4 +- drivers/mtd/ubi/vtbl.c | 22 ++++----- 6 files changed, 73 insertions(+), 81 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 2a8f26b560f6..7f293b284ddb 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -27,10 +27,6 @@ * module load parameters or the kernel boot parameters. If MTD devices were * specified, UBI does not attach any MTD device, but it is possible to do * later using the "UBI control device". - * - * At the moment we only attach UBI devices by scanning, which will become a - * bottleneck when flashes reach certain large size. Then one may improve UBI - * and add other methods, although it does not seem to be easy to do. */ #include @@ -790,11 +786,11 @@ static int io_init(struct ubi_device *ubi) ubi_msg("data offset: %d", ubi->leb_start); /* - * Note, ideally, we have to initialize ubi->bad_peb_count here. But + * Note, ideally, we have to initialize @ubi->bad_peb_count here. But * unfortunately, MTD does not provide this information. We should loop * over all physical eraseblocks and invoke mtd->block_is_bad() for - * each physical eraseblock. So, we skip ubi->bad_peb_count - * uninitialized and initialize it after scanning. + * each physical eraseblock. So, we leave @ubi->bad_peb_count + * uninitialized so far. */ return 0; @@ -805,7 +801,7 @@ static int io_init(struct ubi_device *ubi) * @ubi: UBI device description object * @vol_id: ID of the volume to re-size * - * This function re-sizes the volume marked by the @UBI_VTBL_AUTORESIZE_FLG in + * This function re-sizes the volume marked by the %UBI_VTBL_AUTORESIZE_FLG in * the volume table to the largest possible size. See comments in ubi-header.h * for more description of the flag. Returns zero in case of success and a * negative error code in case of failure. diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index c37298577789..a8d523794b52 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -513,8 +513,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum) * It is important to first invalidate the EC header, and then the VID * header. Otherwise a power cut may lead to valid EC header and * invalid VID header, in which case UBI will treat this PEB as - * corrupted and will try to preserve it, and print scary warnings (see - * the header comment in scan.c for more information). + * corrupted and will try to preserve it, and print scary warnings. */ addr = (loff_t)pnum * ubi->peb_size; err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 06a2d7062136..93257f3c25d0 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -19,21 +19,21 @@ */ /* - * UBI scanning sub-system. + * UBI attaching sub-system. * - * This sub-system is responsible for scanning the flash media, checking UBI - * headers and providing complete information about the UBI flash image. + * This sub-system is responsible for attaching MTD devices and it also + * implements flash media scanning. * * The attaching information is represented by a &struct ubi_attach_info' - * object. Information about found volumes is represented by - * &struct ubi_ainf_volume objects which are kept in volume RB-tree with root - * at the @volumes field. The RB-tree is indexed by the volume ID. + * object. Information about volumes is represented by &struct ubi_ainf_volume + * objects which are kept in volume RB-tree with root at the @volumes field. + * The RB-tree is indexed by the volume ID. * - * Scanned logical eraseblocks are represented by &struct ubi_ainf_peb objects. - * These objects are kept in per-volume RB-trees with the root at the - * corresponding &struct ubi_ainf_volume object. To put it differently, we keep - * an RB-tree of per-volume objects and each of these objects is the root of - * RB-tree of per-eraseblock objects. + * Logical eraseblocks are represented by &struct ubi_ainf_peb objects. These + * objects are kept in per-volume RB-trees with the root at the corresponding + * &struct ubi_ainf_volume object. To put it differently, we keep an RB-tree of + * per-volume objects and each of these objects is the root of RB-tree of + * per-LEB objects. * * Corrupted physical eraseblocks are put to the @corr list, free physical * eraseblocks are put to the @free list and the physical eraseblock to be @@ -51,28 +51,29 @@ * * 1. Corruptions caused by power cuts. These are expected corruptions and UBI * tries to handle them gracefully, without printing too many warnings and - * error messages. The idea is that we do not lose important data in these case - * - we may lose only the data which was being written to the media just before - * the power cut happened, and the upper layers (e.g., UBIFS) are supposed to - * handle such data losses (e.g., by using the FS journal). + * error messages. The idea is that we do not lose important data in these + * cases - we may lose only the data which were being written to the media just + * before the power cut happened, and the upper layers (e.g., UBIFS) are + * supposed to handle such data losses (e.g., by using the FS journal). * * When UBI detects a corruption (CRC-32 mismatch) in a PEB, and it looks like * the reason is a power cut, UBI puts this PEB to the @erase list, and all * PEBs in the @erase list are scheduled for erasure later. * * 2. Unexpected corruptions which are not caused by power cuts. During - * scanning, such PEBs are put to the @corr list and UBI preserves them. + * attaching, such PEBs are put to the @corr list and UBI preserves them. * Obviously, this lessens the amount of available PEBs, and if at some point * UBI runs out of free PEBs, it switches to R/O mode. UBI also loudly informs * about such PEBs every time the MTD device is attached. * * However, it is difficult to reliably distinguish between these types of - * corruptions and UBI's strategy is as follows. UBI assumes corruption type 2 - * if the VID header is corrupted and the data area does not contain all 0xFFs, - * and there were no bit-flips or integrity errors while reading the data area. - * Otherwise UBI assumes corruption type 1. So the decision criteria are as - * follows. - * o If the data area contains only 0xFFs, there is no data, and it is safe + * corruptions and UBI's strategy is as follows (in case of attaching by + * scanning). UBI assumes corruption type 2 if the VID header is corrupted and + * the data area does not contain all 0xFFs, and there were no bit-flips or + * integrity errors (e.g., ECC errors in case of NAND) while reading the data + * area. Otherwise UBI assumes corruption type 1. So the decision criteria + * are as follows. + * o If the data area contains only 0xFFs, there are no data, and it is safe * to just erase this PEB - this is corruption type 1. * o If the data area has bit-flips or data integrity errors (ECC errors on * NAND), it is probably a PEB which was being erased when power cut @@ -102,7 +103,8 @@ static struct ubi_vid_hdr *vidh; * @to_head: if not zero, add to the head of the list * @list: the list to add to * - * This function adds physical eraseblock @pnum to free, erase, or alien lists. + * This function allocates a 'struct ubi_ainf_peb' object for physical + * eraseblock @pnum and adds it to the "free", "erase", or "alien" lists. * If @to_head is not zero, PEB will be added to the head of the list, which * basically means it will be processed first later. E.g., we add corrupted * PEBs (corrupted due to power cuts) to the head of the erase list to make @@ -144,9 +146,10 @@ static int add_to_list(struct ubi_attach_info *ai, int pnum, int ec, * @pnum: physical eraseblock number to add * @ec: erase counter of the physical eraseblock * - * This function adds corrupted physical eraseblock @pnum to the 'corr' list. - * The corruption was presumably not caused by a power cut. Returns zero in - * case of success and a negative error code in case of failure. + * This function allocates a 'struct ubi_ainf_peb' object for a corrupted + * physical eraseblock @pnum and adds it to the 'corr' list. The corruption + * was presumably not caused by a power cut. Returns zero in case of success + * and a negative error code in case of failure. */ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) { @@ -241,8 +244,8 @@ bad: * If the volume corresponding to the @vid_hdr logical eraseblock is already * present in the attaching information, this function does nothing. Otherwise * it adds corresponding volume to the attaching information. Returns a pointer - * to the scanning volume object in case of success and a negative error code - * in case of failure. + * to the allocated "av" object in case of success and a negative error code in + * case of failure. */ static struct ubi_ainf_volume *add_volume(struct ubi_attach_info *ai, int vol_id, int pnum, @@ -425,7 +428,7 @@ out_free_vidh: } /** - * ubi_add_to_av - add physical eraseblock to the attaching information. + * ubi_add_to_av - add used physical eraseblock to the attaching information. * @ubi: UBI device description object * @ai: attaching information * @pnum: the physical eraseblock number @@ -692,8 +695,8 @@ out_free: * the lists, writes the EC header if it is needed, and removes it from the * list. * - * This function returns scanning physical eraseblock information in case of - * success and an error code in case of failure. + * This function returns a pointer to the "aeb" of the found free PEB in case + * of success and an error code in case of failure. */ struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi, struct ubi_attach_info *ai) @@ -793,16 +796,18 @@ out_unlock: } /** - * process_eb - read, check UBI headers, and add them to attaching information. + * scan_peb - scan and process UBI headers of a PEB. * @ubi: UBI device description object * @ai: attaching information * @pnum: the physical eraseblock number * - * This function returns a zero if the physical eraseblock was successfully - * handled and a negative error code in case of failure. + * This function reads UBI headers of PEB @pnum, checks them, and adds + * information about this PEB to the corresponding list or RB-tree in the + * "attaching info" structure. Returns zero if the physical eraseblock was + * successfully handled and a negative error code in case of failure. */ -static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *ai, - int pnum) +static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, + int pnum) { long long uninitialized_var(ec); int err, bitflips = 0, vol_id, ec_err = 0; @@ -814,11 +819,6 @@ static int process_eb(struct ubi_device *ubi, struct ubi_attach_info *ai, if (err < 0) return err; else if (err) { - /* - * FIXME: this is actually duty of the I/O sub-system to - * initialize this, but MTD does not provide enough - * information. - */ ai->bad_peb_count += 1; return 0; } @@ -1033,18 +1033,17 @@ adjust_mean_ec: } /** - * check_what_we_have - check what PEB were found by scanning. + * late_analysis - analyze the overall situation with PEB. * @ubi: UBI device description object * @ai: attaching information * - * This is a helper function which takes a look what PEBs were found by - * scanning, and decides whether the flash is empty and should be formatted and - * whether there are too many corrupted PEBs and we should not attach this - * MTD device. Returns zero if we should proceed with attaching the MTD device, - * and %-EINVAL if we should not. + * This is a helper function which takes a look what PEBs we have after we + * gather information about all of them ("ai" is compete). It decides whether + * the flash is empty and should be formatted of whether there are too many + * corrupted PEBs and we should not attach this MTD device. Returns zero if we + * should proceed with attaching the MTD device, and %-EINVAL if we should not. */ -static int check_what_we_have(struct ubi_device *ubi, - struct ubi_attach_info *ai) +static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai) { struct ubi_ainf_peb *aeb; int max_corr, peb_count; @@ -1112,7 +1111,8 @@ static int check_what_we_have(struct ubi_device *ubi, * @ubi: UBI device description object * * This function does full scanning of an MTD device and returns complete - * information about it. In case of failure, an error code is returned. + * information about it in form of a "struct ubi_attach_info" object. In case + * of failure, an error code is returned. */ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) { @@ -1151,7 +1151,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) cond_resched(); dbg_gen("process PEB %d", pnum); - err = process_eb(ubi, ai, pnum); + err = scan_peb(ubi, ai, pnum); if (err < 0) goto out_vidh; } @@ -1162,7 +1162,7 @@ struct ubi_attach_info *ubi_scan(struct ubi_device *ubi) if (ai->ec_count) ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); - err = check_what_we_have(ubi, ai); + err = late_analysis(ubi, ai); if (err) goto out_vidh; @@ -1208,12 +1208,11 @@ out_ai: } /** - * destroy_av - free the scanning volume information - * @av: scanning volume information + * destroy_av - free volume attaching information. + * @av: volume attaching information * @ai: attaching information * - * This function destroys the volume RB-tree (@av->root) and the scanning - * volume information. + * This function destroys the volume attaching information. */ static void destroy_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av) { diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h index 20bec7cf9ac8..a794577d0f30 100644 --- a/drivers/mtd/ubi/scan.h +++ b/drivers/mtd/ubi/scan.h @@ -146,7 +146,7 @@ struct ubi_vid_hdr; * ubi_move_aeb_to_list - move a PEB from the volume tree to a list. * * @av: volume attaching information - * @aeb: scanning eraseblock information + * @aeb: attaching eraseblock information * @list: the list to move to */ static inline void ubi_move_aeb_to_list(struct ubi_ainf_volume *av, diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h index 6fb8ec2174a5..07cd88f2b203 100644 --- a/drivers/mtd/ubi/ubi-media.h +++ b/drivers/mtd/ubi/ubi-media.h @@ -149,10 +149,10 @@ enum { * The @image_seq field is used to validate a UBI image that has been prepared * for a UBI device. The @image_seq value can be any value, but it must be the * same on all eraseblocks. UBI will ensure that all new erase counter headers - * also contain this value, and will check the value when scanning at start-up. + * also contain this value, and will check the value when attaching the flash. * One way to make use of @image_seq is to increase its value by one every time * an image is flashed over an existing image, then, if the flashing does not - * complete, UBI will detect the error when scanning. + * complete, UBI will detect the error when attaching the media. */ struct ubi_ec_hdr { __be32 magic; diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 341c956c8cdb..437bc193e170 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -37,16 +37,15 @@ * LEB 1. This scheme guarantees recoverability from unclean reboots. * * In this UBI implementation the on-flash volume table does not contain any - * information about how many data static volumes contain. This information may - * be found from the scanning data. + * information about how much data static volumes contain. * * But it would still be beneficial to store this information in the volume * table. For example, suppose we have a static volume X, and all its physical * eraseblocks became bad for some reasons. Suppose we are attaching the - * corresponding MTD device, the scanning has found no logical eraseblocks + * corresponding MTD device, for some reason we find no logical eraseblocks * corresponding to the volume X. According to the volume table volume X does * exist. So we don't know whether it is just empty or all its physical - * eraseblocks went bad. So we cannot alarm the user about this corruption. + * eraseblocks went bad. So we cannot alarm the user properly. * * The volume table also stores so-called "update marker", which is used for * volume updates. Before updating the volume, the update marker is set, and @@ -702,16 +701,16 @@ bad: } /** - * check_scanning_info - check that attaching information. + * check_attaching_info - check that attaching information. * @ubi: UBI device description object * @ai: attaching information * * Even though we protect on-flash data by CRC checksums, we still don't trust * the media. This function ensures that attaching information is consistent to - * the information read from the volume table. Returns zero if the scanning + * the information read from the volume table. Returns zero if the attaching * information is OK and %-EINVAL if it is not. */ -static int check_scanning_info(const struct ubi_device *ubi, +static int check_attaching_info(const struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; @@ -719,15 +718,14 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_volume *vol; if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { - ubi_err("scanning found %d volumes, maximum is %d + %d", + ubi_err("found %d volumes while attaching, maximum is %d + %d", ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); return -EINVAL; } if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && ai->highest_vol_id < UBI_INTERNAL_VOL_START) { - ubi_err("too large volume ID %d found by scanning", - ai->highest_vol_id); + ubi_err("too large volume ID %d found", ai->highest_vol_id); return -EINVAL; } @@ -749,7 +747,7 @@ static int check_scanning_info(const struct ubi_device *ubi, continue; /* - * During scanning we found a volume which does not + * During attaching we found a volume which does not * exist according to the information in the volume * table. This must have happened due to an unclean * reboot while the volume was being removed. Discard @@ -839,7 +837,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) * Make sure that the attaching information is consistent to the * information stored in the volume table. */ - err = check_scanning_info(ubi, ai); + err = check_attaching_info(ubi, ai); if (err) goto out_free; -- cgit v1.2.3-59-g8ed1b