From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de,
Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH 6/8] mtd: nand: mxc: Add own write_page
Date: Fri, 12 Jan 2018 16:36:49 +0100 [thread overview]
Message-ID: <20180112163649.3103cb82@bbrezillon> (raw)
In-Reply-To: <20180109101148.13728-7-s.hauer@pengutronix.de>
On Tue, 9 Jan 2018 11:11:46 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Now that we have our own read_page function add a write_page function
> for consistency aswell. This can be a lot easier than the generic
> function since we do not have to iterate over subpages but can write
> the whole page at once. Also add write_page_raw and write_oob for
> proper raw and oob write support.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/mtd/nand/mxc_nand.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index 83bb01ab7079..6fbf98851a96 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -893,6 +893,59 @@ static int mxc_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
> page);
> }
>
> +static int __mxc_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
I'm not a big fan of those '__' prefixes. How about keeping
mxc_nand_write_page() for this one, renaming the other
mxc_nand_write_page() into mxc_nand_write_page_ecc() and keeping the
other ones unchanged.
> + const uint8_t *buf, int oob_required, int page)
Why don't you pass a 'bool enable_ecc' argument here so that you can
directly do
host->devtype_data->enable_hwecc(nand_chip, enable_ecc);
from here instead of duplicating it in all wrappers?
> +{
> + struct mxc_nand_host *host = nand_get_controller_data(chip);
> +
> + host->devtype_data->send_cmd(host, NAND_CMD_SEQIN, false);
> + mxc_do_addr_cycle(mtd, 0, page);
> +
> + memcpy32_toio(host->main_area0, buf, mtd->writesize);
> + copy_spare(mtd, false, chip->oob_poi);
> +
> + host->devtype_data->send_page(mtd, NFC_INPUT);
> + host->devtype_data->send_cmd(host, NAND_CMD_PAGEPROG, true);
> + mxc_do_addr_cycle(mtd, 0, page);
> +
> + return 0;
> +}
> +
> +static int mxc_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
> + const uint8_t *buf, int oob_required, int page)
> +{
> + struct nand_chip *nand_chip = mtd_to_nand(mtd);
> + struct mxc_nand_host *host = nand_get_controller_data(chip);
> +
> + host->devtype_data->enable_hwecc(nand_chip, true);
> +
> + return __mxc_nand_write_page(mtd, chip, buf, oob_required, page);
> +}
> +
> +static int mxc_nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> + const uint8_t *buf, int oob_required, int page)
> +{
> + struct nand_chip *nand_chip = mtd_to_nand(mtd);
> + struct mxc_nand_host *host = nand_get_controller_data(chip);
> +
> + host->devtype_data->enable_hwecc(nand_chip, false);
> +
> + return __mxc_nand_write_page(mtd, chip, buf, oob_required, page);
> +}
> +
> +static int mxc_nand_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
> + int page)
> +{
> + struct nand_chip *nand_chip = mtd_to_nand(mtd);
> + struct mxc_nand_host *host = nand_get_controller_data(chip);
> +
> + memset(host->data_buf, 0xff, mtd->writesize);
> +
> + host->devtype_data->enable_hwecc(nand_chip, false);
> +
> + return __mxc_nand_write_page(mtd, chip, host->data_buf, 1, page);
> +}
> +
> static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
> u_char *ecc_code)
> {
> @@ -1907,6 +1960,9 @@ static int mxcnd_probe(struct platform_device *pdev)
> this->ecc.read_page = mxc_nand_read_page;
> this->ecc.read_page_raw = mxc_nand_read_page_raw;
> this->ecc.read_oob = mxc_nand_read_oob;
> + this->ecc.write_page = mxc_nand_write_page;
> + this->ecc.write_page_raw = mxc_nand_write_page_raw;
> + this->ecc.write_oob = mxc_nand_write_oob;
> this->ecc.calculate = mxc_nand_calculate_ecc;
> this->ecc.hwctl = mxc_nand_enable_hwecc;
> this->ecc.correct = host->devtype_data->correct_data;
next prev parent reply other threads:[~2018-01-12 15:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 10:11 mxc_nand controller fixes Sascha Hauer
2018-01-09 10:11 ` [PATCH 1/8] mtd: nand: mxc: reorder functions to avoid forward declarations Sascha Hauer
2018-01-09 10:11 ` [PATCH 2/8] mtd: nand: mxc: Add function to control hardware ECC Sascha Hauer
2018-01-09 10:11 ` [PATCH 3/8] mtd: nand: mxc: Add buffer argument to copy_spare Sascha Hauer
2018-01-09 10:11 ` [PATCH 4/8] mtd: nand: mxc: Fix failed/corrected values for v2/v3 controllers Sascha Hauer
2018-01-12 15:31 ` Boris Brezillon
2018-01-09 10:11 ` [PATCH 5/8] mtd: nand: mxc: Fix failed/corrected values for v1 controllers Sascha Hauer
2018-01-12 15:28 ` Boris Brezillon
2018-01-09 10:11 ` [PATCH 6/8] mtd: nand: mxc: Add own write_page Sascha Hauer
2018-01-12 15:36 ` Boris Brezillon [this message]
2018-01-13 16:25 ` Miquel Raynal
2018-01-17 10:40 ` Sascha Hauer
2018-01-18 7:16 ` Miquel Raynal
2018-01-09 10:11 ` [PATCH 7/8] mtd: nand: mxc: Drop now unnecessary functions Sascha Hauer
2018-01-09 10:11 ` [PATCH 8/8] mtd: nand: mxc: remove now unused code Sascha Hauer
-- strict thread matches above, loose matches on Subject: below --
2018-01-17 11:32 [PATCH v2] mxc_nand controller fixes Sascha Hauer
2018-01-17 11:32 ` [PATCH 6/8] mtd: nand: mxc: Add own write_page Sascha Hauer
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=20180112163649.3103cb82@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=kernel@pengutronix.de \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
/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).