* [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue
@ 2019-07-10 9:23 Ye Li
2019-07-12 12:20 ` Vignesh Raghavendra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ye Li @ 2019-07-10 9:23 UTC (permalink / raw)
To: u-boot
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.
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;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue
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
2019-07-15 7:32 ` Jagan Teki
2019-07-16 11:50 ` Jagan Teki
2 siblings, 0 replies; 4+ messages in thread
From: Vignesh Raghavendra @ 2019-07-12 12:20 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue
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
@ 2019-07-15 7:32 ` Jagan Teki
2019-07-16 11:50 ` Jagan Teki
2 siblings, 0 replies; 4+ messages in thread
From: Jagan Teki @ 2019-07-15 7:32 UTC (permalink / raw)
To: u-boot
On Wed, Jul 10, 2019 at 2:54 PM Ye Li <ye.li@nxp.com> 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.
>
> 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);
> + }
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] spi: spi-mem: Fix read data size issue
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
2019-07-15 7:32 ` Jagan Teki
@ 2019-07-16 11:50 ` Jagan Teki
2 siblings, 0 replies; 4+ messages in thread
From: Jagan Teki @ 2019-07-16 11:50 UTC (permalink / raw)
To: u-boot
On Wed, Jul 10, 2019 at 2:54 PM Ye Li <ye.li@nxp.com> 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.
>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> ---
> drivers/spi/spi-mem.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
Applied to u-boot-spi/master
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-16 11:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-07-15 7:32 ` Jagan Teki
2019-07-16 11:50 ` Jagan Teki
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.