[PATCHv2] drivers: mtd: spinand: Add generic spinand frameowrk.
Florian Fainelli
florian at openwrt.org
Thu Jul 4 03:21:59 EDT 2013
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
More information about the linux-mtd
mailing list