/* This function returns the address of the last valid sector.  */
Ctrl_status nand_flash_read_capacity(uint32_t *nb_sector)
/* This function returns the address of the last valid sector.  */
Ctrl_status nand_flash_read_capacity(uint32_t *nb_sector)
{
	if (nand_flash_status == NAND_FLASH_UNLOADED) {
		return CTRL_NO_PRESENT;
	}
	if (nand_flash_status == NAND_FLASH_NOT_INIT) {
		if (nand_flash_translation_initialize(&nf_translation, 0,
				cmd_address, addr_address, data_address, 0,
				0, page_write_buffer, page_read_buffer)) {
			return CTRL_NO_PRESENT;
		}
		nand_flash_status = NAND_FLASH_READY;
	}
	if (nand_flash_status == NAND_FLASH_READY) {
		*nb_sector
			= nand_flash_translation_get_device_size_in_byte(
				&nf_translation) / SECTOR_SIZE;
		return CTRL_GOOD;
	}
	return CTRL_BUSY;
}