Commit 64575574 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Artem Bityutskiy

UBI: introduce helpers dbg_chk_{io, gen}

With this patch code is a bit more readable and there's no
generated code or functionality impact.
Furthermore, this abstracts implementation details and
will allow to change ubi_debug_info in a less invasive way.
Signed-off-by: default avatarEzequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent d856c13c
...@@ -1448,7 +1448,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan) ...@@ -1448,7 +1448,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
goto out_wl; goto out_wl;
#ifdef CONFIG_MTD_UBI_FASTMAP #ifdef CONFIG_MTD_UBI_FASTMAP
if (ubi->fm && ubi->dbg->chk_gen) { if (ubi->fm && ubi_dbg_chk_gen(ubi)) {
struct ubi_attach_info *scan_ai; struct ubi_attach_info *scan_ai;
scan_ai = alloc_ai("ubi_ckh_aeb_slab_cache"); scan_ai = alloc_ai("ubi_ckh_aeb_slab_cache");
...@@ -1498,7 +1498,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1498,7 +1498,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
struct ubi_ainf_peb *aeb, *last_aeb; struct ubi_ainf_peb *aeb, *last_aeb;
uint8_t *buf; uint8_t *buf;
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return 0; return 0;
/* /*
......
...@@ -158,4 +158,13 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) ...@@ -158,4 +158,13 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
return 0; return 0;
} }
static inline int ubi_dbg_chk_io(const struct ubi_device *ubi)
{
return ubi->dbg->chk_io;
}
static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
{
return ubi->dbg->chk_gen;
}
#endif /* !__UBI_DEBUG_H__ */ #endif /* !__UBI_DEBUG_H__ */
...@@ -1132,7 +1132,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum) ...@@ -1132,7 +1132,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
{ {
int err; int err;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
err = ubi_io_is_bad(ubi, pnum); err = ubi_io_is_bad(ubi, pnum);
...@@ -1159,7 +1159,7 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1159,7 +1159,7 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,
int err; int err;
uint32_t magic; uint32_t magic;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
magic = be32_to_cpu(ec_hdr->magic); magic = be32_to_cpu(ec_hdr->magic);
...@@ -1197,7 +1197,7 @@ static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1197,7 +1197,7 @@ static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
uint32_t crc, hdr_crc; uint32_t crc, hdr_crc;
struct ubi_ec_hdr *ec_hdr; struct ubi_ec_hdr *ec_hdr;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
...@@ -1241,7 +1241,7 @@ static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1241,7 +1241,7 @@ static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum,
int err; int err;
uint32_t magic; uint32_t magic;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
magic = be32_to_cpu(vid_hdr->magic); magic = be32_to_cpu(vid_hdr->magic);
...@@ -1282,7 +1282,7 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1282,7 +1282,7 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
struct ubi_vid_hdr *vid_hdr; struct ubi_vid_hdr *vid_hdr;
void *p; void *p;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
...@@ -1334,7 +1334,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, ...@@ -1334,7 +1334,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
void *buf1; void *buf1;
loff_t addr = (loff_t)pnum * ubi->peb_size + offset; loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
...@@ -1398,7 +1398,7 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -1398,7 +1398,7 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
void *buf; void *buf;
loff_t addr = (loff_t)pnum * ubi->peb_size + offset; loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
if (!ubi->dbg->chk_io) if (!ubi_dbg_chk_io(ubi))
return 0; return 0;
buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
......
...@@ -847,7 +847,7 @@ static int self_check_volumes(struct ubi_device *ubi) ...@@ -847,7 +847,7 @@ static int self_check_volumes(struct ubi_device *ubi)
{ {
int i, err = 0; int i, err = 0;
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return 0; return 0;
for (i = 0; i < ubi->vtbl_slots; i++) { for (i = 0; i < ubi->vtbl_slots; i++) {
......
...@@ -858,7 +858,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -858,7 +858,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
*/ */
static void self_vtbl_check(const struct ubi_device *ubi) static void self_vtbl_check(const struct ubi_device *ubi)
{ {
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return; return;
if (vtbl_check(ubi, ubi->vtbl)) { if (vtbl_check(ubi, ubi->vtbl)) {
......
...@@ -2043,7 +2043,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec) ...@@ -2043,7 +2043,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec)
long long read_ec; long long read_ec;
struct ubi_ec_hdr *ec_hdr; struct ubi_ec_hdr *ec_hdr;
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return 0; return 0;
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
...@@ -2083,7 +2083,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec) ...@@ -2083,7 +2083,7 @@ 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, static int self_check_in_wl_tree(const struct ubi_device *ubi,
struct ubi_wl_entry *e, struct rb_root *root) struct ubi_wl_entry *e, struct rb_root *root)
{ {
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return 0; return 0;
if (in_wl_tree(e, root)) if (in_wl_tree(e, root))
...@@ -2109,7 +2109,7 @@ static int self_check_in_pq(const struct ubi_device *ubi, ...@@ -2109,7 +2109,7 @@ static int self_check_in_pq(const struct ubi_device *ubi,
struct ubi_wl_entry *p; struct ubi_wl_entry *p;
int i; int i;
if (!ubi->dbg->chk_gen) if (!ubi_dbg_chk_gen(ubi))
return 0; return 0;
for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment