[PATCH] [MTD] [NAND]: nand_default_mark_blockbad() doesn't work when flash-based bbt not enabled

Ricard Wanderlof ricard.wanderlof at axis.com
Mon Oct 23 06:46:31 EDT 2006


On Mon, 23 Oct 2006, David Woodhouse wrote:

> On Mon, 2006-10-23 at 09:33 +0200, Ricard Wanderlof wrote:
>> (As note, it seems to be that logically, it shouldn't be necessary to set
>> both length variables, as one appears to be for the main buffer, and
>> one for the oob buffer, but this is how it is done in several places,
>> including the code for the mtd character device MEMWRITEOOB and MEMREADOOB
>> ioctls. I'm not sure if this is a temporary solution during some rework of
>> the mtd infrastructure, or whether there is a deeper thought here.)
>
> Hm. That seems wrong to me. If we don't want to read or write the main
> area, we should set ops.len to zero. And if that doesn't work, it should
> probably be fixed.
>
> I'd rather see a patch which fixes that.

It definitely seems confusing.

There are however several places where both ops->len and ops->ooblen are 
used together in some combination, not only in the mtdchar.c ioctl code. 
For instance, in nand.c:nand_do_read_oob() the variable readlen is 
initialized with ops->len, but in the actual read loop, it is decremented 
with ops->ooblen.

The structure using the ops struct was introduced 2006-05-29 by tglx 
(commit titled 'Rework the out of band handling completely').

Since the code as it stands seems to work (apart from the aformentioned 
markbad issue), I'd rather not dive too deep without more information 
about exactly how the ops->len and ops->ooblen fields are supposed to 
interact.

I'd still like to submit the patch, pending a potential clean up of the 
len/ooblen issue, because without the patch, bad block marking fails (in 
certain cases), whereas it works with the patch, and the way len/ooblen is 
handled seems consistent with other uses.

/Ricard
--
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