On Friday 19 February 2010 00:45:37 Sven Van Asbroeck wrote:
> Hello,
> I think I've identified a small bug in YAFFS - and instead of merely
> whingeing about it, I'll offer a patch that fixes it, how about that!
> The problem is related to the 'inband-tags' option. I had to switch this
> on, since the vendor's MTD driver (Freescale) does not allow access to the
> NAND spare area at this point in time. After switching this on, everything
> worked fine until a block had to be erased. That didn't work, and the MTD
> driver complained about unaligned offsets and lengths. It turns out that
> the mtd interface's NAND block erase function calculates the offsets and
> lengths using dev->nDataBytesPerChunk. This will work fine as long as
> 'inband-tags' is not specified, as dev->nDataBytesPerChunk ==
> dev->totalBytesPerChunk in that case. I've corrected this by using
> dev->totalBytesPerChunk for the offset/length calculation. I must have done
> something right, as YAFFS works very well now.
> Hope this is useful,
> Sven
>
> ---
> linux/fs/yaffs2/yaffs_mtdif.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
> diff --git a/linux/fs/yaffs2/yaffs_mtdif.c b/linux/fs/yaffs2/yaffs_mtdif.c
> index aab9a12..be61233 100644
> --- a/linux/fs/yaffs2/yaffs_mtdif.c
> +++ b/linux/fs/yaffs2/yaffs_mtdif.c
> @@ -209,14 +209,14 @@ int nandmtd_EraseBlockInNAND(yaffs_Device *dev, int
> blockNumber) {
> struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
> __u32 addr =
> - ((loff_t) blockNumber) * dev->nDataBytesPerChunk
> + ((loff_t) blockNumber) * dev->totalBytesPerChunk
> * dev->nChunksPerBlock;
> struct erase_info ei;
> int retval = 0;
> ei.mtd = mtd;
> ei.addr = addr;
> - ei.len = dev->nDataBytesPerChunk * dev->nChunksPerBlock;
> + ei.len = dev->totalBytesPerChunk * dev->nChunksPerBlock;
> ei.time = 1000;
> ei.retries = 2;
> ei.callback = NULL;
> --
> 1.6.3.3
Hello Sven
I confirm that was a bug. I should run inband tags through my test harnesses
more often...
I have corrected cvs.
I have also cleared out some obsolete mtdif code.
Thanks
-- Charles