* [PATCH] jffs2: deubg: list_for_each() -> list_for_each_entry()
@ 2020-02-23 5:46 qiwuchen55
0 siblings, 0 replies; only message in thread
From: qiwuchen55 @ 2020-02-23 5:46 UTC (permalink / raw)
To: dwmw2, richard; +Cc: chenqiwu, linux-mtd
From: chenqiwu <chenqiwu@xiaomi.com>
Use list_for_each_entry() instead of list_for_each() to
simplify code.
Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
fs/jffs2/debug.c | 65 +++++++++++++++++++-------------------------------------
1 file changed, 22 insertions(+), 43 deletions(-)
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 9d26b1b9..6bef692 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -498,12 +498,11 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->clean_list)) {
printk(JFFS2_DBG "clean_list: empty\n");
} else {
- struct list_head *this;
int numblocks = 0;
uint32_t dirty = 0;
+ struct jffs2_eraseblock *jeb;
- list_for_each(this, &c->clean_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ list_for_each_entry(jeb, &c->clean_list, list) {
numblocks ++;
dirty += jeb->wasted_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -520,13 +519,11 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->very_dirty_list)) {
printk(JFFS2_DBG "very_dirty_list: empty\n");
} else {
- struct list_head *this;
int numblocks = 0;
uint32_t dirty = 0;
+ struct jffs2_eraseblock *jeb;
- list_for_each(this, &c->very_dirty_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
-
+ list_for_each_entry(jeb, &c->very_dirty_list, list) {
numblocks ++;
dirty += jeb->dirty_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -543,13 +540,11 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->dirty_list)) {
printk(JFFS2_DBG "dirty_list: empty\n");
} else {
- struct list_head *this;
int numblocks = 0;
uint32_t dirty = 0;
+ struct jffs2_eraseblock *jeb;
- list_for_each(this, &c->dirty_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
-
+ list_for_each_entry(jeb, &c->dirty_list, list) {
numblocks ++;
dirty += jeb->dirty_size;
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
@@ -566,11 +561,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->erasable_list)) {
printk(JFFS2_DBG "erasable_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->erasable_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->erasable_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -582,11 +575,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->erasing_list)) {
printk(JFFS2_DBG "erasing_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->erasing_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->erasing_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -597,11 +588,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->erase_checking_list)) {
printk(JFFS2_DBG "erase_checking_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->erase_checking_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->erase_checking_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "erase_checking_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -613,11 +602,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->erase_pending_list)) {
printk(JFFS2_DBG "erase_pending_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->erase_pending_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->erase_pending_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -629,11 +616,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->erasable_pending_wbuf_list)) {
printk(JFFS2_DBG "erasable_pending_wbuf_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->erasable_pending_wbuf_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->erasable_pending_wbuf_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -645,11 +630,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->free_list)) {
printk(JFFS2_DBG "free_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->free_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->free_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -661,11 +644,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->bad_list)) {
printk(JFFS2_DBG "bad_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->bad_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->bad_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
@@ -677,11 +658,9 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
if (list_empty(&c->bad_used_list)) {
printk(JFFS2_DBG "bad_used_list: empty\n");
} else {
- struct list_head *this;
-
- list_for_each(this, &c->bad_used_list) {
- struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
+ struct jffs2_eraseblock *jeb;
+ list_for_each_entry(jeb, &c->bad_used_list, list) {
if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) {
printk(JFFS2_DBG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size,
--
1.9.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-23 5:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-23 5:46 [PATCH] jffs2: deubg: list_for_each() -> list_for_each_entry() qiwuchen55
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).