[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhJPsUw7YGKfBuFtUirOGuCA9hV6e-wjrL4L9b-5kmuVUW=ow@mail.gmail.com>
Date: Tue, 4 Mar 2025 19:46:39 +0800
From: Keguang Zhang <keguang.zhang@...il.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>
Cc: Keguang Zhang via B4 Relay <devnull+keguang.zhang.gmail.com@...nel.org>,
Richard Weinberger <richard@....at>, Vignesh Raghavendra <vigneshr@...com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-media@...r.kernel.org
Subject: Re: [PATCH v12 2/2] mtd: rawnand: Add Loongson-1 NAND Controller Driver
Hello Miquel,
On Fri, Feb 7, 2025 at 1:17 AM Miquel Raynal <miquel.raynal@...tlin.com> wrote:
>
> Hello,
>
> > +static inline int ls1x_nand_check_op(struct nand_chip *chip, const
> > struct nand_operation *op)
>
> No inline function in a c file.
>
> > +{
> > + struct ls1x_nand_host *host = nand_get_controller_data(chip);
> > + const struct nand_op_instr *instr1 = NULL, *instr2 = NULL;
> > + int op_id;
> > +
> > + for (op_id = 0; op_id < op->ninstrs; op_id++) {
> > + const struct nand_op_instr *instr = &op->instrs[op_id];
> > +
> > + if (instr->type == NAND_OP_CMD_INSTR) {
> > + if (!instr1)
> > + instr1 = instr;
> > + else if (!instr2)
> > + instr2 = instr;
> > + else
> > + break;
> > + }
> > + }
> > +
> > + if (!instr1 || !instr2)
> > + return 0;
>
> Is this expected?
>
> > +
> > + if (instr1->ctx.cmd.opcode == NAND_CMD_RNDOUT &&
> > + instr2->ctx.cmd.opcode == NAND_CMD_RNDOUTSTART)
> > + return 0;
> > +
> > + if (instr1->ctx.cmd.opcode == NAND_CMD_READ0 &&
> > + instr2->ctx.cmd.opcode == NAND_CMD_READSTART)
> > + return 0;
> > +
> > + if (instr1->ctx.cmd.opcode == NAND_CMD_ERASE1 &&
> > + instr2->ctx.cmd.opcode == NAND_CMD_ERASE2)
> > + return 0;
> > +
> > + if (instr1->ctx.cmd.opcode == NAND_CMD_SEQIN &&
> > + instr2->ctx.cmd.opcode == NAND_CMD_PAGEPROG)
> > + return 0;
> > +
> > + dev_err(host->dev, "unsupported opcode sequence: %x %x",
> > + instr1->ctx.cmd.opcode, instr2->ctx.cmd.opcode);
> > +
> > + return -EOPNOTSUPP;
> > +}
> > +
> > +static int ls1x_nand_exec_op(struct nand_chip *chip,
> > + const struct nand_operation *op,
> > + bool check_only)
> > +{
> > + int ret;
> > +
>
> if (check_only) ?
Sorry, I'm not sure if I understand correctly.
nand_op_parser_exec_op() only checks patterns and will skip
pattern->exec() when check_only = true. Therefore,
ls1x_nand_check_op() should handle all opcode checks in that case, and
leave check_only = false to nand_op_parser_exec_op().
Then the code will return to:
if (check_only)
return ls1x_nand_check_op(chip, op);
return nand_op_parser_exec_op(chip, &ls1x_nand_op_parser, op, check_only);
Am I right?
> > + ret = ls1x_nand_check_op(chip, op);
> > + if (ret)
> > + return ret;
> > +
> > + return nand_op_parser_exec_op(chip, &ls1x_nand_op_parser, op, check_only);
> > +}
> > +
> > +static const char * const nand_ecc_algos[] = {
> > + [NAND_ECC_ALGO_UNKNOWN] = "none",
> > + [NAND_ECC_ALGO_HAMMING] = "hamming",
> > + [NAND_ECC_ALGO_BCH] = "bch",
> > +};
>
> No way you need this in your driver :-)
>
> Thanks,
> Miquèl
--
Best regards,
Keguang Zhang
Powered by blists - more mailing lists