Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164043
b: refs/heads/master
c: 867996b
h: refs/heads/master
i:
  164041: 8d639c1
  164039: fb41221
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Aug 14, 2009
1 parent 09a4d4a commit c2cf203
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 758d8e46347aee199e7025b8c571bab75d2de63f
refs/heads/master: 867996b15c1f0a98d2c405bada907e97499ba8c2
32 changes: 32 additions & 0 deletions trunk/drivers/mtd/ubi/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,36 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req)
printk(KERN_DEBUG "\t1st 16 characters of name: %s\n", nm);
}

/**
* ubi_dbg_dump_flash - dump a region of flash.
* @ubi: UBI device description object
* @pnum: the physical eraseblock number to dump
* @offset: the starting offset within the physical eraseblock to dump
* @len: the length of the region to dump
*/
void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len)
{
int err;
size_t read;
void *buf;
loff_t addr = (loff_t)pnum * ubi->peb_size + offset;

buf = vmalloc(len);
if (!buf)
return;
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
if (err && err != -EUCLEAN) {
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
"read %zd bytes", err, len, pnum, offset, read);
goto out;
}

dbg_msg("dumping %d bytes of data from PEB %d, offset %d",
len, pnum, offset);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
out:
vfree(buf);
return;
}

#endif /* CONFIG_MTD_UBI_DEBUG */
2 changes: 2 additions & 0 deletions trunk/drivers/mtd/ubi/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ 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);
void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);

#ifdef CONFIG_MTD_UBI_DEBUG_MSG
/* General debugging messages */
Expand Down Expand Up @@ -167,6 +168,7 @@ static inline int ubi_dbg_is_erase_failure(void)
#define ubi_dbg_dump_sv(sv) ({})
#define ubi_dbg_dump_seb(seb, type) ({})
#define ubi_dbg_dump_mkvol_req(req) ({})
#define ubi_dbg_dump_flash(ubi, pnum, offset, len) ({})

#define UBI_IO_DEBUG 0
#define DBG_DISABLE_BGT 0
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/mtd/ubi/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
"%zd bytes", err, len, pnum, offset, written);
ubi_dbg_dump_stack();
ubi_dbg_dump_flash(ubi, pnum, offset, len);
} else
ubi_assert(written == len);

Expand Down

0 comments on commit c2cf203

Please sign in to comment.