summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/misc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 16:34:23 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 16:34:23 -0700
commit4f3a29dadaf999a273f1e7fe2476595d0283eef3 (patch)
tree3776499f6edc95a36533c7efe32a7b6038c88b61 /drivers/mtd/ubi/misc.c
parent06d362931a530e0d48c1a9554a752da4ed240f0b (diff)
parent45aafd32996e27bfc4862654ff31231bdddbe200 (diff)
downloadop-kernel-dev-4f3a29dadaf999a273f1e7fe2476595d0283eef3.zip
op-kernel-dev-4f3a29dadaf999a273f1e7fe2476595d0283eef3.tar.gz
Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6
* 'linux-next' of git://git.infradead.org/ubi-2.6: UBI: tighten the corrupted PEB criteria UBI: fix check_data_ff return code UBI: remember copy_flag while scanning UBI: preserve corrupted PEBs UBI: add truly corrupted PEBs to corrupted list UBI: introduce debugging helper function UBI: make check_pattern function non-static UBI: do not put eraseblocks to the corrupted list unnecessarily UBI: separate out corrupted list UBI: change cascade of ifs to switch statements UBI: rename a local variable UBI: handle bit-flips when no header found UBI: remove duplicate IO error codes UBI: rename IO error code UBI: fix small 80 characters limit style issue UBI: cleanup and simplify Kconfig
Diffstat (limited to 'drivers/mtd/ubi/misc.c')
-rw-r--r--drivers/mtd/ubi/misc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c
index 22ad314..ff2a65c 100644
--- a/drivers/mtd/ubi/misc.c
+++ b/drivers/mtd/ubi/misc.c
@@ -103,3 +103,22 @@ void ubi_calculate_reserved(struct ubi_device *ubi)
if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS)
ubi->beb_rsvd_level = MIN_RESEVED_PEBS;
}
+
+/**
+ * ubi_check_pattern - check if buffer contains only a certain byte pattern.
+ * @buf: buffer to check
+ * @patt: the pattern to check
+ * @size: buffer size in bytes
+ *
+ * This function returns %1 in there are only @patt bytes in @buf, and %0 if
+ * something else was also found.
+ */
+int ubi_check_pattern(const void *buf, uint8_t patt, int size)
+{
+ int i;
+
+ for (i = 0; i < size; i++)
+ if (((const uint8_t *)buf)[i] != patt)
+ return 0;
+ return 1;
+}
OpenPOWER on IntegriCloud