target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
static bool nmbm_write_signature(struct nmbm_instance *ni, uint32_t limit,
				 const struct nmbm_signature *signature,
				 uint32_t *signature_ba)
{
	uint32_t ba = ni->block_count - 1;
	bool success;

	while (ba > limit) {
		if (nmbm_get_block_state(ni, ba) != BLOCK_ST_GOOD)
			goto next_block;

		/* Insurance to detect unexpected bad block marked by user */
		if (nmbm_check_bad_phys_block(ni, ba)) {
			nmbm_set_block_state(ni, ba, BLOCK_ST_BAD);
			goto next_block;
		}

		success = nmbm_erase_block_and_check(ni, ba);
		if (!success)
			goto skip_bad_block;

		success = nmbm_write_repeated_data(ni, ba, signature,
						   sizeof(*signature));
		if (success) {
			*signature_ba = ba;
			return true;
		}

	skip_bad_block:
		nmbm_mark_phys_bad_block(ni, ba);
		nmbm_set_block_state(ni, ba, BLOCK_ST_BAD);

	next_block:
		ba--;
	};

	return false;
}
/*
 * nmbm_write_signature - Write signature to NAND chip
 * @ni: NMBM instance structure
 * @limit: top block address allowed for writing
 * @signature: the signature to be written
 * @signature_ba: the actual block address where signature is written to
 *
 * Write signature within a specific range, from chip bottom to limit.
 * At most one block will be written.
 *
 * @limit is not counted into the allowed write address.
 */
Write signature to NAND chip
@ni: NMBM instance structure
@limit: top block address allowed for writing
@signature: the signature to be written
@signature_ba: the actual block address where signature is written to

Write signature within a specific range, from chip bottom to limit.
At most one block will be written.

@limit is not counted into the allowed write address.
Write signature to NAND chip @ni : NMBM instance structure @limit : top block address allowed for writing @signature : the signature to be written @signature_ba : the actual block address where signature is written to Write signature within a specific range from chip bottom to limit . At most one block will be written . @limit is not counted into the allowed write address .
static bool nmbm_write_signature(struct nmbm_instance *ni, uint32_t limit,
				 const struct nmbm_signature *signature,
				 uint32_t *signature_ba)
{
	uint32_t ba = ni->block_count - 1;
	bool success;
	while (ba > limit) {
		if (nmbm_get_block_state(ni, ba) != BLOCK_ST_GOOD)
			goto next_block;
		if (nmbm_check_bad_phys_block(ni, ba)) {
			nmbm_set_block_state(ni, ba, BLOCK_ST_BAD);
			goto next_block;
		}
		success = nmbm_erase_block_and_check(ni, ba);
		if (!success)
			goto skip_bad_block;
		success = nmbm_write_repeated_data(ni, ba, signature,
						   sizeof(*signature));
		if (success) {
			*signature_ba = ba;
			return true;
		}
	skip_bad_block:
		nmbm_mark_phys_bad_block(ni, ba);
		nmbm_set_block_state(ni, ba, BLOCK_ST_BAD);
	next_block:
		ba--;
	};
	return false;
}
static bool nmbm_write_signature ( struct nmbm_instance * ni , uint32_t limit , const struct nmbm_signature * signature , uint32_t * signature_ba ) { uint32_t ba = ni -> block_count - 1 ; bool success ; while ( ba > limit ) { if ( nmbm_get_block_state ( ni , ba ) != BLOCK_ST_GOOD ) goto next_block ; if ( nmbm_check_bad_phys_block ( ni , ba ) ) { nmbm_set_block_state ( ni , ba , BLOCK_ST_BAD ) ; goto next_block ; } success = nmbm_erase_block_and_check ( ni , ba ) ; if ( ! success ) goto skip_bad_block ; success = nmbm_write_repeated_data ( ni , ba , signature , sizeof ( * signature ) ) ; if ( success ) { * signature_ba = ba ; return true ; } skip_bad_block : nmbm_mark_phys_bad_block ( ni , ba ) ; nmbm_set_block_state ( ni , ba , BLOCK_ST_BAD ) ; next_block : ba -- ; } ; return false ; }
nmbm_write_signature - Write signature to NAND chip
 @ni: NMBM instance structure
 @limit: top block address allowed for writing
 @signature: the signature to be written
 @signature_ba: the actual block address where signature is written to
nmbm_write_signature - Write signature to NAND chip @ni : NMBM instance structure @limit : top block address allowed for writing @signature : the signature to be written @signature_ba : the actual block address where signature is written to
/* Insurance to detect unexpected bad block marked by user */