/* Loop until the Write State machine is ready, then do a full error check. Clear status and leave the flash in Read Array mode; return 0 for no error, -1 for error.  */
static int flash_status_full_check(unsigned long addr, unsigned short value1, unsigned short value2)
/* Loop until the Write State machine is ready, then do a full error check. Clear status and leave the flash in Read Array mode; return 0 for no error, -1 for error.  */
static int flash_status_full_check(unsigned long addr, unsigned short value1, unsigned short value2)
{
	unsigned short status1, status2;
	status1 = flash_status_wait (addr, value1);
	status2 = flash_status_wait (addr + 2, value2);
	return (status1 != value1 || status2 != value2) ? -1 : 0;
}