/* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area.  */
static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address, int len, int check_oob)
/* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area.  */
static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address, int len, int check_oob)
{
	u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];
	struct mtd_info *mtd = inftl->mbd.mtd;
	size_t retlen;
	int i;
	for (i = 0; i < len; i += SECTORSIZE) {
		if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf))
			return -1;
		if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
			return -1;
		if (check_oob) {
			if(inftl_read_oob(mtd, address, mtd->oobsize,
					  &retlen, &buf[SECTORSIZE]) < 0)
				return -1;
			if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
				return -1;
		}
		address += SECTORSIZE;
	}
	return 0;
}