From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Cercueil Subject: Re: [PATCH v4 6/9] mtd: rawnand: ingenic: Separate top-level and SoC specific code Date: Mon, 04 Mar 2019 19:26:08 +0100 Message-ID: <1551723968.4932.4@crapouillou.net> References: <20190209192305.4434-1-paul@crapouillou.net> <20190209192305.4434-6-paul@crapouillou.net> <20190304112058.67cd5194@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20190304112058.67cd5194@xps13> Sender: linux-kernel-owner@vger.kernel.org To: Miquel Raynal Cc: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Harvey Hunt , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: devicetree@vger.kernel.org On Mon, Mar 4, 2019 at 11:20 AM, Miquel Raynal=20 wrote: > Hi Paul, >=20 > Paul Cercueil >=20 > wrote on Sat, 9 Feb 2019 16:23:02 > -0300: >=20 >> The ingenic-nand driver uses an API provided by the jz4780-bch=20 >> driver. >> This makes it difficult to support other SoCs in the jz4780-bch=20 >> driver. >> To work around this, we separate the API functions from the=20 >> SoC-specific >> code, so that these API functions are SoC-agnostic. >>=20 >=20 > I like the idea, actually I am working on this separation (see > [1]) and I would really appreciate that you try to implement the > interface when it will be available (v2 is coming this week, I think=20 > v3 > will be the one to test when raw NAND devices will be properly > supported). I will add you in Cc: if you want to follow/review. >=20 > [1]=20 > Do you think this will be ready for 5.2? You can add me in Cc:. >> Signed-off-by: Paul Cercueil > > >> --- >>=20 >> v2: Add an optional .probe() callback. It is used for instance to=20 >> set >> the clock rate in the JZ4780 backend. >>=20 >> v3: The common code is now inside the ingenic-ecc module. Each >> SoC-specific ECC code is now in its own module, which leaves to=20 >> the >> user the choice of which (if any) ECC code should be supported. >>=20 >> v4: No change >>=20 >> drivers/mtd/nand/raw/ingenic/Kconfig | 17 +++ >> drivers/mtd/nand/raw/ingenic/Makefile | 5 +- >> drivers/mtd/nand/raw/ingenic/ingenic_ecc.c | 157=20 >> +++++++++++++++++++++++++ >> drivers/mtd/nand/raw/ingenic/ingenic_ecc.h | 84 ++++++++++++++ >> drivers/mtd/nand/raw/ingenic/ingenic_nand.c | 38 +++---- >> drivers/mtd/nand/raw/ingenic/jz4780_bch.c | 170=20 >> +++++----------------------- >> drivers/mtd/nand/raw/ingenic/jz4780_bch.h | 40 ------- >> 7 files changed, 308 insertions(+), 203 deletions(-) >> create mode 100644 drivers/mtd/nand/raw/ingenic/ingenic_ecc.c >> create mode 100644 drivers/mtd/nand/raw/ingenic/ingenic_ecc.h >> delete mode 100644 drivers/mtd/nand/raw/ingenic/jz4780_bch.h >>=20 >=20 > [...] >=20 >> diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand.c=20 >> b/drivers/mtd/nand/raw/ingenic/ingenic_nand.c >> index 8c73f7c5be9a..0f51fd15fe79 100644 >> --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand.c >> +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand.c >> @@ -22,7 +22,7 @@ >>=20 >> #include >>=20 >> -#include "jz4780_bch.h" >> +#include "ingenic_ecc.h" >>=20 >> #define DRV_NAME "ingenic-nand" >>=20 >> @@ -40,7 +40,7 @@ struct ingenic_nand_cs { >>=20 >> struct ingenic_nfc { >> struct device *dev; >> - struct jz4780_bch *bch; >> + struct ingenic_ecc *ecc; >> struct nand_controller controller; >> unsigned int num_banks; >> struct list_head chips; >> @@ -124,10 +124,10 @@ static int ingenic_nand_ecc_calculate(struct=20 >> nand_chip *chip, const u8 *dat, >> { >> struct ingenic_nand *nand =3D to_ingenic_nand(nand_to_mtd(chip)); >> struct ingenic_nfc *nfc =3D to_ingenic_nfc(nand->chip.controller); >> - struct jz4780_bch_params params; >> + struct ingenic_ecc_params params; >>=20 >> /* >> - * Don't need to generate the ECC when reading, BCH does it for=20 >> us as >> + * Don't need to generate the ECC when reading, ECC does it for=20 >> us as >=20 > "the ECC engine does it for us" would be more meaningful. OK. >> * part of decoding/correction. >> */ >> if (nand->reading) >> @@ -137,7 +137,7 @@ static int ingenic_nand_ecc_calculate(struct=20 >> nand_chip *chip, const u8 *dat, >> params.bytes =3D nand->chip.ecc.bytes; >> params.strength =3D nand->chip.ecc.strength; >>=20 >> - return jz4780_bch_calculate(nfc->bch, ¶ms, dat, ecc_code); >> + return ingenic_ecc_calculate(nfc->ecc, ¶ms, dat, ecc_code); >> } >>=20 >=20 > Thanks, > Miqu=E8l =