aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/misc.c
diff options
context:
space:
mode:
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 22ad31402945..ff2a65c37f69 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)
103 if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS) 103 if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS)
104 ubi->beb_rsvd_level = MIN_RESEVED_PEBS; 104 ubi->beb_rsvd_level = MIN_RESEVED_PEBS;
105} 105}
106
107/**
108 * ubi_check_pattern - check if buffer contains only a certain byte pattern.
109 * @buf: buffer to check
110 * @patt: the pattern to check
111 * @size: buffer size in bytes
112 *
113 * This function returns %1 in there are only @patt bytes in @buf, and %0 if
114 * something else was also found.
115 */
116int ubi_check_pattern(const void *buf, uint8_t patt, int size)
117{
118 int i;
119
120 for (i = 0; i < size; i++)
121 if (((const uint8_t *)buf)[i] != patt)
122 return 0;
123 return 1;
124}