aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/io.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-14 12:17:40 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-16 07:50:16 -0400
commit92d124f5314913a21f7fa98b22ee457dab171edd (patch)
tree8a8c187f12290424419f0a05caeb202cd73253cc /drivers/mtd/ubi/io.c
parentb342efd4a49cef9cf1a260c1814aad97722f38f8 (diff)
UBI: make self-checks dynamic
This patch adds a possibility to dynamically switch UBI self-checks on and off, instead of toggling them compile-time from the configuration menu. This is much more flexible, and consistent with UBIFS, and this also simplifies UBI Kconfig menu and the code. This patch introduces two levels of self-checks - general, which includes all self-checks which are relatively fast, and I/O, which includes write-verify checks and erase-verify checks, which are relatively slow and involve flash I/O. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r--drivers/mtd/ubi/io.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index b1ad1ec812ad..aaa6e1e83b29 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -91,7 +91,7 @@
91#include <linux/slab.h> 91#include <linux/slab.h>
92#include "ubi.h" 92#include "ubi.h"
93 93
94#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 94#ifdef CONFIG_MTD_UBI_DEBUG
95static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum); 95static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum);
96static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum); 96static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum);
97static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum, 97static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
@@ -1126,7 +1126,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
1126 return err; 1126 return err;
1127} 1127}
1128 1128
1129#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 1129#ifdef CONFIG_MTD_UBI_DEBUG
1130 1130
1131/** 1131/**
1132 * paranoid_check_not_bad - ensure that a physical eraseblock is not bad. 1132 * paranoid_check_not_bad - ensure that a physical eraseblock is not bad.
@@ -1140,6 +1140,9 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
1140{ 1140{
1141 int err; 1141 int err;
1142 1142
1143 if (!(ubi_chk_flags & UBI_CHK_IO))
1144 return 0;
1145
1143 err = ubi_io_is_bad(ubi, pnum); 1146 err = ubi_io_is_bad(ubi, pnum);
1144 if (!err) 1147 if (!err)
1145 return err; 1148 return err;
@@ -1164,6 +1167,9 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1164 int err; 1167 int err;
1165 uint32_t magic; 1168 uint32_t magic;
1166 1169
1170 if (!(ubi_chk_flags & UBI_CHK_IO))
1171 return 0;
1172
1167 magic = be32_to_cpu(ec_hdr->magic); 1173 magic = be32_to_cpu(ec_hdr->magic);
1168 if (magic != UBI_EC_HDR_MAGIC) { 1174 if (magic != UBI_EC_HDR_MAGIC) {
1169 ubi_err("bad magic %#08x, must be %#08x", 1175 ubi_err("bad magic %#08x, must be %#08x",
@@ -1199,6 +1205,9 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
1199 uint32_t crc, hdr_crc; 1205 uint32_t crc, hdr_crc;
1200 struct ubi_ec_hdr *ec_hdr; 1206 struct ubi_ec_hdr *ec_hdr;
1201 1207
1208 if (!(ubi_chk_flags & UBI_CHK_IO))
1209 return 0;
1210
1202 ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); 1211 ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
1203 if (!ec_hdr) 1212 if (!ec_hdr)
1204 return -ENOMEM; 1213 return -ENOMEM;
@@ -1240,6 +1249,9 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
1240 int err; 1249 int err;
1241 uint32_t magic; 1250 uint32_t magic;
1242 1251
1252 if (!(ubi_chk_flags & UBI_CHK_IO))
1253 return 0;
1254
1243 magic = be32_to_cpu(vid_hdr->magic); 1255 magic = be32_to_cpu(vid_hdr->magic);
1244 if (magic != UBI_VID_HDR_MAGIC) { 1256 if (magic != UBI_VID_HDR_MAGIC) {
1245 ubi_err("bad VID header magic %#08x at PEB %d, must be %#08x", 1257 ubi_err("bad VID header magic %#08x at PEB %d, must be %#08x",
@@ -1278,6 +1290,9 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1278 struct ubi_vid_hdr *vid_hdr; 1290 struct ubi_vid_hdr *vid_hdr;
1279 void *p; 1291 void *p;
1280 1292
1293 if (!(ubi_chk_flags & UBI_CHK_IO))
1294 return 0;
1295
1281 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); 1296 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
1282 if (!vid_hdr) 1297 if (!vid_hdr)
1283 return -ENOMEM; 1298 return -ENOMEM;
@@ -1327,6 +1342,9 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
1327 void *buf1; 1342 void *buf1;
1328 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; 1343 loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
1329 1344
1345 if (!(ubi_chk_flags & UBI_CHK_IO))
1346 return 0;
1347
1330 buf1 = __vmalloc(len, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); 1348 buf1 = __vmalloc(len, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL);
1331 if (!buf1) { 1349 if (!buf1) {
1332 ubi_err("cannot allocate memory to check writes"); 1350 ubi_err("cannot allocate memory to check writes");
@@ -1388,6 +1406,9 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
1388 void *buf; 1406 void *buf;
1389 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; 1407 loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
1390 1408
1409 if (!(ubi_chk_flags & UBI_CHK_IO))
1410 return 0;
1411
1391 buf = __vmalloc(len, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); 1412 buf = __vmalloc(len, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL);
1392 if (!buf) { 1413 if (!buf) {
1393 ubi_err("cannot allocate memory to check for 0xFFs"); 1414 ubi_err("cannot allocate memory to check for 0xFFs");
@@ -1422,4 +1443,4 @@ error:
1422 return err; 1443 return err;
1423} 1444}
1424 1445
1425#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ 1446#endif /* CONFIG_MTD_UBI_DEBUG */