[PATCH 1/1] MTD mtdchar: add missing initializer on raw write

Ricard Wanderlof ricard.wanderlof at axis.com
Tue Jun 7 05:28:29 EDT 2011


On Mon, 6 Jun 2011, Artem Bityutskiy wrote:

> On Mon, 2011-06-06 at 15:50 +0200, Peter Wippich wrote:
> On writes in MODE_RAW the mtd_oob_ops struct is not sufficiently 
> initialized which may cause nandwrite to fail. With this patch
> it is possible to write raw nand/oob data without additional ECC
> (either for testing or when some sectors need different oob layout
> e.g. bootloader) like
> nandwrite  -n -r -o  /dev/mtd0 <myfile>
> 
> Signed-off-by: Peter Wippich <pewi at gw-instruments.de>

Looks good, thanks. We also need to add this patch to the stable tree.

Ricard, does it solve the issue you reported here

http://lists.infradead.org/pipermail/linux-mtd/2011-March/034516.html

Yes, it does, it seems to work beautifully. The error messages I reported 
in the post are gone, nandwrite reports success, and the resulting data in 
the flash appears to be ok. Thanks Peter for finding the root cause and 
the elegantly trivial patch.

Tested-by: Ricard Wanderlof <ricardw at axis.com>

/Ricard

> 
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 3f92731..797a34a 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -321,6 +321,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
>                          ops.datbuf = kbuf;
>                          ops.oobbuf = NULL;
>                          ops.len = len;
> +                       ops.ooboffs = 0;
>
>                          ret = mtd->write_oob(mtd, *ppos, &ops);
>                          retlen = ops.retlen;
>


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30



More information about the linux-mtd mailing list