From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-fx0-f215.google.com ([209.85.220.215]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MUOV6-0002hE-4L for linux-mtd@lists.infradead.org; Fri, 24 Jul 2009 17:24:17 +0000 Received: by fxm11 with SMTP id 11so1618436fxm.18 for ; Fri, 24 Jul 2009 10:24:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20090724.001104.229278926.anemo@mba.ocn.ne.jp> References: <20090723.001338.27942898.anemo@mba.ocn.ne.jp> <20090724.001104.229278926.anemo@mba.ocn.ne.jp> Date: Fri, 24 Jul 2009 21:24:01 +0400 Message-ID: Subject: Re: abuse of nand_correct_data in tmio_nand driver From: Dmitry Eremin-Solenikov To: Atsushi Nemoto , Ian Molton Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: linux-mtd@lists.infradead.org, vimal.newwork@gmail.com List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 2009/7/23 Atsushi Nemoto : > On Thu, 23 Jul 2009 12:34:43 +0530, vimal singh = wrote: >> > OK, but I still feel duplicating nand_ecc code is not so good. =A0How >> > about splitting nand_correct_data into two parts? =A0A pure calculatio= n >> > function and a wrapper for mtd interface. =A0Like this: >> >> But I do not see any thing extra, which you achieve from this >> wrapper... =A0Is 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, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned char *read_ecc, unsigned char *ca= lc_ecc) > { > =A0 =A0 =A0 =A0int r0, r1; > > =A0 =A0 =A0 =A0/* assume ecc.size =3D 512 and ecc.bytes =3D 6 */ > =A0 =A0 =A0 =A0r0 =3D __nand_correct_data(buf, read_ecc, calc_ecc, 256); > =A0 =A0 =A0 =A0if (r0 < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return r0; > =A0 =A0 =A0 =A0r1 =3D __nand_correct_data(buf + 256, read_ecc + 3, calc_e= cc + 3, 256); > =A0 =A0 =A0 =A0if (r1 < 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return r1; > =A0 =A0 =A0 =A0return r0 | r1; > } > > Note that this is not tested at all since I do not have tmio device. This seems to be the thing that was initially ment by Zaurus kernels, so this if Ian doesn't object, Acked-by: Dmitry Eremin-Solenikov --=20 With best wishes Dmitry