Re: [PATCHv2] drivers: mtd: spinand: Add generic spinand frameowrk.

From: Florian Fainelli
Date: Thu Jul 04 2013 - 03:23:10 EST


Hello,

Le jeudi 4 juillet 2013 10:13:43 Sourav Poddar a écrit :
> >
> > Can this somehow be made a runtime thing?
>
> Ahh..I think we might opt for a device tree entry and based on that
> check for ECC.

Ok, sounds good too.

>
> > [snip]
> >
> >> + if (count< oob_num&& ops->oobbuf&& chip->oobbuf) {
> >> + int size;
> >> + int offset, len, temp;
> >> +
> >> + /* repack spare to oob */
> >> + memset(chip->oobbuf, 0,
> >> info->ecclayout->oobavail);
> >> +
> >> + temp = 0;
> >> + offset = info->ecclayout->oobfree[0].offset;
> >> + len = info->ecclayout->oobfree[0].length;
> >> + memcpy(chip->oobbuf + temp,
> >> + chip->buf + info->page_main_size +
> >> offset, len);>
> > Sounds like a for look might be useful here
>
> I dont think so, there is a while loop above under which it happens.
> We are increasing count at the bottom of the while loop. So, I think
> this should work fine.

What I meant here, is that you could use a for loop to repeat 4 times the same
following pattern, such that it becomes:

for (j = 0; j < 4; j++0 {
temp += len;
offset = info->ecclayout->oobfree[j].offset;
len = info->ecclayout->oobfree[j].length;
memcpy(chip->oobbuf + temp,
chip->buf + info->page_main_size + offset, len);
}

Or even make it a helper function which is inlined if that is deemed more
elegant.
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/