-#ifndef CONFIG_YAFFS_USE_OLD_MTD
- if(data && tags)
- {
- if(dev->useNANDECC)
- retval = mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,(__u8 *)&pt,NULL);
- else
- retval = mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,(__u8 *)&pt,NULL);
- }
- else
- {
-#endif
- if(data)
- retval = mtd->write(mtd,addr,dev->nBytesPerChunk,&dummy,data);
- if(tags)
- retval = mtd->write_oob(mtd,addr,mtd->oobsize,&dummy,(__u8 *)&pt);
-
-#ifndef CONFIG_YAFFS_USE_OLD_MTD
+ T(YAFFS_TRACE_MTD,
+ (TSTR
+ ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p"
+ TENDSTR), chunkInNAND, data, tags));
+
+
+ addr = ((loff_t) chunkInNAND) * dev->param.totalBytesPerChunk;
+
+ /* For yaffs2 writing there must be both data and tags.
+ * If we're using inband tags, then the tags are stuffed into
+ * the end of the data buffer.
+ */
+ if (!data || !tags)
+ BUG();
+ else if (dev->param.inbandTags) {
+ yaffs_PackedTags2TagsPart *pt2tp;
+ pt2tp = (yaffs_PackedTags2TagsPart *)(data + dev->nDataBytesPerChunk);
+ yaffs_PackTags2TagsPart(pt2tp, tags);
+ } else
+ yaffs_PackTags2(&pt, tags, !dev->param.noTagsECC);
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
+ ops.mode = MTD_OOB_AUTO;
+ ops.ooblen = (dev->param.inbandTags) ? 0 : packed_tags_size;
+ ops.len = dev->param.totalBytesPerChunk;
+ ops.ooboffs = 0;
+ ops.datbuf = (__u8 *)data;
+ ops.oobbuf = (dev->param.inbandTags) ? NULL : packed_tags_ptr;
+ retval = mtd->write_oob(mtd, addr, &ops);
+
+#else
+ if (!dev->param.inbandTags) {
+ retval =
+ mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
+ &dummy, data, (__u8 *) packed_tags_ptr, NULL);
+ } else {
+ retval =
+ mtd->write(mtd, addr, dev->param.totalBytesPerChunk, &dummy,
+ data);