target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
static bool nmbm_write_repeated_data(struct nmbm_instance *ni, uint32_t ba,
				     const void *data, uint32_t size)
{
	uint64_t addr, off;
	bool success;
	int ret;

	if (size > bmtd.pg_size)
		return false;

	addr = ba2addr(ni, ba);

	for (off = 0; off < bmtd.blk_size; off += bmtd.pg_size) {
		/* Prepare page data. fill 0xff to unused region */
		memcpy(ni->page_cache, data, size);
		memset(ni->page_cache + size, 0xff, ni->rawpage_size - size);

		success = nmbm_write_phys_page(ni, addr + off, ni->page_cache, NULL);
		if (!success)
			return false;

		/* Verify the data just written. ECC error indicates failure */
		ret = nmbm_read_phys_page(ni, addr + off, ni->page_cache, NULL);
		if (ret < 0)
			return false;

		if (memcmp(ni->page_cache, data, size))
			return false;
	}

	return true;
}
/*
 * nmbm_write_repeated_data - Write critical data to a block with retry
 * @ni: NMBM instance structure
 * @ba: block address where the data will be written to
 * @data: the data to be written
 * @size: size of the data
 *
 * Write data to every page of the block. Success only if all pages within
 * this block have been successfully written.
 *
 * Make sure data size is not bigger than one page.
 *
 * This function will write and verify every page for at most
 * NMBM_TRY_COUNT times.
 */
Write critical data to a block with retry
@ni: NMBM instance structure
@ba: block address where the data will be written to
@data: the data to be written
@size: size of the data

Write data to every page of the block. Success only if all pages within
this block have been successfully written.

Make sure data size is not bigger than one page.

This function will write and verify every page for at most
NMBM_TRY_COUNT times.
Write critical data to a block with retry @ni : NMBM instance structure @ba : block address where the data will be written to @data : the data to be written @size : size of the data Write data to every page of the block . Success only if all pages within this block have been successfully written . Make sure data size is not bigger than one page . This function will write and verify every page for at most NMBM_TRY_COUNT times .
static bool nmbm_write_repeated_data(struct nmbm_instance *ni, uint32_t ba,
				     const void *data, uint32_t size)
{
	uint64_t addr, off;
	bool success;
	int ret;
	if (size > bmtd.pg_size)
		return false;
	addr = ba2addr(ni, ba);
	for (off = 0; off < bmtd.blk_size; off += bmtd.pg_size) {
		memcpy(ni->page_cache, data, size);
		memset(ni->page_cache + size, 0xff, ni->rawpage_size - size);
		success = nmbm_write_phys_page(ni, addr + off, ni->page_cache, NULL);
		if (!success)
			return false;
		ret = nmbm_read_phys_page(ni, addr + off, ni->page_cache, NULL);
		if (ret < 0)
			return false;
		if (memcmp(ni->page_cache, data, size))
			return false;
	}
	return true;
}
static bool nmbm_write_repeated_data ( struct nmbm_instance * ni , uint32_t ba , const void * data , uint32_t size ) { uint64_t addr , off ; bool success ; int ret ; if ( size > bmtd . pg_size ) return false ; addr = ba2addr ( ni , ba ) ; for ( off = 0 ; off < bmtd . blk_size ; off += bmtd . pg_size ) { memcpy ( ni -> page_cache , data , size ) ; memset ( ni -> page_cache + size , 0xff , ni -> rawpage_size - size ) ; success = nmbm_write_phys_page ( ni , addr + off , ni -> page_cache , NULL ) ; if ( ! success ) return false ; ret = nmbm_read_phys_page ( ni , addr + off , ni -> page_cache , NULL ) ; if ( ret < 0 ) return false ; if ( memcmp ( ni -> page_cache , data , size ) ) return false ; } return true ; }
nmbm_write_repeated_data - Write critical data to a block with retry
 @ni: NMBM instance structure
 @ba: block address where the data will be written to
 @data: the data to be written
 @size: size of the data
nmbm_write_repeated_data - Write critical data to a block with retry @ni : NMBM instance structure @ba : block address where the data will be written to @data : the data to be written @size : size of the data
/* Prepare page data. fill 0xff to unused region */ /* Verify the data just written. ECC error indicates failure */