projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rationalise context and parameter handling
[yaffs2.git]
/
yaffs_mtdif.c
diff --git
a/yaffs_mtdif.c
b/yaffs_mtdif.c
index 582563abdf0b73445964126b0f7cbc17d0312f91..25d92ed6347bf36007767b5d2f3dfe9943eb5af2 100644
(file)
--- a/
yaffs_mtdif.c
+++ b/
yaffs_mtdif.c
@@
-9,11
+9,10
@@
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
- *
*/
const char *yaffs_mtdif_c_version =
*/
const char *yaffs_mtdif_c_version =
-
"$Id: yaffs_mtdif.c,v 1.18 2007-02-12 16:55:26 wookey
Exp $";
+
"$Id: yaffs_mtdif.c,v 1.23 2010-02-18 01:18:04 charles
Exp $";
#include "yportenv.h"
#include "yportenv.h"
@@
-25,7
+24,9
@@
const char *yaffs_mtdif_c_version =
#include "linux/time.h"
#include "linux/mtd/nand.h"
#include "linux/time.h"
#include "linux/mtd/nand.h"
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
+#include "yaffs_linux.h"
+
+#if (MTD_VERSION_CODE < MTD_VERSION(2, 6, 18))
static struct nand_oobinfo yaffs_oobinfo = {
.useecc = 1,
.eccbytes = 6,
static struct nand_oobinfo yaffs_oobinfo = {
.useecc = 1,
.eccbytes = 6,
@@
-37,7
+38,7
@@
static struct nand_oobinfo yaffs_noeccinfo = {
};
#endif
};
#endif
-#if (
LINUX_VERSION_CODE > KERNEL_VERSION(2,6,
17))
+#if (
MTD_VERSION_CODE > MTD_VERSION(2, 6,
17))
static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
{
oob[0] = spare->tagByte0;
static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
{
oob[0] = spare->tagByte0;
@@
-46,8
+47,8
@@
static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
oob[3] = spare->tagByte3;
oob[4] = spare->tagByte4;
oob[5] = spare->tagByte5 & 0x3f;
oob[3] = spare->tagByte3;
oob[4] = spare->tagByte4;
oob[5] = spare->tagByte5 & 0x3f;
- oob[5] |= spare->blockStatus == 'Y' ? 0: 0x80;
- oob[5] |= spare->pageStatus == 0 ? 0: 0x40;
+ oob[5] |= spare->blockStatus == 'Y' ? 0
: 0x80;
+ oob[5] |= spare->pageStatus == 0 ? 0
: 0x40;
oob[6] = spare->tagByte6;
oob[7] = spare->tagByte7;
}
oob[6] = spare->tagByte6;
oob[7] = spare->tagByte7;
}
@@
-72,25
+73,25
@@
static inline void translate_oob2spare(yaffs_Spare *spare, __u8 *oob)
}
#endif
}
#endif
-int nandmtd_WriteChunkToNAND(yaffs_Device *
dev, int chunkInNAND,
- const __u8 *
data, const yaffs_Spare *
spare)
+int nandmtd_WriteChunkToNAND(yaffs_Device *dev, int chunkInNAND,
+ const __u8 *
data, const yaffs_Spare *
spare)
{
{
- struct mtd_info *mtd =
(struct mtd_info *)(dev->genericDevice)
;
-#if (
LINUX_VERSION_CODE > KERNEL_VERSION(2,6,
17))
+ struct mtd_info *mtd =
yaffs_DeviceToContext(dev)->mtd
;
+#if (
MTD_VERSION_CODE > MTD_VERSION(2, 6,
17))
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (
LINUX_VERSION_CODE > KERNEL_VERSION(2,6,
17))
+#if (
MTD_VERSION_CODE > MTD_VERSION(2, 6,
17))
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
retval = mtd->write(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data);
else if (spare) {
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
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 */
translate_spare2oob(spare, spareAsBytes);
ops.mode = MTD_OOB_AUTO;
ops.ooblen = 8; /* temp hack */
@@
-108,7
+109,7
@@
int nandmtd_WriteChunkToNAND(yaffs_Device * dev, int chunkInNAND,
__u8 *spareAsBytes = (__u8 *) spare;
if (data && spare) {
__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,
retval =
mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data, spareAsBytes,
@@
-136,25
+137,25
@@
int nandmtd_WriteChunkToNAND(yaffs_Device * dev, int chunkInNAND,
return YAFFS_FAIL;
}
return YAFFS_FAIL;
}
-int nandmtd_ReadChunkFromNAND(yaffs_Device *
dev, int chunkInNAND, __u8 *
data,
- yaffs_Spare *
spare)
+int nandmtd_ReadChunkFromNAND(yaffs_Device *
dev, int chunkInNAND, __u8 *
data,
+ yaffs_Spare *spare)
{
{
- struct mtd_info *mtd =
(struct mtd_info *)(dev->genericDevice)
;
-#if (
LINUX_VERSION_CODE > KERNEL_VERSION(2,6,
17))
+ struct mtd_info *mtd =
yaffs_DeviceToContext(dev)->mtd
;
+#if (
MTD_VERSION_CODE > MTD_VERSION(2, 6,
17))
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (
LINUX_VERSION_CODE > KERNEL_VERSION(2,6,
17))
+#if (
MTD_VERSION_CODE > MTD_VERSION(2, 6,
17))
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data);
else if (spare) {
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
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.mode = MTD_OOB_AUTO;
ops.ooblen = 8; /* temp hack */
} else {
@@
-166,14
+167,14
@@
int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
ops.ooboffs = 0;
ops.oobbuf = spareAsBytes;
retval = mtd->read_oob(mtd, addr, &ops);
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) {
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, */
/* Careful, this call adds 2 ints */
/* to the end of the spare data. Calling function */
/* should allocate enough memory for spare, */
@@
-206,27
+207,24
@@
int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
return YAFFS_FAIL;
}
return YAFFS_FAIL;
}
-int nandmtd_EraseBlockInNAND(yaffs_Device *
dev, int blockNumber)
+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
__u32 addr =
((loff_t) blockNumber) * dev->nDataBytesPerChunk
- * dev->nChunksPerBlock;
+ * dev->
param.
nChunksPerBlock;
struct erase_info ei;
struct erase_info ei;
+
int retval = 0;
ei.mtd = mtd;
ei.addr = addr;
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;
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)
retval = mtd->erase(mtd, &ei);
if (retval == 0)
@@
-235,7
+233,7
@@
int nandmtd_EraseBlockInNAND(yaffs_Device * dev, int blockNumber)
return YAFFS_FAIL;
}
return YAFFS_FAIL;
}
-int nandmtd_InitialiseNAND(yaffs_Device *
dev)
+int nandmtd_InitialiseNAND(yaffs_Device *dev)
{
return YAFFS_OK;
}
{
return YAFFS_OK;
}