diff options
| author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-07-31 02:37:34 -0400 |
|---|---|---|
| committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-10-19 10:19:57 -0400 |
| commit | bb00e180a93a6c8e89c3b2d1f9473781e1e2d2a4 (patch) | |
| tree | 87bd9ddc65052014e36e4fb0565e73d7ff4dd992 | |
| parent | 0525dac9fd31e5a12fb934238abd09e2752a5967 (diff) | |
UBI: make check_pattern function non-static
This patch turns static function 'check_pattern()' into a non-static
'ubi_check_pattern()'. This is just a preparation for the chages which
are coming in the next patches.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| -rw-r--r-- | drivers/mtd/ubi/io.c | 30 | ||||
| -rw-r--r-- | drivers/mtd/ubi/misc.c | 19 | ||||
| -rw-r--r-- | drivers/mtd/ubi/ubi.h | 1 |
3 files changed, 26 insertions, 24 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index b76252465c87..c2960ac9f39c 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
| @@ -376,25 +376,6 @@ retry: | |||
| 376 | return 0; | 376 | return 0; |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | /** | ||
| 380 | * check_pattern - check if buffer contains only a certain byte pattern. | ||
| 381 | * @buf: buffer to check | ||
| 382 | * @patt: the pattern to check | ||
| 383 | * @size: buffer size in bytes | ||
| 384 | * | ||
| 385 | * This function returns %1 in there are only @patt bytes in @buf, and %0 if | ||
| 386 | * something else was also found. | ||
| 387 | */ | ||
| 388 | static int check_pattern(const void *buf, uint8_t patt, int size) | ||
| 389 | { | ||
| 390 | int i; | ||
| 391 | |||
| 392 | for (i = 0; i < size; i++) | ||
| 393 | if (((const uint8_t *)buf)[i] != patt) | ||
| 394 | return 0; | ||
| 395 | return 1; | ||
| 396 | } | ||
| 397 | |||
| 398 | /* Patterns to write to a physical eraseblock when torturing it */ | 379 | /* Patterns to write to a physical eraseblock when torturing it */ |
| 399 | static uint8_t patterns[] = {0xa5, 0x5a, 0x0}; | 380 | static uint8_t patterns[] = {0xa5, 0x5a, 0x0}; |
| 400 | 381 | ||
| @@ -426,7 +407,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) | |||
| 426 | if (err) | 407 | if (err) |
| 427 | goto out; | 408 | goto out; |
| 428 | 409 | ||
| 429 | err = check_pattern(ubi->peb_buf1, 0xFF, ubi->peb_size); | 410 | err = ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->peb_size); |
| 430 | if (err == 0) { | 411 | if (err == 0) { |
| 431 | ubi_err("erased PEB %d, but a non-0xFF byte found", | 412 | ubi_err("erased PEB %d, but a non-0xFF byte found", |
| 432 | pnum); | 413 | pnum); |
| @@ -445,7 +426,8 @@ static int torture_peb(struct ubi_device *ubi, int pnum) | |||
| 445 | if (err) | 426 | if (err) |
| 446 | goto out; | 427 | goto out; |
| 447 | 428 | ||
| 448 | err = check_pattern(ubi->peb_buf1, patterns[i], ubi->peb_size); | 429 | err = ubi_check_pattern(ubi->peb_buf1, patterns[i], |
| 430 | ubi->peb_size); | ||
| 449 | if (err == 0) { | 431 | if (err == 0) { |
| 450 | ubi_err("pattern %x checking failed for PEB %d", | 432 | ubi_err("pattern %x checking failed for PEB %d", |
| 451 | patterns[i], pnum); | 433 | patterns[i], pnum); |
| @@ -752,7 +734,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
| 752 | * 0xFF. If yes, this physical eraseblock is assumed to be | 734 | * 0xFF. If yes, this physical eraseblock is assumed to be |
| 753 | * empty. | 735 | * empty. |
| 754 | */ | 736 | */ |
| 755 | if (check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) { | 737 | if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) { |
| 756 | /* The physical eraseblock is supposedly empty */ | 738 | /* The physical eraseblock is supposedly empty */ |
| 757 | if (verbose) | 739 | if (verbose) |
| 758 | ubi_warn("no EC header found at PEB %d, " | 740 | ubi_warn("no EC header found at PEB %d, " |
| @@ -1009,7 +991,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
| 1009 | if (read_err == -EBADMSG) | 991 | if (read_err == -EBADMSG) |
| 1010 | return UBI_IO_BAD_HDR_EBADMSG; | 992 | return UBI_IO_BAD_HDR_EBADMSG; |
| 1011 | 993 | ||
| 1012 | if (check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { | 994 | if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { |
| 1013 | if (verbose) | 995 | if (verbose) |
| 1014 | ubi_warn("no VID header found at PEB %d, " | 996 | ubi_warn("no VID header found at PEB %d, " |
| 1015 | "only 0xFF bytes", pnum); | 997 | "only 0xFF bytes", pnum); |
| @@ -1363,7 +1345,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) | |||
| 1363 | goto error; | 1345 | goto error; |
| 1364 | } | 1346 | } |
| 1365 | 1347 | ||
| 1366 | err = check_pattern(ubi->dbg_peb_buf, 0xFF, len); | 1348 | err = ubi_check_pattern(ubi->dbg_peb_buf, 0xFF, len); |
| 1367 | if (err == 0) { | 1349 | if (err == 0) { |
| 1368 | ubi_err("flash region at PEB %d:%d, length %d does not " | 1350 | ubi_err("flash region at PEB %d:%d, length %d does not " |
| 1369 | "contain all 0xFF bytes", pnum, offset, len); | 1351 | "contain all 0xFF bytes", pnum, offset, len); |
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 | */ | ||
| 116 | int 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 | } | ||
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 10990770bc9e..8831d7ba9f21 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
| @@ -511,6 +511,7 @@ int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, | |||
| 511 | int length); | 511 | int length); |
| 512 | int ubi_check_volume(struct ubi_device *ubi, int vol_id); | 512 | int ubi_check_volume(struct ubi_device *ubi, int vol_id); |
| 513 | void ubi_calculate_reserved(struct ubi_device *ubi); | 513 | void ubi_calculate_reserved(struct ubi_device *ubi); |
| 514 | int ubi_check_pattern(const void *buf, uint8_t patt, int size); | ||
| 514 | 515 | ||
| 515 | /* eba.c */ | 516 | /* eba.c */ |
| 516 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, | 517 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, |
