*/
const char *yaffs_mtdif_c_version =
- "$Id: yaffs_mtdif.c,v 1.22 2009-03-06 17:20:51 wookey Exp $";
+ "$Id: yaffs_mtdif.c,v 1.23 2010-02-18 01:18:04 charles Exp $";
#include "yportenv.h"
#include "linux/time.h"
#include "linux/mtd/nand.h"
+#include "yaffs_linux.h"
+
#if (MTD_VERSION_CODE < MTD_VERSION(2, 6, 18))
static struct nand_oobinfo yaffs_oobinfo = {
.useecc = 1,
int nandmtd_WriteChunkToNAND(yaffs_Device *dev, int chunkInNAND,
const __u8 *data, const yaffs_Spare *spare)
{
- struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
+ struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd;
#if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17))
struct mtd_oob_ops ops;
#endif
retval = mtd->write(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data);
else if (spare) {
- if (dev->useNANDECC) {
+ if (dev->param.useNANDECC) {
translate_spare2oob(spare, spareAsBytes);
ops.mode = MTD_OOB_AUTO;
ops.ooblen = 8; /* temp hack */
__u8 *spareAsBytes = (__u8 *) spare;
if (data && spare) {
- if (dev->useNANDECC)
+ if (dev->param.useNANDECC)
retval =
mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data, spareAsBytes,
int nandmtd_ReadChunkFromNAND(yaffs_Device *dev, int chunkInNAND, __u8 *data,
yaffs_Spare *spare)
{
- struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
+ struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd;
#if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17))
struct mtd_oob_ops ops;
#endif
retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data);
else if (spare) {
- if (dev->useNANDECC) {
+ if (dev->param.useNANDECC) {
ops.mode = MTD_OOB_AUTO;
ops.ooblen = 8; /* temp hack */
} else {
ops.ooboffs = 0;
ops.oobbuf = spareAsBytes;
retval = mtd->read_oob(mtd, addr, &ops);
- if (dev->useNANDECC)
+ if (dev->param.useNANDECC)
translate_oob2spare(spare, spareAsBytes);
}
#else
__u8 *spareAsBytes = (__u8 *) spare;
if (data && spare) {
- if (dev->useNANDECC) {
+ if (dev->param.useNANDECC) {
/* Careful, this call adds 2 ints */
/* to the end of the spare data. Calling function */
/* should allocate enough memory for spare, */
int nandmtd_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
{
- struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
+ struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd;
__u32 addr =
((loff_t) blockNumber) * dev->nDataBytesPerChunk
- * dev->nChunksPerBlock;
+ * dev->param.nChunksPerBlock;
struct erase_info ei;
+
int retval = 0;
ei.mtd = mtd;
ei.addr = addr;
- ei.len = dev->nDataBytesPerChunk * dev->nChunksPerBlock;
+ ei.len = dev->nDataBytesPerChunk * dev->param.nChunksPerBlock;
ei.time = 1000;
ei.retries = 2;
ei.callback = NULL;
ei.priv = (u_long) dev;
- /* Todo finish off the ei if required */
-
- sema_init(&dev->sem, 0);
-
retval = mtd->erase(mtd, &ei);
if (retval == 0)