/* Loop through the sector table starting from the previously found sector. Searches forwards or backwards, dependent on the passed address.  */
static flash_sect_t find_sector(flash_info_t *info, ulong addr)
/* Loop through the sector table starting from the previously found sector. Searches forwards or backwards, dependent on the passed address.  */
static flash_sect_t find_sector(flash_info_t *info, ulong addr)
{
	static flash_sect_t saved_sector = 0;
	flash_sect_t sector = saved_sector;
	while ((info->start[sector] < addr)
			&& (sector < info->sector_count - 1))
		sector++;
	while ((info->start[sector] > addr) && (sector > 0))
		sector--;
	saved_sector = sector;
	return sector;
}