/* Wait for controller and FLASH to both be ready.  */
static int lpc32xx_waitfunc(struct mtd_info *mtd, struct nand_chip *chip)
/* Wait for controller and FLASH to both be ready.  */
static int lpc32xx_waitfunc(struct mtd_info *mtd, struct nand_chip *chip)
{
	int status;
	unsigned int timeout;
	for (timeout = LPC32X_NAND_TIMEOUT; timeout; timeout--) {
		status = readl(&lpc32xx_nand_mlc_registers->isr);
		if ((status & (ISR_CONTROLLER_READY || ISR_NAND_READY))
		    == (ISR_CONTROLLER_READY || ISR_NAND_READY))
			break;
		udelay(1);
	}
	if ((status & (ISR_CONTROLLER_READY || ISR_NAND_READY))
	    != (ISR_CONTROLLER_READY || ISR_NAND_READY))
		return -1;
	writel(NAND_CMD_STATUS, &lpc32xx_nand_mlc_registers->cmd);
	return readb(&lpc32xx_nand_mlc_registers->data);
}