All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue
Date: Fri, 12 Jul 2019 17:50:28 +0530	[thread overview]
Message-ID: <1507187d-172a-5cae-55f6-8232e1713473@ti.com> (raw)
In-Reply-To: <1562750607-44125-1-git-send-email-ye.li@nxp.com>



On 10/07/19 2:53 PM, Ye Li wrote:
> When slave drivers don't set the max_read_size, the spi-mem should directly
> use data.nbytes and not limit to any size. But current logic will limit to
> the max_write_size.
> 

Indeed. Thanks for catching this!

Acked-by: Vignesh Raghavendra <vigneshr@ti.com>

> Signed-off-by: Ye Li <ye.li@nxp.com>
> ---
>  drivers/spi/spi-mem.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index b86eee7..be440fe 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -423,12 +423,14 @@ int spi_mem_adjust_op_size(struct spi_slave *slave, struct spi_mem_op *op)
>  		if (slave->max_write_size && len > slave->max_write_size)
>  			return -EINVAL;
>  
> -		if (op->data.dir == SPI_MEM_DATA_IN && slave->max_read_size)
> -			op->data.nbytes = min(op->data.nbytes,
> +		if (op->data.dir == SPI_MEM_DATA_IN) {
> +			if (slave->max_read_size)
> +				op->data.nbytes = min(op->data.nbytes,
>  					      slave->max_read_size);
> -		else if (slave->max_write_size)
> +		} else if (slave->max_write_size) {
>  			op->data.nbytes = min(op->data.nbytes,
>  					      slave->max_write_size - len);
> +		}
>  
>  		if (!op->data.nbytes)
>  			return -EINVAL;
> 

-- 
Regards
Vignesh

  reply	other threads:[~2019-07-12 12:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10  9:23 [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue Ye Li
2019-07-12 12:20 ` Vignesh Raghavendra [this message]
2019-07-15  7:32 ` Jagan Teki
2019-07-16 11:50 ` Jagan Teki

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=1507187d-172a-5cae-55f6-8232e1713473@ti.com \
    --to=vigneshr@ti.com \
    --cc=u-boot@lists.denx.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 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.