Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb00e180 authored by Artem Bityutskiy's avatar Artem Bityutskiy
Browse files

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: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 0525dac9
Loading
Loading
Loading
Loading
+6 −24
Original line number Original line Diff line number Diff line
@@ -376,25 +376,6 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
	return 0;
	return 0;
}
}


/**
 * 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.
 */
static int 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;
}

/* Patterns to write to a physical eraseblock when torturing it */
/* Patterns to write to a physical eraseblock when torturing it */
static uint8_t patterns[] = {0xa5, 0x5a, 0x0};
static uint8_t patterns[] = {0xa5, 0x5a, 0x0};


@@ -426,7 +407,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
		if (err)
		if (err)
			goto out;
			goto out;


		err = check_pattern(ubi->peb_buf1, 0xFF, ubi->peb_size);
		err = ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->peb_size);
		if (err == 0) {
		if (err == 0) {
			ubi_err("erased PEB %d, but a non-0xFF byte found",
			ubi_err("erased PEB %d, but a non-0xFF byte found",
				pnum);
				pnum);
@@ -445,7 +426,8 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
		if (err)
		if (err)
			goto out;
			goto out;


		err = check_pattern(ubi->peb_buf1, patterns[i], ubi->peb_size);
		err = ubi_check_pattern(ubi->peb_buf1, patterns[i],
					ubi->peb_size);
		if (err == 0) {
		if (err == 0) {
			ubi_err("pattern %x checking failed for PEB %d",
			ubi_err("pattern %x checking failed for PEB %d",
				patterns[i], pnum);
				patterns[i], pnum);
@@ -752,7 +734,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
		 * 0xFF. If yes, this physical eraseblock is assumed to be
		 * 0xFF. If yes, this physical eraseblock is assumed to be
		 * empty.
		 * empty.
		 */
		 */
		if (check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
		if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
			/* The physical eraseblock is supposedly empty */
			/* The physical eraseblock is supposedly empty */
			if (verbose)
			if (verbose)
				ubi_warn("no EC header found at PEB %d, "
				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,
		if (read_err == -EBADMSG)
		if (read_err == -EBADMSG)
			return UBI_IO_BAD_HDR_EBADMSG;
			return UBI_IO_BAD_HDR_EBADMSG;


		if (check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
		if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
			if (verbose)
			if (verbose)
				ubi_warn("no VID header found at PEB %d, "
				ubi_warn("no VID header found at PEB %d, "
					 "only 0xFF bytes", pnum);
					 "only 0xFF bytes", pnum);
@@ -1363,7 +1345,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
		goto error;
		goto error;
	}
	}


	err = check_pattern(ubi->dbg_peb_buf, 0xFF, len);
	err = ubi_check_pattern(ubi->dbg_peb_buf, 0xFF, len);
	if (err == 0) {
	if (err == 0) {
		ubi_err("flash region at PEB %d:%d, length %d does not "
		ubi_err("flash region at PEB %d:%d, length %d does not "
			"contain all 0xFF bytes", pnum, offset, len);
			"contain all 0xFF bytes", pnum, offset, len);
+19 −0
Original line number Original line Diff line number Diff line
@@ -103,3 +103,22 @@ void ubi_calculate_reserved(struct ubi_device *ubi)
	if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS)
	if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS)
		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;
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -511,6 +511,7 @@ int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
		      int length);
		      int length);
int ubi_check_volume(struct ubi_device *ubi, int vol_id);
int ubi_check_volume(struct ubi_device *ubi, int vol_id);
void ubi_calculate_reserved(struct ubi_device *ubi);
void ubi_calculate_reserved(struct ubi_device *ubi);
int ubi_check_pattern(const void *buf, uint8_t patt, int size);


/* eba.c */
/* eba.c */
int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,
int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,