/* Translate the given offset into the appropriate command and offset. This does the mapping using the 16bit interleave layout defined by M-Systems, and looks like this for a sector pair: +-------- */
static unsigned int DoC_GetDataOffset(struct mtd_info *mtd, loff_t *from)
/* Translate the given offset into the appropriate command and offset. This does the mapping using the 16bit interleave layout defined by M-Systems, and looks like this for a sector pair: +-------- */
static unsigned int DoC_GetDataOffset(struct mtd_info *mtd, loff_t *from)
{
	struct DiskOnChip *this = mtd->priv;
	if (this->interleave) {
		unsigned int ofs = *from & 0x3ff;
		unsigned int cmd;
		if (ofs < 512) {
			cmd = NAND_CMD_READ0;
			ofs &= 0x1ff;
		} else if (ofs < 1014) {
			cmd = NAND_CMD_READ1;
			ofs = (ofs & 0x1ff) + 10;
		} else {
			cmd = NAND_CMD_READOOB;
			ofs = ofs - 1014;
		}
		*from = (*from & ~0x3ff) | ofs;
		return cmd;
	} else {
		if ((*from) & 0x100)
			return NAND_CMD_READ1;
		return NAND_CMD_READ0;
	}
}