From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Priit Laes <plaes@plaes.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org, Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Kukjin Kim <kgene@kernel.org>,
Krzysztof Kozlowski <k.kozlowski@samsung.com>,
linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org, Josh Wu <josh.wu@atmel.com>,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-sunxi@googlegroups.com, Stefan Agner <stefan@agner.ch>,
Kyungmin Park <kyungmin.park@samsung.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
punnaiah choudary kalluri <punnaia@xilinx.com>
Subject: Re: [linux-sunxi] [PATCH 01/23] mtd: kill the ecclayout->oobavail field
Date: Tue, 8 Dec 2015 09:14:51 +0100 [thread overview]
Message-ID: <20151208091451.4eef0b50@bbrezillon> (raw)
In-Reply-To: <1449556985.25438.8.camel@plaes.org>
Hi Priit,
On Tue, 08 Dec 2015 08:43:05 +0200
Priit Laes <plaes@plaes.org> wrote:
> On Mon, 2015-12-07 at 23:25 +0100, Boris Brezillon wrote:
> > ecclayout->oobavail is just redundant with the mtd->oobavail field.
> > Moreover, it prevents static const definition of ecc layouts since
> > the
> > NAND framework is calculating this value based on the ecclayout-
> > >oobfree
> > field.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > drivers/mtd/devices/docg3.c | 5 ++-
> > drivers/mtd/mtdswap.c | 16 ++++-----
> > drivers/mtd/nand/brcmnand/brcmnand.c | 3 --
> > drivers/mtd/nand/docg4.c | 1 -
> > drivers/mtd/nand/hisi504_nand.c | 1 -
> > drivers/mtd/nand/nand_base.c | 12 +++----
> > drivers/mtd/onenand/onenand_base.c | 16 ++++-----
> > drivers/mtd/tests/oobtest.c | 49 +++++++++++++--
> > ------------
> > drivers/staging/mt29f_spinand/mt29f_spinand.c | 1 -
> > fs/jffs2/wbuf.c | 6 ++--
> > include/linux/mtd/mtd.h | 1 -
> > 11 files changed, 48 insertions(+), 63 deletions(-)
> >
> [..]
> >
> > diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c
> > b/drivers/mtd/nand/brcmnand/brcmnand.c
> > index 35d78f7..a906ec2 100644
> > --- a/drivers/mtd/nand/brcmnand/brcmnand.c
> > +++ b/drivers/mtd/nand/brcmnand/brcmnand.c
> > @@ -845,9 +845,6 @@ static struct nand_ecclayout *brcmnand_create_layout(int ecc_level,
> > break;
> > }
> > out:
> > - /* Sum available OOB */
> > - for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE; i++)
> > - layout->oobavail += layout->oobfree[i].length;
> > return layout;
> > }
>
> You can get rid of the 'out' label and replace the single goto in this
> function with 'return layout'.
Yep, I'll fix that.
>
> [...]
> >
> > diff --git a/drivers/mtd/nand/nand_base.c
> > b/drivers/mtd/nand/nand_base.c
> > index 0748a13..1107f5c1 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -2037,7 +2037,7 @@ static int nand_do_read_oob(struct mtd_info
> > *mtd, loff_t from,
> > stats = mtd->ecc_stats;
> >
> > if (ops->mode == MTD_OPS_AUTO_OOB)
> > - len = chip->ecc.layout->oobavail;
> > + len = mtd->oobavail;
> > else
> > len = mtd->oobsize;
> >
> > @@ -2728,7 +2728,7 @@ static int nand_do_write_oob(struct mtd_info
> > *mtd, loff_t to,
> > __func__, (unsigned int)to, (int)ops-
> > >ooblen);
> >
> > if (ops->mode == MTD_OPS_AUTO_OOB)
> > - len = chip->ecc.layout->oobavail;
> > + len = mtd->oobavail;
> > else
> > len = mtd->oobsize;
> >
> [...]
> > diff --git a/drivers/mtd/onenand/onenand_base.c
> > b/drivers/mtd/onenand/onenand_base.c
> > index 43b3392..d70bbfd 100644
> > --- a/drivers/mtd/onenand/onenand_base.c
> > +++ b/drivers/mtd/onenand/onenand_base.c
> > @@ -1125,7 +1125,7 @@ static int onenand_mlc_read_ops_nolock(struct
> > mtd_info *mtd, loff_t from,
> > (int)len);
> >
> > if (ops->mode == MTD_OPS_AUTO_OOB)
> > - oobsize = this->ecclayout->oobavail;
> > + oobsize = mtd->oobavail;
> > else
> > oobsize = mtd->oobsize;
> >
> > @@ -1230,7 +1230,7 @@ static int onenand_read_ops_nolock(struct
> > mtd_info *mtd, loff_t from,
> > (int)len);
> >
> > if (ops->mode == MTD_OPS_AUTO_OOB)
> > - oobsize = this->ecclayout->oobavail;
> > + oobsize = mtd->oobavail;
> > else
> > oobsize = mtd->oobsize;
> >
> > @@ -1365,7 +1365,7 @@ static int onenand_read_oob_nolock(struct
> > mtd_info *mtd, loff_t from,
> > ops->oobretlen = 0;
> >
> > if (mode == MTD_OPS_AUTO_OOB)
> > - oobsize = this->ecclayout->oobavail;
> > + oobsize = mtd->oobavail;
> > else
> > oobsize = mtd->oobsize;
> >
> > @@ -1887,7 +1887,7 @@ static int onenand_write_ops_nolock(struct
> > mtd_info *mtd, loff_t to,
> > return 0;
> >
> > if (ops->mode == MTD_OPS_AUTO_OOB)
> > - oobsize = this->ecclayout->oobavail;
> > + oobsize = mtd->oobavail;
> > else
> > oobsize = mtd->oobsize;
> >
> > @@ -2063,7 +2063,7 @@ static int onenand_write_oob_nolock(struct
> > mtd_info *mtd, loff_t to,
> > ops->oobretlen = 0;
> >
> > if (mode == MTD_OPS_AUTO_OOB)
> > - oobsize = this->ecclayout->oobavail;
> > + oobsize = mtd->oobavail;
> > else
> > oobsize = mtd->oobsize;
>
> This identical construction seems to occur multiple times in multiple
> files. Would it make sense to create a macro for it?
Right, I'll make another patch move this logic into an inline function.
Thanks for the review.
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-12-08 8:15 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 22:25 [PATCH 00/23] mtd: rework ECC layout definition Boris Brezillon
2015-12-07 22:25 ` [PATCH 01/23] mtd: kill the ecclayout->oobavail field Boris Brezillon
2015-12-08 6:43 ` [linux-sunxi] " Priit Laes
2015-12-08 8:14 ` Boris Brezillon [this message]
2015-12-07 22:25 ` [PATCH 02/23] mtd: inftl: kill unused oobinfo field Boris Brezillon
2015-12-07 22:25 ` [PATCH 03/23] mtd: nftl: " Boris Brezillon
2015-12-07 22:25 ` [PATCH 04/23] mtd: nand: s3c2410: kill the ->ecc_layout field Boris Brezillon
2015-12-08 0:38 ` Krzysztof Kozlowski
2015-12-07 22:26 ` [PATCH 05/23] mtd: nand: jz4770: " Boris Brezillon
2015-12-08 10:30 ` Harvey Hunt
2015-12-08 10:33 ` Boris Brezillon
2015-12-07 22:26 ` [PATCH 06/23] mtd: nand: kill unused ->ecclayout field in platform_nand_chip struct Boris Brezillon
2015-12-07 22:26 ` [PATCH 07/23] staging: mt29f_spinand: kill unused ecclayout field Boris Brezillon
2015-12-07 22:26 ` [PATCH 08/23] mtd: nand: lpc32xx_mlc: fix ecc.size Boris Brezillon
2015-12-07 22:26 ` [PATCH 09/23] mtd: nand: vf610: remove useless mtd->ecclayout assignment Boris Brezillon
2015-12-07 22:42 ` Stefan Agner
2015-12-07 22:26 ` [PATCH 10/23] mtd: nand: simplify nand_bch_init() usage Boris Brezillon
2015-12-07 22:26 ` [PATCH 11/23] mtd: add mtd_eccpos(), mtd_oobfree() and mtd_eccbytes() helper functions Boris Brezillon
2015-12-07 22:26 ` [PATCH 12/23] mtd: use mtd_eccpos() and mtd_oobfree() where appropriate Boris Brezillon
2015-12-07 22:48 ` kbuild test robot
2015-12-07 23:36 ` kbuild test robot
2015-12-07 22:26 ` [PATCH 13/23] mtd: add mtd_set_ecclayout() helper function Boris Brezillon
2015-12-07 22:26 ` [PATCH 14/23] mtd: use mtd_set_ecclayout() where appropriate Boris Brezillon
2015-12-07 22:26 ` [PATCH 15/23] mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition Boris Brezillon
2015-12-07 22:26 ` [PATCH 16/23] mtd: docg3: switch to mtd_ooblayout_ops Boris Brezillon
2015-12-07 22:26 ` [PATCH 17/23] mtd: nand: implement the default mtd_ooblayout_ops Boris Brezillon
2015-12-07 22:26 ` [PATCH 18/23] mtd: nand: bch: switch to nand_ecclayout_pos Boris Brezillon
2015-12-07 22:26 ` [PATCH 19/23] mtd: nand: switch all drivers to mtd_ooblayout_ops Boris Brezillon
2015-12-08 10:11 ` Ralf Baechle
2015-12-07 22:26 ` [PATCH 20/23] mtd: onenand: switch " Boris Brezillon
2015-12-07 22:26 ` [PATCH 21/23] staging: mt29f_spinand: " Boris Brezillon
2015-12-07 23:59 ` [linux-sunxi] " Julian Calaby
2015-12-08 8:43 ` Boris Brezillon
2015-12-07 22:26 ` [PATCH 22/23] mtd: nand: kill layout field Boris Brezillon
2015-12-07 23:00 ` kbuild test robot
2015-12-07 22:26 ` [PATCH 23/23] mtd: kill the nand_ecclayout struct Boris Brezillon
2016-01-26 19:26 ` [PATCH 00/23] mtd: rework ECC layout definition Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151208091451.4eef0b50@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=daniel@zonque.org \
--cc=devel@driverdev.osuosl.org \
--cc=dwmw2@infradead.org \
--cc=ezequiel.garcia@free-electrons.com \
--cc=gregkh@linuxfoundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=josh.wu@atmel.com \
--cc=k.kozlowski@samsung.com \
--cc=kgene@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=maxime.ripard@free-electrons.com \
--cc=plaes@plaes.org \
--cc=punnaia@xilinx.com \
--cc=ralf@linux-mips.org \
--cc=robert.jarzmik@free.fr \
--cc=stefan@agner.ch \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).