/* Returns a positive value on success, a negative error code otherwise.  */
static int mtd_ooblayout_count_bytes(struct mtd_info *mtd, int(*iter)(struct mtd_info *, int section, struct mtd_oob_region *oobregion))
/* Returns a positive value on success, a negative error code otherwise.  */
static int mtd_ooblayout_count_bytes(struct mtd_info *mtd, int(*iter)(struct mtd_info *, int section, struct mtd_oob_region *oobregion))
{
	struct mtd_oob_region oobregion;
	int section = 0, ret, nbytes = 0;
	while (1) {
		ret = iter(mtd, section++, &oobregion);
		if (ret) {
			if (ret == -ERANGE)
				ret = nbytes;
			break;
		}
		nbytes += oobregion.length;
	}
	return ret;
}