X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Fmtd%2Fubi%2Fdebug.c;h=d33a2831cc0741fe6aeac87c857305eca193c01c;hb=b989bd4c572ab700e8c67842c37abc7738641310;hp=61af9bb560ab6777cd90ea5125790f38ee6139a9;hpb=7ea6411f4ceb62e5e53170d59d10996dca20c599;p=karo-tx-linux.git diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 61af9bb560ab..d33a2831cc07 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -18,24 +18,49 @@ * Author: Artem Bityutskiy (Битюцкий Артём) */ -/* - * Here we keep all the UBI debugging stuff which should normally be disabled - * and compiled-out, but it is extremely helpful when hunting bugs or doing big - * changes. - */ - -#ifdef CONFIG_MTD_UBI_DEBUG - #include "ubi.h" #include #include #include + +/** + * 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("error %d while reading %d bytes from PEB %d:%d, " + "read %zd bytes", err, len, pnum, offset, read); + goto out; + } + + ubi_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; +} + /** - * ubi_dbg_dump_ec_hdr - dump an erase counter header. + * ubi_dump_ec_hdr - dump an erase counter header. * @ec_hdr: the erase counter header to dump */ -void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) +void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { printk(KERN_DEBUG "Erase counter header dump:\n"); printk(KERN_DEBUG "\tmagic %#08x\n", @@ -57,10 +82,10 @@ void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) } /** - * ubi_dbg_dump_vid_hdr - dump a volume identifier header. + * ubi_dump_vid_hdr - dump a volume identifier header. * @vid_hdr: the volume identifier header to dump */ -void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) +void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) { printk(KERN_DEBUG "Volume identifier header dump:\n"); printk(KERN_DEBUG "\tmagic %08x\n", be32_to_cpu(vid_hdr->magic)); @@ -81,11 +106,13 @@ void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) vid_hdr, UBI_VID_HDR_SIZE, 1); } +#ifdef CONFIG_MTD_UBI_DEBUG + /** - * ubi_dbg_dump_vol_info- dump volume information. + * ubi_dump_vol_info - dump volume information. * @vol: UBI volume description object */ -void ubi_dbg_dump_vol_info(const struct ubi_volume *vol) +void ubi_dump_vol_info(const struct ubi_volume *vol) { printk(KERN_DEBUG "Volume information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", vol->vol_id); @@ -112,11 +139,11 @@ void ubi_dbg_dump_vol_info(const struct ubi_volume *vol) } /** - * ubi_dbg_dump_vtbl_record - dump a &struct ubi_vtbl_record object. + * ubi_dump_vtbl_record - dump a &struct ubi_vtbl_record object. * @r: the object to dump * @idx: volume table index */ -void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) +void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { int name_len = be16_to_cpu(r->name_len); @@ -146,10 +173,10 @@ void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) } /** - * ubi_dbg_dump_sv - dump a &struct ubi_scan_volume object. + * ubi_dump_sv - dump a &struct ubi_scan_volume object. * @sv: the object to dump */ -void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) +void ubi_dump_sv(const struct ubi_scan_volume *sv) { printk(KERN_DEBUG "Volume scanning information dump:\n"); printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); @@ -163,11 +190,11 @@ void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) } /** - * ubi_dbg_dump_seb - dump a &struct ubi_scan_leb object. + * ubi_dump_seb - dump a &struct ubi_scan_leb object. * @seb: the object to dump * @type: object type: 0 - not corrupted, 1 - corrupted */ -void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type) +void ubi_dump_seb(const struct ubi_scan_leb *seb, int type) { printk(KERN_DEBUG "eraseblock scanning information dump:\n"); printk(KERN_DEBUG "\tec %d\n", seb->ec); @@ -199,38 +226,6 @@ 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 = 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; -} - /** * ubi_debugging_init_dev - initialize debugging for an UBI device. * @ubi: UBI device description object