goto out_wl;
 
 #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;
 
                scan_ai = alloc_ai("ubi_ckh_aeb_slab_cache");
        struct ubi_ainf_peb *aeb, *last_aeb;
        uint8_t *buf;
 
-       if (!ubi->dbg->chk_gen)
+       if (!ubi_dbg_chk_gen(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__ */
 
 {
        int err;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        err = ubi_io_is_bad(ubi, pnum);
        int err;
        uint32_t magic;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        magic = be32_to_cpu(ec_hdr->magic);
        uint32_t crc, hdr_crc;
        struct ubi_ec_hdr *ec_hdr;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
        int err;
        uint32_t magic;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        magic = be32_to_cpu(vid_hdr->magic);
        struct ubi_vid_hdr *vid_hdr;
        void *p;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
        void *buf1;
        loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
        void *buf;
        loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
 
-       if (!ubi->dbg->chk_io)
+       if (!ubi_dbg_chk_io(ubi))
                return 0;
 
        buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
 
 {
        int i, err = 0;
 
-       if (!ubi->dbg->chk_gen)
+       if (!ubi_dbg_chk_gen(ubi))
                return 0;
 
        for (i = 0; i < ubi->vtbl_slots; i++) {
 
  */
 static void self_vtbl_check(const struct ubi_device *ubi)
 {
-       if (!ubi->dbg->chk_gen)
+       if (!ubi_dbg_chk_gen(ubi))
                return;
 
        if (vtbl_check(ubi, ubi->vtbl)) {
 
        long long read_ec;
        struct ubi_ec_hdr *ec_hdr;
 
-       if (!ubi->dbg->chk_gen)
+       if (!ubi_dbg_chk_gen(ubi))
                return 0;
 
        ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
 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)
+       if (!ubi_dbg_chk_gen(ubi))
                return 0;
 
        if (in_wl_tree(e, root))
        struct ubi_wl_entry *p;
        int i;
 
-       if (!ubi->dbg->chk_gen)
+       if (!ubi_dbg_chk_gen(ubi))
                return 0;
 
        for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i)