diff options
Diffstat (limited to 'drivers/mtd/ubi/debug.c')
-rw-r--r-- | drivers/mtd/ubi/debug.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 54b0186915fb..4876977e52cb 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -196,4 +196,36 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req) | |||
196 | printk(KERN_DEBUG "\t1st 16 characters of name: %s\n", nm); | 196 | printk(KERN_DEBUG "\t1st 16 characters of name: %s\n", nm); |
197 | } | 197 | } |
198 | 198 | ||
199 | /** | ||
200 | * ubi_dbg_dump_flash - dump a region of flash. | ||
201 | * @ubi: UBI device description object | ||
202 | * @pnum: the physical eraseblock number to dump | ||
203 | * @offset: the starting offset within the physical eraseblock to dump | ||
204 | * @len: the length of the region to dump | ||
205 | */ | ||
206 | void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len) | ||
207 | { | ||
208 | int err; | ||
209 | size_t read; | ||
210 | void *buf; | ||
211 | loff_t addr = (loff_t)pnum * ubi->peb_size + offset; | ||
212 | |||
213 | buf = vmalloc(len); | ||
214 | if (!buf) | ||
215 | return; | ||
216 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | ||
217 | if (err && err != -EUCLEAN) { | ||
218 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " | ||
219 | "read %zd bytes", err, len, pnum, offset, read); | ||
220 | goto out; | ||
221 | } | ||
222 | |||
223 | dbg_msg("dumping %d bytes of data from PEB %d, offset %d", | ||
224 | len, pnum, offset); | ||
225 | print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); | ||
226 | out: | ||
227 | vfree(buf); | ||
228 | return; | ||
229 | } | ||
230 | |||
199 | #endif /* CONFIG_MTD_UBI_DEBUG */ | 231 | #endif /* CONFIG_MTD_UBI_DEBUG */ |