/* read_oob_from_regs - read data from OOB registers @ctrl: NAND controller @i: sub-page sector index @oob: buffer to read to @sas: spare area sector size (i.e., OOB size per FLASH_CACHE) @sector_1k: 1 for 1KiB sectors, 0 for 512B, other values are illegal  */
static int read_oob_from_regs(struct brcmnand_controller *ctrl, int i, u8 *oob, int sas, int sector_1k)
/* read_oob_from_regs - read data from OOB registers @ctrl: NAND controller @i: sub-page sector index @oob: buffer to read to @sas: spare area sector size (i.e., OOB size per FLASH_CACHE) @sector_1k: 1 for 1KiB sectors, 0 for 512B, other values are illegal  */
static int read_oob_from_regs(struct brcmnand_controller *ctrl, int i, u8 *oob, int sas, int sector_1k)
{
	int tbytes = sas << sector_1k;
	int j;
	if (sector_1k && (i & 0x01))
		tbytes = max(0, tbytes - (int)ctrl->max_oob);
	tbytes = min_t(int, tbytes, ctrl->max_oob);
	for (j = 0; j < tbytes; j++)
		oob[j] = oob_reg_read(ctrl, j);
	return tbytes;
}