From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Chuanhua Han <chuanhua.han@nxp.com>
Cc: broonie@kernel.org, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
jiafei.pan@nxp.com, zhiqiang.hou@nxp.com
Subject: Re: [PATCH] mtd: m25p80: consider max message size when use the spi_mem_xx() API
Date: Mon, 20 Aug 2018 12:15:44 +0200 [thread overview]
Message-ID: <20180820121544.5dfaf802@bbrezillon> (raw)
In-Reply-To: <1534758206-24555-1-git-send-email-chuanhua.han@nxp.com>
Hi Chuanhua,
On Mon, 20 Aug 2018 17:43:26 +0800
Chuanhua Han <chuanhua.han@nxp.com> wrote:
Subject prefix should be "spi: spi-mem: " not "mtd: m25p80: ", and you
need a commit message explaining what this patch does and why it's
needed.
> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
Fixes: c36ff266dc82 ("spi: Extend the core to ease integration of SPI memory controllers")
Cc: <stable@vger.kernel.org>
> ---
> Changes in v2:
> - Place the adjusted transfer bytes code in spi_mem_adjust_op_size()
> and check spi_max_message_size(mem->spi) value before subtracting
> opcode, addr and dummy bytes.
> *fixes:
> spi: Extend the core to ease integration of SPI memory controllers
> ---
> drivers/spi/spi-mem.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index 990770d..f5e75d1 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -328,10 +328,21 @@ EXPORT_SYMBOL_GPL(spi_mem_exec_op);
> int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
> {
> struct spi_controller *ctlr = mem->spi->controller;
> + unsigned long val = sizeof(op->cmd.opcode) +
> + op->addr.nbytes +
> + op->dummy.nbytes;
Not properly aligned, and you should find a better name for this variable.
>
> if (ctlr->mem_ops && ctlr->mem_ops->adjust_op_size)
> return ctlr->mem_ops->adjust_op_size(mem, op);
>
> + if (spi_max_message_size(mem->spi) < val)
> + return -EINVAL;
This should be enclosed in the if (!ctlr->mem_ops || !ctlr->mem_ops->exec_op)
block and you should check that spi_max_transfer_size(mem->spi) >= val too.
> +
> + if (!ctlr->mem_ops || !ctlr->mem_ops->exec_op)
> + op->data.nbytes = min3((unsigned long)op->data.nbytes,
> + spi_max_transfer_size(mem->spi),
> + spi_max_message_size(mem->spi) - val);
> +
> return 0;
> }
> EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size);
Regards,
Boris
next prev parent reply other threads:[~2018-08-20 10:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 9:43 [PATCH] mtd: m25p80: consider max message size when use the spi_mem_xx() API Chuanhua Han
2018-08-20 10:15 ` Boris Brezillon [this message]
2018-08-20 10:23 ` kbuild test robot
2018-08-20 17:13 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2018-08-20 12:43 Chuanhua Han
2018-08-20 13:01 ` David Laight
2018-08-20 13:54 ` 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=20180820121544.5dfaf802@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=broonie@kernel.org \
--cc=chuanhua.han@nxp.com \
--cc=jiafei.pan@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=zhiqiang.hou@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.