/* Erase the Numonyx flash start at 'addr' for size of 'length' Parameter: addr: offset/start address of the flash length: length of the data to erase Return: SUCCESS on success, otherwise FAIL  */
int spi_nor_erase_numonyx(uint32_t addr, uint32_t length)
/* Erase the Numonyx flash start at 'addr' for size of 'length' Parameter: addr: offset/start address of the flash length: length of the data to erase Return: SUCCESS on success, otherwise FAIL  */
int spi_nor_erase_numonyx(uint32_t addr, uint32_t length)
{
    int retv=SUCCESS;
    if (length > (SZ_CHIP - SZ_SECTOR)) {
        retv = numonyx_erase_chip();
    } else {
        while (length > 0) {
            retv = numonyx_erase_sector(addr);
            if (retv == FAIL) {
                break;
            }
            addr += SZ_SECTOR;
            length -= SZ_SECTOR;
        }
    }
    return retv;
}