Skip to content

Commit 6457557

Browse files
ezequielgarciadedekind
authored andcommitted
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: Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent d856c13 commit 6457557

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

drivers/mtd/ubi/attach.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
14481448
goto out_wl;
14491449

14501450
#ifdef CONFIG_MTD_UBI_FASTMAP
1451-
if (ubi->fm && ubi->dbg->chk_gen) {
1451+
if (ubi->fm && ubi_dbg_chk_gen(ubi)) {
14521452
struct ubi_attach_info *scan_ai;
14531453

14541454
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)
14981498
struct ubi_ainf_peb *aeb, *last_aeb;
14991499
uint8_t *buf;
15001500

1501-
if (!ubi->dbg->chk_gen)
1501+
if (!ubi_dbg_chk_gen(ubi))
15021502
return 0;
15031503

15041504
/*

drivers/mtd/ubi/debug.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,13 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
158158
return 0;
159159
}
160160

161+
static inline int ubi_dbg_chk_io(const struct ubi_device *ubi)
162+
{
163+
return ubi->dbg->chk_io;
164+
}
165+
166+
static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
167+
{
168+
return ubi->dbg->chk_gen;
169+
}
161170
#endif /* !__UBI_DEBUG_H__ */

drivers/mtd/ubi/io.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
11321132
{
11331133
int err;
11341134

1135-
if (!ubi->dbg->chk_io)
1135+
if (!ubi_dbg_chk_io(ubi))
11361136
return 0;
11371137

11381138
err = ubi_io_is_bad(ubi, pnum);
@@ -1159,7 +1159,7 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,
11591159
int err;
11601160
uint32_t magic;
11611161

1162-
if (!ubi->dbg->chk_io)
1162+
if (!ubi_dbg_chk_io(ubi))
11631163
return 0;
11641164

11651165
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)
11971197
uint32_t crc, hdr_crc;
11981198
struct ubi_ec_hdr *ec_hdr;
11991199

1200-
if (!ubi->dbg->chk_io)
1200+
if (!ubi_dbg_chk_io(ubi))
12011201
return 0;
12021202

12031203
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,
12411241
int err;
12421242
uint32_t magic;
12431243

1244-
if (!ubi->dbg->chk_io)
1244+
if (!ubi_dbg_chk_io(ubi))
12451245
return 0;
12461246

12471247
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)
12821282
struct ubi_vid_hdr *vid_hdr;
12831283
void *p;
12841284

1285-
if (!ubi->dbg->chk_io)
1285+
if (!ubi_dbg_chk_io(ubi))
12861286
return 0;
12871287

12881288
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,
13341334
void *buf1;
13351335
loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
13361336

1337-
if (!ubi->dbg->chk_io)
1337+
if (!ubi_dbg_chk_io(ubi))
13381338
return 0;
13391339

13401340
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)
13981398
void *buf;
13991399
loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
14001400

1401-
if (!ubi->dbg->chk_io)
1401+
if (!ubi_dbg_chk_io(ubi))
14021402
return 0;
14031403

14041404
buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);

drivers/mtd/ubi/vmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static int self_check_volumes(struct ubi_device *ubi)
847847
{
848848
int i, err = 0;
849849

850-
if (!ubi->dbg->chk_gen)
850+
if (!ubi_dbg_chk_gen(ubi))
851851
return 0;
852852

853853
for (i = 0; i < ubi->vtbl_slots; i++) {

drivers/mtd/ubi/vtbl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
858858
*/
859859
static void self_vtbl_check(const struct ubi_device *ubi)
860860
{
861-
if (!ubi->dbg->chk_gen)
861+
if (!ubi_dbg_chk_gen(ubi))
862862
return;
863863

864864
if (vtbl_check(ubi, ubi->vtbl)) {

drivers/mtd/ubi/wl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec)
20432043
long long read_ec;
20442044
struct ubi_ec_hdr *ec_hdr;
20452045

2046-
if (!ubi->dbg->chk_gen)
2046+
if (!ubi_dbg_chk_gen(ubi))
20472047
return 0;
20482048

20492049
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)
20832083
static int self_check_in_wl_tree(const struct ubi_device *ubi,
20842084
struct ubi_wl_entry *e, struct rb_root *root)
20852085
{
2086-
if (!ubi->dbg->chk_gen)
2086+
if (!ubi_dbg_chk_gen(ubi))
20872087
return 0;
20882088

20892089
if (in_wl_tree(e, root))
@@ -2109,7 +2109,7 @@ static int self_check_in_pq(const struct ubi_device *ubi,
21092109
struct ubi_wl_entry *p;
21102110
int i;
21112111

2112-
if (!ubi->dbg->chk_gen)
2112+
if (!ubi_dbg_chk_gen(ubi))
21132113
return 0;
21142114

21152115
for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i)

0 commit comments

Comments
 (0)