From: Boris Brezillon <boris.brezillon@collabora.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Tudor Ambarus <tudor.ambarus@microchip.com>,
Richard Weinberger <richard@nod.at>,
Boris Brezillon <bbrezillon@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/2] mtd: rawnand: atmel: Convert the driver to exec_op()
Date: Mon, 27 Apr 2020 20:25:25 +0200 [thread overview]
Message-ID: <20200427202525.43b27bb4@collabora.com> (raw)
In-Reply-To: <20200427171719.395b84a7@xps13>
On Mon, 27 Apr 2020 17:17:19 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> Hi Boris,
>
> Thanks for the conversion!
>
> Boris Brezillon <boris.brezillon@collabora.com> wrote on Sat, 18 Apr
> 2020 21:49:59 +0200:
>
> [...]
>
> >
> > -static void atmel_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
> > - unsigned int ctrl)
> > +static int atmel_hsmc_exec_rw(struct nand_chip *chip,
> > + const struct nand_subop *subop)
> > {
> > + const struct nand_op_instr *instr = subop->instrs;
> > struct atmel_nand *nand = to_atmel_nand(chip);
> > - struct atmel_nand_controller *nc;
> >
> > - nc = to_nand_controller(chip->controller);
> > + if (WARN_ON_ONCE(subop->ninstrs != 1 ||
> > + (instr->type != NAND_OP_DATA_IN_INSTR &&
> > + instr->type != NAND_OP_DATA_OUT_INSTR)))
> > + return -EINVAL;
> >
> > - if ((ctrl & NAND_CTRL_CHANGE) && nand->activecs->csgpio) {
> > - if (ctrl & NAND_NCE)
> > - gpiod_set_value(nand->activecs->csgpio, 0);
> > - else
> > - gpiod_set_value(nand->activecs->csgpio, 1);
> > - }
> > + if (instr->type == NAND_OP_DATA_IN_INSTR)
> > + atmel_nand_read_buf(nand, instr->ctx.data.buf.in,
> > + instr->ctx.data.len,
> > + instr->ctx.data.force_8bit);
> > + else
> > + atmel_nand_write_buf(nand, instr->ctx.data.buf.out,
> > + instr->ctx.data.len,
> > + instr->ctx.data.force_8bit);
> >
> > - if (ctrl & NAND_ALE)
> > - writeb(cmd, nand->activecs->io.virt + nc->caps->ale_offs);
> > - else if (ctrl & NAND_CLE)
> > - writeb(cmd, nand->activecs->io.virt + nc->caps->cle_offs);
> > + return 0;
> > +}
> > +
> > +static int atmel_hsmc_exec_waitrdy(struct nand_chip *chip,
> > + const struct nand_subop *subop)
> > +{
> > + const struct nand_op_instr *instr = subop->instrs;
> > + struct atmel_nand *nand = to_atmel_nand(chip);
> > +
> > + if (WARN_ON_ONCE(subop->ninstrs != 1 ||
> > + instr->type != NAND_OP_WAITRDY_INSTR))
> > + return -EINVAL;
>
> How could this happen? I would drop this extra check which IMHO is not
> useful (same for all the occurrences of similar conditions).
Yes, I guess I was overcautious here to detect core bugs, but you're
right, this shouldn't be checked at this level.
>
> > +
> > + return atmel_hsmc_nand_waitrdy(nand, instr->ctx.waitrdy.timeout_ms);
> > +}
> > +
> > +static const struct nand_op_parser atmel_hsmc_op_parser = NAND_OP_PARSER(
> > + NAND_OP_PARSER_PATTERN(atmel_hsmc_exec_cmd_addr,
> > + NAND_OP_PARSER_PAT_CMD_ELEM(true),
> > + NAND_OP_PARSER_PAT_ADDR_ELEM(true, 5),
> > + NAND_OP_PARSER_PAT_CMD_ELEM(true)),
> > + NAND_OP_PARSER_PATTERN(atmel_hsmc_exec_rw,
> > + NAND_OP_PARSER_PAT_DATA_IN_ELEM(false, UINT_MAX)),
>
> I find more meaningful to use 0 than UINT_MAX as the core will ignore
> any boundary in this case.
Oh, you're right, I had forgotten that 0 meant 'no-limit'.
>
> > + NAND_OP_PARSER_PATTERN(atmel_hsmc_exec_rw,
> > + NAND_OP_PARSER_PAT_DATA_IN_ELEM(false, UINT_MAX)),
>
> You probably meant DATA_OUT here?
Absolutely.
>
> > + NAND_OP_PARSER_PATTERN(atmel_hsmc_exec_waitrdy,
> > + NAND_OP_PARSER_PAT_WAITRDY_ELEM(false)),
> > +);
> > +
> > +static int atmel_hsmc_nand_exec_op(struct atmel_nand *nand,
> > + const struct nand_operation *op,
> > + bool check_only)
> > +{
> > + int ret;
> > +
> > + if (check_only)
> > + return nand_op_parser_exec_op(&nand->base,
> > + &atmel_hsmc_op_parser, op, true);
> > +
> > + atmel_hsmc_nand_select_die(nand, op->cs);
> > + ret = nand_op_parser_exec_op(&nand->base, &atmel_hsmc_op_parser, op,
> > + false);
> > + atmel_hsmc_nand_unselect_die(nand);
> > +
> > + return ret;
> > }
> >
>
> With the above fixed, please add my
>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Thanks for the review.
Boris
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-04-27 18:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 19:49 [PATCH 1/2] mtd: rawnand: Propage CS selection to sub operations Boris Brezillon
2020-04-18 19:49 ` [PATCH 2/2] mtd: rawnand: atmel: Convert the driver to exec_op() Boris Brezillon
2020-04-27 15:17 ` Miquel Raynal
2020-04-27 18:25 ` Boris Brezillon [this message]
2020-04-27 18:27 ` Boris Brezillon
2020-04-27 18:36 ` Miquel Raynal
2020-04-27 15:00 ` [PATCH 1/2] mtd: rawnand: Propage CS selection to sub operations Miquel Raynal
2020-04-27 18:22 ` Boris Brezillon
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=20200427202525.43b27bb4@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=alexandre.belloni@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=ludovic.desroches@microchip.com \
--cc=miquel.raynal@bootlin.com \
--cc=nicolas.ferre@microchip.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/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).