abuse of nand_correct_data in tmio_nand driver

Atsushi Nemoto anemo at mba.ocn.ne.jp
Thu Jul 23 11:11:04 EDT 2009

On Thu, 23 Jul 2009 12:34:43 +0530, vimal singh <vimal.newwork at gmail.com> wrote:
> > OK, but I still feel duplicating nand_ecc code is not so good.  How
> > about splitting nand_correct_data into two parts?  A pure calculation
> > function and a wrapper for mtd interface.  Like this:
> But I do not see any thing extra, which you achieve from this
> wrapper...  Is this a prototype, and you want to handle above scenario
> in this wrapper (calling 'nand_correct_data' multiple times based on
> something, probably 'ecc.bytes')?

Yes, if we have __nand_correct_data(buf, read_ecc, calc_ecc, eccsize)
which do job based on its eccsize argument, the ecc.correct function
of the tmio_nand driver can be implemented like this:

int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
		unsigned char *read_ecc, unsigned char *calc_ecc)
	int r0, r1;

	/* assume ecc.size = 512 and ecc.bytes = 6 */
	r0 = __nand_correct_data(buf, read_ecc, calc_ecc, 256);
	if (r0 < 0)
		return r0;
	r1 = __nand_correct_data(buf + 256, read_ecc + 3, calc_ecc + 3, 256);
	if (r1 < 0)
		return r1;
	return r0 | r1;

Note that this is not tested at all since I do not have tmio device.

Of course if Dmitry had another idea, I will not intrude this

Atsushi Nemoto

More information about the linux-mtd mailing list