/* Author: Artem Bityutskiy (Битюцкий Артём) ubi_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_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len)
/* Author: Artem Bityutskiy (Битюцкий Артём) ubi_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_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 = mtd_read(ubi->mtd, addr, len, &read, buf);
	if (err && err != -EUCLEAN) {
		ubi_err(ubi, "err %d while reading %d bytes from PEB %d:%d, read %zd bytes",
			err, len, pnum, offset, read);
		goto out;
	}
	ubi_msg(ubi, "dumping %d bytes of data from PEB %d, offset %d",
		len, pnum, offset);
	print_hex_dump("", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
out:
	vfree(buf);
	return;
}