aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-16 10:40:22 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-24 06:34:45 -0400
commitc8566350a3229ca505b84313c65d1403b4d0cbfc (patch)
tree156309b71de9779948fdab03a2831b41fe6ca159 /drivers/mtd
parent85c6e6e28259e9b58b8984db536c45bc3161f40c (diff)
UBI: fix and re-work debugging stuff
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/build.c2
-rw-r--r--drivers/mtd/ubi/cdev.c26
-rw-r--r--drivers/mtd/ubi/debug.c160
-rw-r--r--drivers/mtd/ubi/debug.h68
-rw-r--r--drivers/mtd/ubi/gluebi.c10
-rw-r--r--drivers/mtd/ubi/io.c4
-rw-r--r--drivers/mtd/ubi/kapi.c20
-rw-r--r--drivers/mtd/ubi/scan.c2
-rw-r--r--drivers/mtd/ubi/upd.c16
-rw-r--r--drivers/mtd/ubi/vmt.c73
-rw-r--r--drivers/mtd/ubi/vtbl.c2
11 files changed, 206 insertions, 177 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 27271fe32e0..7210e1da1fc 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -403,7 +403,7 @@ static int uif_init(struct ubi_device *ubi)
403 403
404 ubi_assert(MINOR(dev) == 0); 404 ubi_assert(MINOR(dev) == 0);
405 cdev_init(&ubi->cdev, &ubi_cdev_operations); 405 cdev_init(&ubi->cdev, &ubi_cdev_operations);
406 dbg_msg("%s major is %u", ubi->ubi_name, MAJOR(dev)); 406 dbg_gen("%s major is %u", ubi->ubi_name, MAJOR(dev));
407 ubi->cdev.owner = THIS_MODULE; 407 ubi->cdev.owner = THIS_MODULE;
408 408
409 err = cdev_add(&ubi->cdev, dev, 1); 409 err = cdev_add(&ubi->cdev, dev, 1);
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 4fb84e3e650..7c19918cc91 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -116,7 +116,7 @@ static int vol_cdev_open(struct inode *inode, struct file *file)
116 else 116 else
117 mode = UBI_READONLY; 117 mode = UBI_READONLY;
118 118
119 dbg_msg("open volume %d, mode %d", vol_id, mode); 119 dbg_gen("open volume %d, mode %d", vol_id, mode);
120 120
121 desc = ubi_open_volume(ubi_num, vol_id, mode); 121 desc = ubi_open_volume(ubi_num, vol_id, mode);
122 unlock_kernel(); 122 unlock_kernel();
@@ -132,7 +132,7 @@ static int vol_cdev_release(struct inode *inode, struct file *file)
132 struct ubi_volume_desc *desc = file->private_data; 132 struct ubi_volume_desc *desc = file->private_data;
133 struct ubi_volume *vol = desc->vol; 133 struct ubi_volume *vol = desc->vol;
134 134
135 dbg_msg("release volume %d, mode %d", vol->vol_id, desc->mode); 135 dbg_gen("release volume %d, mode %d", vol->vol_id, desc->mode);
136 136
137 if (vol->updating) { 137 if (vol->updating) {
138 ubi_warn("update of volume %d not finished, volume is damaged", 138 ubi_warn("update of volume %d not finished, volume is damaged",
@@ -141,7 +141,7 @@ static int vol_cdev_release(struct inode *inode, struct file *file)
141 vol->updating = 0; 141 vol->updating = 0;
142 vfree(vol->upd_buf); 142 vfree(vol->upd_buf);
143 } else if (vol->changing_leb) { 143 } else if (vol->changing_leb) {
144 dbg_msg("only %lld of %lld bytes received for atomic LEB change" 144 dbg_gen("only %lld of %lld bytes received for atomic LEB change"
145 " for volume %d:%d, cancel", vol->upd_received, 145 " for volume %d:%d, cancel", vol->upd_received,
146 vol->upd_bytes, vol->ubi->ubi_num, vol->vol_id); 146 vol->upd_bytes, vol->ubi->ubi_num, vol->vol_id);
147 vol->changing_leb = 0; 147 vol->changing_leb = 0;
@@ -183,7 +183,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin)
183 return -EINVAL; 183 return -EINVAL;
184 } 184 }
185 185
186 dbg_msg("seek volume %d, offset %lld, origin %d, new offset %lld", 186 dbg_gen("seek volume %d, offset %lld, origin %d, new offset %lld",
187 vol->vol_id, offset, origin, new_offset); 187 vol->vol_id, offset, origin, new_offset);
188 188
189 file->f_pos = new_offset; 189 file->f_pos = new_offset;
@@ -201,7 +201,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
201 void *tbuf; 201 void *tbuf;
202 uint64_t tmp; 202 uint64_t tmp;
203 203
204 dbg_msg("read %zd bytes from offset %lld of volume %d", 204 dbg_gen("read %zd bytes from offset %lld of volume %d",
205 count, *offp, vol->vol_id); 205 count, *offp, vol->vol_id);
206 206
207 if (vol->updating) { 207 if (vol->updating) {
@@ -216,7 +216,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
216 return 0; 216 return 0;
217 217
218 if (vol->corrupted) 218 if (vol->corrupted)
219 dbg_msg("read from corrupted volume %d", vol->vol_id); 219 dbg_gen("read from corrupted volume %d", vol->vol_id);
220 220
221 if (*offp + count > vol->used_bytes) 221 if (*offp + count > vol->used_bytes)
222 count_save = count = vol->used_bytes - *offp; 222 count_save = count = vol->used_bytes - *offp;
@@ -285,7 +285,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
285 char *tbuf; 285 char *tbuf;
286 uint64_t tmp; 286 uint64_t tmp;
287 287
288 dbg_msg("requested: write %zd bytes to offset %lld of volume %u", 288 dbg_gen("requested: write %zd bytes to offset %lld of volume %u",
289 count, *offp, vol->vol_id); 289 count, *offp, vol->vol_id);
290 290
291 if (vol->vol_type == UBI_STATIC_VOLUME) 291 if (vol->vol_type == UBI_STATIC_VOLUME)
@@ -514,7 +514,7 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
514 break; 514 break;
515 } 515 }
516 516
517 dbg_msg("erase LEB %d:%d", vol->vol_id, lnum); 517 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum);
518 err = ubi_eba_unmap_leb(ubi, vol, lnum); 518 err = ubi_eba_unmap_leb(ubi, vol, lnum);
519 if (err) 519 if (err)
520 break; 520 break;
@@ -626,7 +626,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
626 { 626 {
627 struct ubi_mkvol_req req; 627 struct ubi_mkvol_req req;
628 628
629 dbg_msg("create volume"); 629 dbg_gen("create volume");
630 err = copy_from_user(&req, argp, sizeof(struct ubi_mkvol_req)); 630 err = copy_from_user(&req, argp, sizeof(struct ubi_mkvol_req));
631 if (err) { 631 if (err) {
632 err = -EFAULT; 632 err = -EFAULT;
@@ -656,7 +656,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
656 { 656 {
657 int vol_id; 657 int vol_id;
658 658
659 dbg_msg("remove volume"); 659 dbg_gen("remove volume");
660 err = get_user(vol_id, (__user int32_t *)argp); 660 err = get_user(vol_id, (__user int32_t *)argp);
661 if (err) { 661 if (err) {
662 err = -EFAULT; 662 err = -EFAULT;
@@ -689,7 +689,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
689 uint64_t tmp; 689 uint64_t tmp;
690 struct ubi_rsvol_req req; 690 struct ubi_rsvol_req req;
691 691
692 dbg_msg("re-size volume"); 692 dbg_gen("re-size volume");
693 err = copy_from_user(&req, argp, sizeof(struct ubi_rsvol_req)); 693 err = copy_from_user(&req, argp, sizeof(struct ubi_rsvol_req));
694 if (err) { 694 if (err) {
695 err = -EFAULT; 695 err = -EFAULT;
@@ -742,7 +742,7 @@ static int ctrl_cdev_ioctl(struct inode *inode, struct file *file,
742 struct ubi_attach_req req; 742 struct ubi_attach_req req;
743 struct mtd_info *mtd; 743 struct mtd_info *mtd;
744 744
745 dbg_msg("attach MTD device"); 745 dbg_gen("attach MTD device");
746 err = copy_from_user(&req, argp, sizeof(struct ubi_attach_req)); 746 err = copy_from_user(&req, argp, sizeof(struct ubi_attach_req));
747 if (err) { 747 if (err) {
748 err = -EFAULT; 748 err = -EFAULT;
@@ -782,7 +782,7 @@ static int ctrl_cdev_ioctl(struct inode *inode, struct file *file,
782 { 782 {
783 int ubi_num; 783 int ubi_num;
784 784
785 dbg_msg("dettach MTD device"); 785 dbg_gen("dettach MTD device");
786 err = get_user(ubi_num, (__user int32_t *)argp); 786 err = get_user(ubi_num, (__user int32_t *)argp);
787 if (err) { 787 if (err) {
788 err = -EFAULT; 788 err = -EFAULT;
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 56956ec2845..21e0d7d76a4 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -24,7 +24,7 @@
24 * changes. 24 * changes.
25 */ 25 */
26 26
27#ifdef CONFIG_MTD_UBI_DEBUG_MSG 27#ifdef CONFIG_MTD_UBI_DEBUG
28 28
29#include "ubi.h" 29#include "ubi.h"
30 30
@@ -34,14 +34,19 @@
34 */ 34 */
35void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) 35void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
36{ 36{
37 dbg_msg("erase counter header dump:"); 37 printk(KERN_DEBUG "Erase counter header dump:\n");
38 dbg_msg("magic %#08x", be32_to_cpu(ec_hdr->magic)); 38 printk(KERN_DEBUG "\tmagic %#08x\n",
39 dbg_msg("version %d", (int)ec_hdr->version); 39 be32_to_cpu(ec_hdr->magic));
40 dbg_msg("ec %llu", (long long)be64_to_cpu(ec_hdr->ec)); 40 printk(KERN_DEBUG "\tversion %d\n", (int)ec_hdr->version);
41 dbg_msg("vid_hdr_offset %d", be32_to_cpu(ec_hdr->vid_hdr_offset)); 41 printk(KERN_DEBUG "\tec %llu\n",
42 dbg_msg("data_offset %d", be32_to_cpu(ec_hdr->data_offset)); 42 (long long)be64_to_cpu(ec_hdr->ec));
43 dbg_msg("hdr_crc %#08x", be32_to_cpu(ec_hdr->hdr_crc)); 43 printk(KERN_DEBUG "\tvid_hdr_offset %d\n",
44 dbg_msg("erase counter header hexdump:"); 44 be32_to_cpu(ec_hdr->vid_hdr_offset));
45 printk(KERN_DEBUG "\tdata_offset %d\n",
46 be32_to_cpu(ec_hdr->data_offset));
47 printk(KERN_DEBUG "\thdr_crc %#08x\n",
48 be32_to_cpu(ec_hdr->hdr_crc));
49 printk(KERN_DEBUG "erase counter header hexdump:\n");
45 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 50 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
46 ec_hdr, UBI_EC_HDR_SIZE, 1); 51 ec_hdr, UBI_EC_HDR_SIZE, 1);
47} 52}
@@ -52,22 +57,24 @@ void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
52 */ 57 */
53void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) 58void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
54{ 59{
55 dbg_msg("volume identifier header dump:"); 60 printk(KERN_DEBUG "Volume identifier header dump:\n");
56 dbg_msg("magic %08x", be32_to_cpu(vid_hdr->magic)); 61 printk(KERN_DEBUG "\tmagic %08x\n", be32_to_cpu(vid_hdr->magic));
57 dbg_msg("version %d", (int)vid_hdr->version); 62 printk(KERN_DEBUG "\tversion %d\n", (int)vid_hdr->version);
58 dbg_msg("vol_type %d", (int)vid_hdr->vol_type); 63 printk(KERN_DEBUG "\tvol_type %d\n", (int)vid_hdr->vol_type);
59 dbg_msg("copy_flag %d", (int)vid_hdr->copy_flag); 64 printk(KERN_DEBUG "\tcopy_flag %d\n", (int)vid_hdr->copy_flag);
60 dbg_msg("compat %d", (int)vid_hdr->compat); 65 printk(KERN_DEBUG "\tcompat %d\n", (int)vid_hdr->compat);
61 dbg_msg("vol_id %d", be32_to_cpu(vid_hdr->vol_id)); 66 printk(KERN_DEBUG "\tvol_id %d\n", be32_to_cpu(vid_hdr->vol_id));
62 dbg_msg("lnum %d", be32_to_cpu(vid_hdr->lnum)); 67 printk(KERN_DEBUG "\tlnum %d\n", be32_to_cpu(vid_hdr->lnum));
63 dbg_msg("leb_ver %u", be32_to_cpu(vid_hdr->leb_ver)); 68 printk(KERN_DEBUG "\tleb_ver %u\n", be32_to_cpu(vid_hdr->leb_ver));
64 dbg_msg("data_size %d", be32_to_cpu(vid_hdr->data_size)); 69 printk(KERN_DEBUG "\tdata_size %d\n", be32_to_cpu(vid_hdr->data_size));
65 dbg_msg("used_ebs %d", be32_to_cpu(vid_hdr->used_ebs)); 70 printk(KERN_DEBUG "\tused_ebs %d\n", be32_to_cpu(vid_hdr->used_ebs));
66 dbg_msg("data_pad %d", be32_to_cpu(vid_hdr->data_pad)); 71 printk(KERN_DEBUG "\tdata_pad %d\n", be32_to_cpu(vid_hdr->data_pad));
67 dbg_msg("sqnum %llu", 72 printk(KERN_DEBUG "\tsqnum %llu\n",
68 (unsigned long long)be64_to_cpu(vid_hdr->sqnum)); 73 (unsigned long long)be64_to_cpu(vid_hdr->sqnum));
69 dbg_msg("hdr_crc %08x", be32_to_cpu(vid_hdr->hdr_crc)); 74 printk(KERN_DEBUG "\thdr_crc %08x\n", be32_to_cpu(vid_hdr->hdr_crc));
70 dbg_msg("volume identifier header hexdump:"); 75 printk(KERN_DEBUG "Volume identifier header hexdump:\n");
76 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
77 vid_hdr, UBI_VID_HDR_SIZE, 1);
71} 78}
72 79
73/** 80/**
@@ -76,27 +83,27 @@ void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
76 */ 83 */
77void ubi_dbg_dump_vol_info(const struct ubi_volume *vol) 84void ubi_dbg_dump_vol_info(const struct ubi_volume *vol)
78{ 85{
79 dbg_msg("volume information dump:"); 86 printk(KERN_DEBUG "Volume information dump:\n");
80 dbg_msg("vol_id %d", vol->vol_id); 87 printk(KERN_DEBUG "\tvol_id %d\n", vol->vol_id);
81 dbg_msg("reserved_pebs %d", vol->reserved_pebs); 88 printk(KERN_DEBUG "\treserved_pebs %d\n", vol->reserved_pebs);
82 dbg_msg("alignment %d", vol->alignment); 89 printk(KERN_DEBUG "\talignment %d\n", vol->alignment);
83 dbg_msg("data_pad %d", vol->data_pad); 90 printk(KERN_DEBUG "\tdata_pad %d\n", vol->data_pad);
84 dbg_msg("vol_type %d", vol->vol_type); 91 printk(KERN_DEBUG "\tvol_type %d\n", vol->vol_type);
85 dbg_msg("name_len %d", vol->name_len); 92 printk(KERN_DEBUG "\tname_len %d\n", vol->name_len);
86 dbg_msg("usable_leb_size %d", vol->usable_leb_size); 93 printk(KERN_DEBUG "\tusable_leb_size %d\n", vol->usable_leb_size);
87 dbg_msg("used_ebs %d", vol->used_ebs); 94 printk(KERN_DEBUG "\tused_ebs %d\n", vol->used_ebs);
88 dbg_msg("used_bytes %lld", vol->used_bytes); 95 printk(KERN_DEBUG "\tused_bytes %lld\n", vol->used_bytes);
89 dbg_msg("last_eb_bytes %d", vol->last_eb_bytes); 96 printk(KERN_DEBUG "\tlast_eb_bytes %d\n", vol->last_eb_bytes);
90 dbg_msg("corrupted %d", vol->corrupted); 97 printk(KERN_DEBUG "\tcorrupted %d\n", vol->corrupted);
91 dbg_msg("upd_marker %d", vol->upd_marker); 98 printk(KERN_DEBUG "\tupd_marker %d\n", vol->upd_marker);
92 99
93 if (vol->name_len <= UBI_VOL_NAME_MAX && 100 if (vol->name_len <= UBI_VOL_NAME_MAX &&
94 strnlen(vol->name, vol->name_len + 1) == vol->name_len) { 101 strnlen(vol->name, vol->name_len + 1) == vol->name_len) {
95 dbg_msg("name %s", vol->name); 102 printk(KERN_DEBUG "\tname %s\n", vol->name);
96 } else { 103 } else {
97 dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c", 104 printk(KERN_DEBUG "\t1st 5 characters of name: %c%c%c%c%c\n",
98 vol->name[0], vol->name[1], vol->name[2], 105 vol->name[0], vol->name[1], vol->name[2],
99 vol->name[3], vol->name[4]); 106 vol->name[3], vol->name[4]);
100 } 107 }
101} 108}
102 109
@@ -109,28 +116,29 @@ void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
109{ 116{
110 int name_len = be16_to_cpu(r->name_len); 117 int name_len = be16_to_cpu(r->name_len);
111 118
112 dbg_msg("volume table record %d dump:", idx); 119 printk(KERN_DEBUG "Volume table record %d dump:\n", idx);
113 dbg_msg("reserved_pebs %d", be32_to_cpu(r->reserved_pebs)); 120 printk(KERN_DEBUG "\treserved_pebs %d\n",
114 dbg_msg("alignment %d", be32_to_cpu(r->alignment)); 121 be32_to_cpu(r->reserved_pebs));
115 dbg_msg("data_pad %d", be32_to_cpu(r->data_pad)); 122 printk(KERN_DEBUG "\talignment %d\n", be32_to_cpu(r->alignment));
116 dbg_msg("vol_type %d", (int)r->vol_type); 123 printk(KERN_DEBUG "\tdata_pad %d\n", be32_to_cpu(r->data_pad));
117 dbg_msg("upd_marker %d", (int)r->upd_marker); 124 printk(KERN_DEBUG "\tvol_type %d\n", (int)r->vol_type);
118 dbg_msg("name_len %d", name_len); 125 printk(KERN_DEBUG "\tupd_marker %d\n", (int)r->upd_marker);
126 printk(KERN_DEBUG "\tname_len %d\n", name_len);
119 127
120 if (r->name[0] == '\0') { 128 if (r->name[0] == '\0') {
121 dbg_msg("name NULL"); 129 printk(KERN_DEBUG "\tname NULL\n");
122 return; 130 return;
123 } 131 }
124 132
125 if (name_len <= UBI_VOL_NAME_MAX && 133 if (name_len <= UBI_VOL_NAME_MAX &&
126 strnlen(&r->name[0], name_len + 1) == name_len) { 134 strnlen(&r->name[0], name_len + 1) == name_len) {
127 dbg_msg("name %s", &r->name[0]); 135 printk(KERN_DEBUG "\tname %s\n", &r->name[0]);
128 } else { 136 } else {
129 dbg_msg("1st 5 characters of the name: %c%c%c%c%c", 137 printk(KERN_DEBUG "\t1st 5 characters of name: %c%c%c%c%c\n",
130 r->name[0], r->name[1], r->name[2], r->name[3], 138 r->name[0], r->name[1], r->name[2], r->name[3],
131 r->name[4]); 139 r->name[4]);
132 } 140 }
133 dbg_msg("crc %#08x", be32_to_cpu(r->crc)); 141 printk(KERN_DEBUG "\tcrc %#08x\n", be32_to_cpu(r->crc));
134} 142}
135 143
136/** 144/**
@@ -139,15 +147,15 @@ void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
139 */ 147 */
140void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv) 148void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv)
141{ 149{
142 dbg_msg("volume scanning information dump:"); 150 printk(KERN_DEBUG "Volume scanning information dump:\n");
143 dbg_msg("vol_id %d", sv->vol_id); 151 printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id);
144 dbg_msg("highest_lnum %d", sv->highest_lnum); 152 printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum);
145 dbg_msg("leb_count %d", sv->leb_count); 153 printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count);
146 dbg_msg("compat %d", sv->compat); 154 printk(KERN_DEBUG "\tcompat %d\n", sv->compat);
147 dbg_msg("vol_type %d", sv->vol_type); 155 printk(KERN_DEBUG "\tvol_type %d\n", sv->vol_type);
148 dbg_msg("used_ebs %d", sv->used_ebs); 156 printk(KERN_DEBUG "\tused_ebs %d\n", sv->used_ebs);
149 dbg_msg("last_data_size %d", sv->last_data_size); 157 printk(KERN_DEBUG "\tlast_data_size %d\n", sv->last_data_size);
150 dbg_msg("data_pad %d", sv->data_pad); 158 printk(KERN_DEBUG "\tdata_pad %d\n", sv->data_pad);
151} 159}
152 160
153/** 161/**
@@ -157,14 +165,14 @@ void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv)
157 */ 165 */
158void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type) 166void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type)
159{ 167{
160 dbg_msg("eraseblock scanning information dump:"); 168 printk(KERN_DEBUG "eraseblock scanning information dump:\n");
161 dbg_msg("ec %d", seb->ec); 169 printk(KERN_DEBUG "\tec %d\n", seb->ec);
162 dbg_msg("pnum %d", seb->pnum); 170 printk(KERN_DEBUG "\tpnum %d\n", seb->pnum);
163 if (type == 0) { 171 if (type == 0) {
164 dbg_msg("lnum %d", seb->lnum); 172 printk(KERN_DEBUG "\tlnum %d\n", seb->lnum);
165 dbg_msg("scrub %d", seb->scrub); 173 printk(KERN_DEBUG "\tscrub %d\n", seb->scrub);
166 dbg_msg("sqnum %llu", seb->sqnum); 174 printk(KERN_DEBUG "\tsqnum %llu\n", seb->sqnum);
167 dbg_msg("leb_ver %u", seb->leb_ver); 175 printk(KERN_DEBUG "\tleb_ver %u\n", seb->leb_ver);
168 } 176 }
169} 177}
170 178
@@ -176,16 +184,16 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req)
176{ 184{
177 char nm[17]; 185 char nm[17];
178 186
179 dbg_msg("volume creation request dump:"); 187 printk(KERN_DEBUG "Volume creation request dump:\n");
180 dbg_msg("vol_id %d", req->vol_id); 188 printk(KERN_DEBUG "\tvol_id %d\n", req->vol_id);
181 dbg_msg("alignment %d", req->alignment); 189 printk(KERN_DEBUG "\talignment %d\n", req->alignment);
182 dbg_msg("bytes %lld", (long long)req->bytes); 190 printk(KERN_DEBUG "\tbytes %lld\n", (long long)req->bytes);
183 dbg_msg("vol_type %d", req->vol_type); 191 printk(KERN_DEBUG "\tvol_type %d\n", req->vol_type);
184 dbg_msg("name_len %d", req->name_len); 192 printk(KERN_DEBUG "\tname_len %d\n", req->name_len);
185 193
186 memcpy(nm, req->name, 16); 194 memcpy(nm, req->name, 16);
187 nm[16] = 0; 195 nm[16] = 0;
188 dbg_msg("the 1st 16 characters of the name: %s", nm); 196 printk(KERN_DEBUG "\t1st 16 characters of name: %s\n", nm);
189} 197}
190 198
191#endif /* CONFIG_MTD_UBI_DEBUG_MSG */ 199#endif /* CONFIG_MTD_UBI_DEBUG */
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 7d8d77c31df..78e914d23ec 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -24,21 +24,16 @@
24#ifdef CONFIG_MTD_UBI_DEBUG 24#ifdef CONFIG_MTD_UBI_DEBUG
25#include <linux/random.h> 25#include <linux/random.h>
26 26
27#define ubi_assert(expr) BUG_ON(!(expr))
28#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) 27#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
29#else
30#define ubi_assert(expr) ({})
31#define dbg_err(fmt, ...) ({})
32#endif
33 28
34#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT 29#define ubi_assert(expr) do { \
35#define DBG_DISABLE_BGT 1 30 if (unlikely(!(expr))) { \
36#else 31 printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
37#define DBG_DISABLE_BGT 0 32 __func__, __LINE__, current->pid); \
38#endif 33 ubi_dbg_dump_stack(); \
34 } \
35} while (0)
39 36
40#ifdef CONFIG_MTD_UBI_DEBUG_MSG
41/* Generic debugging message */
42#define dbg_msg(fmt, ...) \ 37#define dbg_msg(fmt, ...) \
43 printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \ 38 printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
44 current->pid, __func__, ##__VA_ARGS__) 39 current->pid, __func__, ##__VA_ARGS__)
@@ -61,19 +56,12 @@ void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv);
61void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type); 56void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type);
62void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req); 57void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
63 58
59#ifdef CONFIG_MTD_UBI_DEBUG_MSG
60/* General debugging messages */
61#define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)
64#else 62#else
65 63#define dbg_gen(fmt, ...) ({})
66#define dbg_msg(fmt, ...) ({}) 64#endif
67#define ubi_dbg_dump_stack() ({})
68#define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
69#define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
70#define ubi_dbg_dump_vol_info(vol) ({})
71#define ubi_dbg_dump_vtbl_record(r, idx) ({})
72#define ubi_dbg_dump_sv(sv) ({})
73#define ubi_dbg_dump_seb(seb, type) ({})
74#define ubi_dbg_dump_mkvol_req(req) ({})
75
76#endif /* CONFIG_MTD_UBI_DEBUG_MSG */
77 65
78#ifdef CONFIG_MTD_UBI_DEBUG_MSG_EBA 66#ifdef CONFIG_MTD_UBI_DEBUG_MSG_EBA
79/* Messages from the eraseblock association sub-system */ 67/* Messages from the eraseblock association sub-system */
@@ -105,6 +93,12 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
105#define UBI_IO_DEBUG 0 93#define UBI_IO_DEBUG 0
106#endif 94#endif
107 95
96#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
97#define DBG_DISABLE_BGT 1
98#else
99#define DBG_DISABLE_BGT 0
100#endif
101
108#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS 102#ifdef CONFIG_MTD_UBI_DEBUG_EMULATE_BITFLIPS
109/** 103/**
110 * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. 104 * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip.
@@ -149,4 +143,30 @@ static inline int ubi_dbg_is_erase_failure(void)
149#define ubi_dbg_is_erase_failure() 0 143#define ubi_dbg_is_erase_failure() 0
150#endif 144#endif
151 145
146#else
147
148#define ubi_assert(expr) ({})
149#define dbg_err(fmt, ...) ({})
150#define dbg_msg(fmt, ...) ({})
151#define dbg_gen(fmt, ...) ({})
152#define dbg_eba(fmt, ...) ({})
153#define dbg_wl(fmt, ...) ({})
154#define dbg_io(fmt, ...) ({})
155#define dbg_bld(fmt, ...) ({})
156#define ubi_dbg_dump_stack() ({})
157#define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
158#define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
159#define ubi_dbg_dump_vol_info(vol) ({})
160#define ubi_dbg_dump_vtbl_record(r, idx) ({})
161#define ubi_dbg_dump_sv(sv) ({})
162#define ubi_dbg_dump_seb(seb, type) ({})
163#define ubi_dbg_dump_mkvol_req(req) ({})
164
165#define UBI_IO_DEBUG 0
166#define DBG_DISABLE_BGT 0
167#define ubi_dbg_is_bitflip() 0
168#define ubi_dbg_is_write_failure() 0
169#define ubi_dbg_is_erase_failure() 0
170
171#endif /* !CONFIG_MTD_UBI_DEBUG */
152#endif /* !__UBI_DEBUG_H__ */ 172#endif /* !__UBI_DEBUG_H__ */
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index ae76ab638b2..49f52dceea9 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -111,7 +111,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
111 struct ubi_device *ubi; 111 struct ubi_device *ubi;
112 uint64_t tmp = from; 112 uint64_t tmp = from;
113 113
114 dbg_msg("read %zd bytes from offset %lld", len, from); 114 dbg_gen("read %zd bytes from offset %lld", len, from);
115 115
116 if (len < 0 || from < 0 || from + len > mtd->size) 116 if (len < 0 || from < 0 || from + len > mtd->size)
117 return -EINVAL; 117 return -EINVAL;
@@ -162,7 +162,7 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
162 struct ubi_device *ubi; 162 struct ubi_device *ubi;
163 uint64_t tmp = to; 163 uint64_t tmp = to;
164 164
165 dbg_msg("write %zd bytes to offset %lld", len, to); 165 dbg_gen("write %zd bytes to offset %lld", len, to);
166 166
167 if (len < 0 || to < 0 || len + to > mtd->size) 167 if (len < 0 || to < 0 || len + to > mtd->size)
168 return -EINVAL; 168 return -EINVAL;
@@ -215,7 +215,7 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
215 struct ubi_volume *vol; 215 struct ubi_volume *vol;
216 struct ubi_device *ubi; 216 struct ubi_device *ubi;
217 217
218 dbg_msg("erase %u bytes at offset %u", instr->len, instr->addr); 218 dbg_gen("erase %u bytes at offset %u", instr->len, instr->addr);
219 219
220 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) 220 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize)
221 return -EINVAL; 221 return -EINVAL;
@@ -304,7 +304,7 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
304 return -ENFILE; 304 return -ENFILE;
305 } 305 }
306 306
307 dbg_msg("added mtd%d (\"%s\"), size %u, EB size %u", 307 dbg_gen("added mtd%d (\"%s\"), size %u, EB size %u",
308 mtd->index, mtd->name, mtd->size, mtd->erasesize); 308 mtd->index, mtd->name, mtd->size, mtd->erasesize);
309 return 0; 309 return 0;
310} 310}
@@ -322,7 +322,7 @@ int ubi_destroy_gluebi(struct ubi_volume *vol)
322 int err; 322 int err;
323 struct mtd_info *mtd = &vol->gluebi_mtd; 323 struct mtd_info *mtd = &vol->gluebi_mtd;
324 324
325 dbg_msg("remove mtd%d", mtd->index); 325 dbg_gen("remove mtd%d", mtd->index);
326 err = del_mtd_device(mtd); 326 err = del_mtd_device(mtd);
327 if (err) 327 if (err)
328 return err; 328 return err;
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 561e7b2f96c..27b9c2c2fc6 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -187,7 +187,7 @@ retry:
187 ubi_assert(len == read); 187 ubi_assert(len == read);
188 188
189 if (ubi_dbg_is_bitflip()) { 189 if (ubi_dbg_is_bitflip()) {
190 dbg_msg("bit-flip (emulated)"); 190 dbg_gen("bit-flip (emulated)");
191 err = UBI_IO_BITFLIPS; 191 err = UBI_IO_BITFLIPS;
192 } 192 }
193 } 193 }
@@ -1256,7 +1256,7 @@ static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
1256 1256
1257fail: 1257fail:
1258 ubi_err("paranoid check failed for PEB %d", pnum); 1258 ubi_err("paranoid check failed for PEB %d", pnum);
1259 dbg_msg("hex dump of the %d-%d region", offset, offset + len); 1259 ubi_msg("hex dump of the %d-%d region", offset, offset + len);
1260 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 1260 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
1261 ubi->dbg_peb_buf, len, 1); 1261 ubi->dbg_peb_buf, len, 1);
1262 err = 1; 1262 err = 1;
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index e65c8e0bcd5..5d9bcf109c1 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -106,7 +106,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
106 struct ubi_device *ubi; 106 struct ubi_device *ubi;
107 struct ubi_volume *vol; 107 struct ubi_volume *vol;
108 108
109 dbg_msg("open device %d volume %d, mode %d", ubi_num, vol_id, mode); 109 dbg_gen("open device %d volume %d, mode %d", ubi_num, vol_id, mode);
110 110
111 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES) 111 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
112 return ERR_PTR(-EINVAL); 112 return ERR_PTR(-EINVAL);
@@ -215,7 +215,7 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
215 struct ubi_device *ubi; 215 struct ubi_device *ubi;
216 struct ubi_volume_desc *ret; 216 struct ubi_volume_desc *ret;
217 217
218 dbg_msg("open volume %s, mode %d", name, mode); 218 dbg_gen("open volume %s, mode %d", name, mode);
219 219
220 if (!name) 220 if (!name)
221 return ERR_PTR(-EINVAL); 221 return ERR_PTR(-EINVAL);
@@ -266,7 +266,7 @@ void ubi_close_volume(struct ubi_volume_desc *desc)
266 struct ubi_volume *vol = desc->vol; 266 struct ubi_volume *vol = desc->vol;
267 struct ubi_device *ubi = vol->ubi; 267 struct ubi_device *ubi = vol->ubi;
268 268
269 dbg_msg("close volume %d, mode %d", vol->vol_id, desc->mode); 269 dbg_gen("close volume %d, mode %d", vol->vol_id, desc->mode);
270 270
271 spin_lock(&ubi->volumes_lock); 271 spin_lock(&ubi->volumes_lock);
272 switch (desc->mode) { 272 switch (desc->mode) {
@@ -323,7 +323,7 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
323 struct ubi_device *ubi = vol->ubi; 323 struct ubi_device *ubi = vol->ubi;
324 int err, vol_id = vol->vol_id; 324 int err, vol_id = vol->vol_id;
325 325
326 dbg_msg("read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset); 326 dbg_gen("read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset);
327 327
328 if (vol_id < 0 || vol_id >= ubi->vtbl_slots || lnum < 0 || 328 if (vol_id < 0 || vol_id >= ubi->vtbl_slots || lnum < 0 ||
329 lnum >= vol->used_ebs || offset < 0 || len < 0 || 329 lnum >= vol->used_ebs || offset < 0 || len < 0 ||
@@ -388,7 +388,7 @@ int ubi_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
388 struct ubi_device *ubi = vol->ubi; 388 struct ubi_device *ubi = vol->ubi;
389 int vol_id = vol->vol_id; 389 int vol_id = vol->vol_id;
390 390
391 dbg_msg("write %d bytes to LEB %d:%d:%d", len, vol_id, lnum, offset); 391 dbg_gen("write %d bytes to LEB %d:%d:%d", len, vol_id, lnum, offset);
392 392
393 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) 393 if (vol_id < 0 || vol_id >= ubi->vtbl_slots)
394 return -EINVAL; 394 return -EINVAL;
@@ -438,7 +438,7 @@ int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf,
438 struct ubi_device *ubi = vol->ubi; 438 struct ubi_device *ubi = vol->ubi;
439 int vol_id = vol->vol_id; 439 int vol_id = vol->vol_id;
440 440
441 dbg_msg("atomically write %d bytes to LEB %d:%d", len, vol_id, lnum); 441 dbg_gen("atomically write %d bytes to LEB %d:%d", len, vol_id, lnum);
442 442
443 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) 443 if (vol_id < 0 || vol_id >= ubi->vtbl_slots)
444 return -EINVAL; 444 return -EINVAL;
@@ -482,7 +482,7 @@ int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum)
482 struct ubi_device *ubi = vol->ubi; 482 struct ubi_device *ubi = vol->ubi;
483 int err; 483 int err;
484 484
485 dbg_msg("erase LEB %d:%d", vol->vol_id, lnum); 485 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum);
486 486
487 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) 487 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
488 return -EROFS; 488 return -EROFS;
@@ -542,7 +542,7 @@ int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum)
542 struct ubi_volume *vol = desc->vol; 542 struct ubi_volume *vol = desc->vol;
543 struct ubi_device *ubi = vol->ubi; 543 struct ubi_device *ubi = vol->ubi;
544 544
545 dbg_msg("unmap LEB %d:%d", vol->vol_id, lnum); 545 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum);
546 546
547 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) 547 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
548 return -EROFS; 548 return -EROFS;
@@ -579,7 +579,7 @@ int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype)
579 struct ubi_volume *vol = desc->vol; 579 struct ubi_volume *vol = desc->vol;
580 struct ubi_device *ubi = vol->ubi; 580 struct ubi_device *ubi = vol->ubi;
581 581
582 dbg_msg("unmap LEB %d:%d", vol->vol_id, lnum); 582 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum);
583 583
584 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) 584 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
585 return -EROFS; 585 return -EROFS;
@@ -621,7 +621,7 @@ int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum)
621{ 621{
622 struct ubi_volume *vol = desc->vol; 622 struct ubi_volume *vol = desc->vol;
623 623
624 dbg_msg("test LEB %d:%d", vol->vol_id, lnum); 624 dbg_gen("test LEB %d:%d", vol->vol_id, lnum);
625 625
626 if (lnum < 0 || lnum >= vol->reserved_pebs) 626 if (lnum < 0 || lnum >= vol->reserved_pebs)
627 return -EINVAL; 627 return -EINVAL;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 892c2ba4977..40eca9ce5fa 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -932,7 +932,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
932 for (pnum = 0; pnum < ubi->peb_count; pnum++) { 932 for (pnum = 0; pnum < ubi->peb_count; pnum++) {
933 cond_resched(); 933 cond_resched();
934 934
935 dbg_msg("process PEB %d", pnum); 935 dbg_gen("process PEB %d", pnum);
936 err = process_eb(ubi, si, pnum); 936 err = process_eb(ubi, si, pnum);
937 if (err < 0) 937 if (err < 0)
938 goto out_vidh; 938 goto out_vidh;
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 6fa1ab3f2a7..1230a5e1b53 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -56,11 +56,11 @@ static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol)
56 int err; 56 int err;
57 struct ubi_vtbl_record vtbl_rec; 57 struct ubi_vtbl_record vtbl_rec;
58 58
59 dbg_msg("set update marker for volume %d", vol->vol_id); 59 dbg_gen("set update marker for volume %d", vol->vol_id);
60 60
61 if (vol->upd_marker) { 61 if (vol->upd_marker) {
62 ubi_assert(ubi->vtbl[vol->vol_id].upd_marker); 62 ubi_assert(ubi->vtbl[vol->vol_id].upd_marker);
63 dbg_msg("already set"); 63 dbg_gen("already set");
64 return 0; 64 return 0;
65 } 65 }
66 66
@@ -92,7 +92,7 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
92 uint64_t tmp; 92 uint64_t tmp;
93 struct ubi_vtbl_record vtbl_rec; 93 struct ubi_vtbl_record vtbl_rec;
94 94
95 dbg_msg("clear update marker for volume %d", vol->vol_id); 95 dbg_gen("clear update marker for volume %d", vol->vol_id);
96 96
97 memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id], 97 memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id],
98 sizeof(struct ubi_vtbl_record)); 98 sizeof(struct ubi_vtbl_record));
@@ -133,7 +133,7 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
133 int i, err; 133 int i, err;
134 uint64_t tmp; 134 uint64_t tmp;
135 135
136 dbg_msg("start update of volume %d, %llu bytes", vol->vol_id, bytes); 136 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes);
137 ubi_assert(!vol->updating && !vol->changing_leb); 137 ubi_assert(!vol->updating && !vol->changing_leb);
138 vol->updating = 1; 138 vol->updating = 1;
139 139
@@ -183,7 +183,7 @@ int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
183{ 183{
184 ubi_assert(!vol->updating && !vol->changing_leb); 184 ubi_assert(!vol->updating && !vol->changing_leb);
185 185
186 dbg_msg("start changing LEB %d:%d, %u bytes", 186 dbg_gen("start changing LEB %d:%d, %u bytes",
187 vol->vol_id, req->lnum, req->bytes); 187 vol->vol_id, req->lnum, req->bytes);
188 if (req->bytes == 0) 188 if (req->bytes == 0)
189 return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0, 189 return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0,
@@ -242,7 +242,7 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
242 memset(buf + len, 0xFF, l - len); 242 memset(buf + len, 0xFF, l - len);
243 len = ubi_calc_data_len(ubi, buf, l); 243 len = ubi_calc_data_len(ubi, buf, l);
244 if (len == 0) { 244 if (len == 0) {
245 dbg_msg("all %d bytes contain 0xFF - skip", len); 245 dbg_gen("all %d bytes contain 0xFF - skip", len);
246 return 0; 246 return 0;
247 } 247 }
248 248
@@ -283,7 +283,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
283 uint64_t tmp; 283 uint64_t tmp;
284 int lnum, offs, err = 0, len, to_write = count; 284 int lnum, offs, err = 0, len, to_write = count;
285 285
286 dbg_msg("write %d of %lld bytes, %lld already passed", 286 dbg_gen("write %d of %lld bytes, %lld already passed",
287 count, vol->upd_bytes, vol->upd_received); 287 count, vol->upd_bytes, vol->upd_received);
288 288
289 if (ubi->ro_mode) 289 if (ubi->ro_mode)
@@ -400,7 +400,7 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
400{ 400{
401 int err; 401 int err;
402 402
403 dbg_msg("write %d of %lld bytes, %lld already passed", 403 dbg_gen("write %d of %lld bytes, %lld already passed",
404 count, vol->upd_bytes, vol->upd_received); 404 count, vol->upd_bytes, vol->upd_received);
405 405
406 if (ubi->ro_mode) 406 if (ubi->ro_mode)
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index bfa7c5d2e06..2cd886a5ada 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -28,9 +28,9 @@
28#include "ubi.h" 28#include "ubi.h"
29 29
30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
31static void paranoid_check_volumes(struct ubi_device *ubi); 31static int paranoid_check_volumes(struct ubi_device *ubi);
32#else 32#else
33#define paranoid_check_volumes(ubi) 33#define paranoid_check_volumes(ubi) 0
34#endif 34#endif
35 35
36static ssize_t vol_attribute_show(struct device *dev, 36static ssize_t vol_attribute_show(struct device *dev,
@@ -218,7 +218,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
218 spin_lock(&ubi->volumes_lock); 218 spin_lock(&ubi->volumes_lock);
219 if (vol_id == UBI_VOL_NUM_AUTO) { 219 if (vol_id == UBI_VOL_NUM_AUTO) {
220 /* Find unused volume ID */ 220 /* Find unused volume ID */
221 dbg_msg("search for vacant volume ID"); 221 dbg_gen("search for vacant volume ID");
222 for (i = 0; i < ubi->vtbl_slots; i++) 222 for (i = 0; i < ubi->vtbl_slots; i++)
223 if (!ubi->volumes[i]) { 223 if (!ubi->volumes[i]) {
224 vol_id = i; 224 vol_id = i;
@@ -233,7 +233,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
233 req->vol_id = vol_id; 233 req->vol_id = vol_id;
234 } 234 }
235 235
236 dbg_msg("volume ID %d, %llu bytes, type %d, name %s", 236 dbg_gen("volume ID %d, %llu bytes, type %d, name %s",
237 vol_id, (unsigned long long)req->bytes, 237 vol_id, (unsigned long long)req->bytes,
238 (int)req->vol_type, req->name); 238 (int)req->vol_type, req->name);
239 239
@@ -361,8 +361,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
361 ubi->vol_count += 1; 361 ubi->vol_count += 1;
362 spin_unlock(&ubi->volumes_lock); 362 spin_unlock(&ubi->volumes_lock);
363 363
364 paranoid_check_volumes(ubi); 364 err = paranoid_check_volumes(ubi);
365 return 0; 365 return err;
366 366
367out_sysfs: 367out_sysfs:
368 /* 368 /*
@@ -414,7 +414,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc)
414 struct ubi_device *ubi = vol->ubi; 414 struct ubi_device *ubi = vol->ubi;
415 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs; 415 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs;
416 416
417 dbg_msg("remove UBI volume %d", vol_id); 417 dbg_gen("remove UBI volume %d", vol_id);
418 ubi_assert(desc->mode == UBI_EXCLUSIVE); 418 ubi_assert(desc->mode == UBI_EXCLUSIVE);
419 ubi_assert(vol == ubi->volumes[vol_id]); 419 ubi_assert(vol == ubi->volumes[vol_id]);
420 420
@@ -465,8 +465,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc)
465 ubi->vol_count -= 1; 465 ubi->vol_count -= 1;
466 spin_unlock(&ubi->volumes_lock); 466 spin_unlock(&ubi->volumes_lock);
467 467
468 paranoid_check_volumes(ubi); 468 err = paranoid_check_volumes(ubi);
469 return 0; 469 return err;
470 470
471out_err: 471out_err:
472 ubi_err("cannot remove volume %d, error %d", vol_id, err); 472 ubi_err("cannot remove volume %d, error %d", vol_id, err);
@@ -497,7 +497,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
497 if (ubi->ro_mode) 497 if (ubi->ro_mode)
498 return -EROFS; 498 return -EROFS;
499 499
500 dbg_msg("re-size volume %d to from %d to %d PEBs", 500 dbg_gen("re-size volume %d to from %d to %d PEBs",
501 vol_id, vol->reserved_pebs, reserved_pebs); 501 vol_id, vol->reserved_pebs, reserved_pebs);
502 502
503 if (vol->vol_type == UBI_STATIC_VOLUME && 503 if (vol->vol_type == UBI_STATIC_VOLUME &&
@@ -586,8 +586,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
586 (long long)vol->used_ebs * vol->usable_leb_size; 586 (long long)vol->used_ebs * vol->usable_leb_size;
587 } 587 }
588 588
589 paranoid_check_volumes(ubi); 589 err = paranoid_check_volumes(ubi);
590 return 0; 590 return err;
591 591
592out_acc: 592out_acc:
593 if (pebs > 0) { 593 if (pebs > 0) {
@@ -615,8 +615,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
615 int err, vol_id = vol->vol_id; 615 int err, vol_id = vol->vol_id;
616 dev_t dev; 616 dev_t dev;
617 617
618 dbg_msg("add volume %d", vol_id); 618 dbg_gen("add volume %d", vol_id);
619 ubi_dbg_dump_vol_info(vol);
620 619
621 /* Register character device for the volume */ 620 /* Register character device for the volume */
622 cdev_init(&vol->cdev, &ubi_vol_cdev_operations); 621 cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
@@ -650,8 +649,8 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
650 return err; 649 return err;
651 } 650 }
652 651
653 paranoid_check_volumes(ubi); 652 err = paranoid_check_volumes(ubi);
654 return 0; 653 return err;
655 654
656out_gluebi: 655out_gluebi:
657 err = ubi_destroy_gluebi(vol); 656 err = ubi_destroy_gluebi(vol);
@@ -672,7 +671,7 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
672{ 671{
673 int err; 672 int err;
674 673
675 dbg_msg("free volume %d", vol->vol_id); 674 dbg_gen("free volume %d", vol->vol_id);
676 675
677 ubi->volumes[vol->vol_id] = NULL; 676 ubi->volumes[vol->vol_id] = NULL;
678 err = ubi_destroy_gluebi(vol); 677 err = ubi_destroy_gluebi(vol);
@@ -686,8 +685,10 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
686 * paranoid_check_volume - check volume information. 685 * paranoid_check_volume - check volume information.
687 * @ubi: UBI device description object 686 * @ubi: UBI device description object
688 * @vol_id: volume ID 687 * @vol_id: volume ID
688 *
689 * Returns zero if volume is all right and a a negative error code if not.
689 */ 690 */
690static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) 691static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
691{ 692{
692 int idx = vol_id2idx(ubi, vol_id); 693 int idx = vol_id2idx(ubi, vol_id);
693 int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker; 694 int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker;
@@ -705,16 +706,7 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
705 goto fail; 706 goto fail;
706 } 707 }
707 spin_unlock(&ubi->volumes_lock); 708 spin_unlock(&ubi->volumes_lock);
708 return; 709 return 0;
709 }
710
711 if (vol->exclusive) {
712 /*
713 * The volume may be being created at the moment, do not check
714 * it (e.g., it may be in the middle of ubi_create_volume().
715 */
716 spin_unlock(&ubi->volumes_lock);
717 return;
718 } 710 }
719 711
720 if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || 712 if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 ||
@@ -830,25 +822,34 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
830 } 822 }
831 823
832 spin_unlock(&ubi->volumes_lock); 824 spin_unlock(&ubi->volumes_lock);
833 return; 825 return 0;
834 826
835fail: 827fail:
836 ubi_err("paranoid check failed for volume %d", vol_id); 828 ubi_err("paranoid check failed for volume %d", vol_id);
837 ubi_dbg_dump_vol_info(vol); 829 if (vol) {
838 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); 830 ubi_dbg_dump_vol_info(vol);
831 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
832 }
839 spin_unlock(&ubi->volumes_lock); 833 spin_unlock(&ubi->volumes_lock);
840 BUG(); 834 return -EINVAL;
841} 835}
842 836
843/** 837/**
844 * paranoid_check_volumes - check information about all volumes. 838 * paranoid_check_volumes - check information about all volumes.
845 * @ubi: UBI device description object 839 * @ubi: UBI device description object
840 *
841 * Returns zero if volumes are all right and a a negative error code if not.
846 */ 842 */
847static void paranoid_check_volumes(struct ubi_device *ubi) 843static int paranoid_check_volumes(struct ubi_device *ubi)
848{ 844{
849 int i; 845 int i, err = 0;
850 846
851 for (i = 0; i < ubi->vtbl_slots; i++) 847 for (i = 0; i < ubi->vtbl_slots; i++) {
852 paranoid_check_volume(ubi, i); 848 err = paranoid_check_volume(ubi, i);
849 if (err)
850 break;
851 }
852
853 return err;
853} 854}
854#endif 855#endif
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index d9af11a8682..05fb72fd268 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -371,7 +371,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
371 * to LEB 0. 371 * to LEB 0.
372 */ 372 */
373 373
374 dbg_msg("check layout volume"); 374 dbg_gen("check layout volume");
375 375
376 /* Read both LEB 0 and LEB 1 into memory */ 376 /* Read both LEB 0 and LEB 1 into memory */
377 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { 377 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {