/* Wait for the SerialFlash device to be ready to accept new commands.  */
static at25_status_t at25dfx_wait_ready(void)
/* Wait for the SerialFlash device to be ready to accept new commands.  */
static at25_status_t at25dfx_wait_ready(void)
{
	at25_status_t op_stat;
	uint8_t at25_stat;
	uint8_t ready = 0;
	while (!ready) {
		op_stat = at25dfx_read_status(&at25_stat);
		if (op_stat != AT25_SUCCESS) {
			return op_stat;
		}
		if ((at25_stat & AT25_STATUS_RDYBSY) == AT25_STATUS_RDYBSY_READY) {
			ready = 1;
		}
	}
	return AT25_SUCCESS;
}