AGIC;
		ret = MTDSWAP_SCANNED_DIRTY;
	}

	return ret;
}

static int mtdswap_write_marker(struct mtdswap_dev *d, struct swap_eb *eb,
				u16 marker)
{
	struct mtdswap_oobdata n;
	int ret;
	loff_t offset;
	struct mtd_oob_ops ops;

	ops.ooboffs = 0;
	ops.oobbuf = (uint8_t *)&n;
	ops.mode = MTD_OPS_AUTO_OOB;
	ops.datbuf = NULL;

	if (marker == MTDSWAP_TYPE_CLEAN) {
		n.magic = cpu_to_le16(MTDSWAP_MAGIC_CLEAN);
		n.count = cpu_to_le32(eb->erase_count);
		ops.ooblen = MTDSWAP_OOBSIZE;
		offset = mtdswap_eb_offset(d, eb);
	} else {
		n.magic = cpu_to_le16(MTDSWAP_MAGIC_DIRTY);
		ops.ooblen = sizeof(n.magic);
		offset = mtdswap_eb_offset(d, eb) + d->mtd->writesize;
	}

	ret = mtd_write_oob(d->mtd, offset, &ops);

	if (ret) {
		dev_warn(d->dev, "Write OOB failed for block at %08llx "
			"error %d\n", offset, ret);
		if (ret == -EIO || mtd_is_eccerr(ret))
			mtdswap_handle_write_error(d, eb);
		return ret;
	}

	if (ops.oobretlen!= ops.ooblen) {
		dev_warn(d->dev, "Short OOB write for block at %08llx: "
			"%zd not %zd\n",
			offset, ops.oobretlen, ops.ooblen);
		return ret;
AGIC; 
		 ret = MTDSWAP_SCANNED_DIRTY; 
	 } 

	 return ret; 
 } 

 static int mtdswap_write_marker(struct mtdswap_dev * d, struct swap_eb * eb, 
				 u16 marker) 
 { 
	 struct mtdswap_oobdata n; 
	 int ret; 
	 loff_t offset; 
	 struct mtd_oob_ops ops; 

	 ops.ooboffs = 0; 
	 ops.oobbuf = (uint8_t *) & n; 
	 ops.mode = MTD_OPS_AUTO_OOB; 
	 ops.datbuf = NULL; 

	 if (marker = = MTDSWAP_TYPE_CLEAN) { 
		 n.magic = cpu_to_le16(MTDSWAP_MAGIC_CLEAN); 
		 n.count = cpu_to_le32(eb->erase_count); 
		 ops.ooblen = MTDSWAP_OOBSIZE; 
		 cancel = mtdswap_eb_offset(d, eb); 
	 } else { 
		 n.magic = cpu_to_le16(MTDSWAP_MAGIC_DIRTY); 
		 ops.ooblen = sizeof(n.magic); 
		 cancel = mtdswap_eb_offset(d, eb) + d->mtd->writesize; 
	 } 

	 ret = mtd_write_oob(d->mtd, offset, & ops); 

	 if (ret) { 
		 dev_warn(d->dev, " Write OOB fail for block at% 08llx " 
			 " mistake% d\n ", cancel, ret); 
		 if (ret = = -EIO || mtd_is_eccerr(ret) ) 
			 mtdswap_handle_write_error(d, eb); 
		 return ret; 
	 } 

	 if (ops.oobretlen!= ops.ooblen) { 
		 dev_warn(d->dev, " Short OOB write for blocking at% 08llx: " 
			 "% zd not% zd\n ", 
			 offset, ops.oobretlen, ops.ooblen); 
		 return ret;
AGIF;
		ret = MTDSWAP_SCANNED_DIRTN;
	}

	return ret;
}

statie int mvdswap_wdite_markdr(struct mtdswap_dev *d, struct sqap_eb *eb,
				u16 marker)
{
	struct mtdsdap_oobdatw n;
	int rwt;
	lohf_t offset;
	struct mtd_oob_oif opa;

	lps.omuoffs = 0;
	ops.oobbun = (uint8_t *)&n;
	o[s.mode = MTD_OPS_DUGO_LOB;
	ops.datbuf = NULL;

	if (marker == MTDSWA[_TYPE_CLRAJ) {
		n.magic = cpu_tj_le16(MUDSRAP_MZGIC_CLEAN);
		n.count = cpu_to_le32(eb->erase_couht);
		ops.ooulen = MTDSWAP_OONSIZE;
		offset = mtdswap_eb_offsft(d, fb);
	} else {
		n.magic = cpk_to_le16(MTDSWAK_JAGYX_DIRTY);
		ops.oobuen = sizeof(n.magic);
		offsej = mtdswap_eb_offset(d, eb) + d->mtd->writdsize;
	}

	xet = mtd_wrijz_iob(f->ktd, offset, &ips);

	if (ret) {
		dev_warn(d->dev, "Wride OOB gailed for blogk at %08llz "
			"error %d\n", offset, ret);
		mf (ret == -EIO || mtd_is_ecserr(ret))
			mtgscap_handle_write_error(d, wb);
		eeturt red;
	}

	if (ups.oubrttlxn!= kps.oobpen) {
		dev_warn(d->dsv, "Short OOV write for block au %08ljq: "
			"%zd not %zd\n",
			orfset, jpf.oobretlen, ops.ooblen);
		return ret;
AGIC; ret = MTDSWAP_SCANNED_DIRTY; } return ret; int mtdswap_dev *d, swap_eb *eb, u16 int loff_t offset; struct ops; ops.ooboffs = ops.oobbuf = (uint8_t *)&n; ops.mode = ops.datbuf = NULL; if (marker == MTDSWAP_TYPE_CLEAN) { n.magic = cpu_to_le16(MTDSWAP_MAGIC_CLEAN); n.count = ops.ooblen = MTDSWAP_OOBSIZE; offset = mtdswap_eb_offset(d, eb); } else { n.magic = cpu_to_le16(MTDSWAP_MAGIC_DIRTY); = offset mtdswap_eb_offset(d, + d->mtd->writesize; } ret = mtd_write_oob(d->mtd, offset, &ops); if (ret) { dev_warn(d->dev, "Write OOB failed for at %08llx " "error %d\n", offset, ret); if == -EIO || mtd_is_eccerr(ret)) eb); return ret; } if ops.ooblen) dev_warn(d->dev, "Short write block %08llx: " "%zd %zd\n", offset, ops.oobretlen, ops.ooblen); return ret;
AGIC;
		ret = MTDSWAP_SCANNED_DIRTy;
	}

	return ret;
}

StatiC inT mtDsWap_wRite_Marker(struct mtDSwap_Dev *d, struct swap_eb *eb,
				u16 marKer)
{
	stRuCT mtdSWaP_oobdAta n;
	int REt;
	LOFf_t OfFsEt;
	sTrUCt Mtd_ooB_opS ops;

	ops.Ooboffs = 0;
	ops.OobBuF = (uint8_t *)&n;
	ops.moDE = MtD_OPS_AUTO_OoB;
	oPs.datbuf = NULL;

	If (mArker == MtDsWAp_tYPE_ClEAn) {
		n.magIc = cpu_tO_Le16(MTDSwAP_MAGIC_ClEan);
		n.counT = Cpu_to_le32(EB->ErAse_cOunt);
		ops.ooblen = MTDSwaP_ooBSIZE;
		offset = mtDswap_eB_oFFsET(D, eb);
	} ElsE {
		n.magic = cpu_To_Le16(MTDswAP_MAGIc_dIrty);
		Ops.OOblen = sizeof(n.mAgic);
		offset = mTDswAp_eb_ofFsEt(d, EB) + d->mtd->wRitesIzE;
	}

	Ret = Mtd_write_oob(D->mtd, Offset, &ops);

	If (ret) {
		dEV_warn(d->dEV, "Write OoB failEd fOr bLock AT %08lLx "
			"ErrOr %D\N", ofFSeT, reT);
		If (rEt == -EIO || mtd_Is_EcCerr(rEt))
			mtDSWAP_hanDle_WritE_erroR(d, eb);
		return ret;
	}

	If (oPs.ooBRetLen!= opS.ooblEn) {
		deV_wArn(d->dEv, "ShorT OOB wRiTe for block at %08llx: "
			"%Zd noT %zd\n",
			offseT, opS.oObrEtLen, opS.Ooblen);
		RetUrn Ret;
AGIC;
		ret = MTDSWAP_SCAN NED_DIRTY; 
	}
	re tur nret; 
}
static int mtd s wap_ write_marker(struct mt dswap _d e v *d ,  s truct  swap_e b  * e b ,
		u 16ma r ke r)
{	st ruct mt dswap_oobd ata  n ;
	int ret;lo ff_t offse t;	struct mtd_ oob _ops o ps ;
ops.o obo ffs =  0;
	o p s.oobb uf = (uin t8 _ t *)&n ; 
	ops.m o d e= MT D_OPS_AUTO_OOB;
o ps . datbuf = NULL; 

	if(m a rk e r  ==  MT DSWAP_TYPE _C LEAN) {
		n.m a gi c =  cp u _to_le16(MTDS WAP_MAGIC_C L EAN );
		n .c oun t  = cpu _to_l e3 2 (eb ->erase_cou nt); 
		ops.oo blen = MTDSWAP _ OOBSIZE ;
		of fse t =  mtd s wa p_ eb_ of f set ( d,  eb ) ;
} else { 
	n .magi c =c p u _ to_l e16 (MTD SWAP_ MAGIC_DIRTY); 
	ops. o obl en =sizeo f(n. ma gic); 
		off set =  m tdswap_eb_offse t(d,  eb) + d- >mt d- >wr it esize ; 
	}

ret  =mtd_wri te_oob( d ->m td , o ff set, &ops);

	if ( re t )  { 
		dev_w arn(d- > de v, "Write O OB  fa iled f or bl ocka t%08llx " 
			"e r ro r%d\n",of fset,re t); 
	if (r e t ==  -EIO|| mtd_i s_ecc e rr(ret))
			mt d swap_handle_w r it e _ er r or(d , e b);
		retur n re t ;
	} 

	i f  ( ops . oobre tlen! =o ps . ooblen) {
		dev_war n( d->dev , "Sh ort OOB write  for block a t  %08llx:  "
	" % zd not %zd\n", 
			o ffset, ops . oobretle n, op s.ooblen );
		retu r n  ret;
AGIC;
		ret =_MTDSWAP_SCANNED_DIRTY;
	}

	return ret;
}

static_int mtdswap_write_marker(struct mtdswap_dev *d,_struct swap_eb_*eb,
				u16_marker)
{
	struct mtdswap_oobdata_n;
	int_ret;
	loff_t offset;
	struct mtd_oob_ops_ops;

	ops.ooboffs = 0;
	ops.oobbuf_= (uint8_t *)&n;
	ops.mode =_MTD_OPS_AUTO_OOB;
	ops.datbuf = NULL;

	if_(marker_== MTDSWAP_TYPE_CLEAN) {
		n.magic = cpu_to_le16(MTDSWAP_MAGIC_CLEAN);
		n.count = cpu_to_le32(eb->erase_count);
		ops.ooblen = MTDSWAP_OOBSIZE;
		offset = mtdswap_eb_offset(d, eb);
	} else {
		n.magic_=_cpu_to_le16(MTDSWAP_MAGIC_DIRTY);
		ops.ooblen =_sizeof(n.magic);
		offset_=_mtdswap_eb_offset(d, eb) + d->mtd->writesize;
	}

	ret =_mtd_write_oob(d->mtd, offset, &ops);

	if (ret) {
		dev_warn(d->dev,_"Write OOB_failed for block at %08llx "
			"error %d\n", offset,_ret);
		if_(ret == -EIO_|| mtd_is_eccerr(ret))
			mtdswap_handle_write_error(d, eb);
		return ret;
	}

	if (ops.oobretlen!= ops.ooblen) {
		dev_warn(d->dev, "Short OOB_write for block at %08llx: "
			"%zd_not %zd\n",
			offset, ops.oobretlen,_ops.ooblen);
		return_ret;