From: Vignesh R <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 04/20] spi: spi-mem: Extend spi_mem_adjust_op_size() to honor max xfer size
Date: Tue, 5 Feb 2019 11:29:13 +0530 [thread overview]
Message-ID: <20190205055929.24168-5-vigneshr@ti.com> (raw)
In-Reply-To: <20190205055929.24168-1-vigneshr@ti.com>
Extend spi_mem_adjust_op_size() to take spi->max_write_size and
spi->max_read_size into account.
Signed-off-by: Vignesh R <vigneshr@ti.com>
Tested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
Tested-by: Jagan Teki <jagan@amarulasolutions.com> #zynq-microzed
---
drivers/spi/spi-mem.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 1da20b8de5c4..334af682dc65 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -412,6 +412,25 @@ int spi_mem_adjust_op_size(struct spi_slave *slave, struct spi_mem_op *op)
if (ops->mem_ops && ops->mem_ops->adjust_op_size)
return ops->mem_ops->adjust_op_size(slave, op);
+ if (!ops->mem_ops || !ops->mem_ops->exec_op) {
+ unsigned int len;
+
+ len = sizeof(op->cmd.opcode) + op->addr.nbytes +
+ op->dummy.nbytes;
+ 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,
+ slave->max_read_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;
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size);
--
2.20.1
next prev parent reply other threads:[~2019-02-05 5:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-05 5:59 [U-Boot] [PATCH v4 00/20] SF: Migrate to Linux SPI NOR framework Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 01/20] configs: Move CONFIG_SPI_FLASH into defconfigs Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 02/20] bitops: Fix GENMASK definition for Sandbox Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 03/20] spi: spi-mem: Allow use of spi_mem_exec_op for all SPI modes Vignesh R
2019-02-05 5:59 ` Vignesh R [this message]
2019-02-05 5:59 ` [U-Boot] [PATCH v4 05/20] spi: spi-mem: Claim SPI bus before spi mem access Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 06/20] spi: Add non DM version of SPI_MEM Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 07/20] sh: bitops: add hweight*() macros Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 08/20] mtd: spi: Port SPI NOR framework from Linux Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 09/20] mtd: spi: spi-nor-core: Add SPI MEM support Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 10/20] mtd: spi: spi-nor-core: Add 4 Byte addressing support Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 11/20] mtd: spi: spi-nor-core: Add SFDP support Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 12/20] mtd: spi: spi-nor-core: Add back U-Boot specific features Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 13/20] mtd: spi: sf_probe: Add "jedec, spi-nor" compatible string Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 14/20] mtd: spi: Switch to new SPI NOR framework Vignesh R
2019-02-11 3:31 ` Adam Ford
2019-02-11 4:38 ` Vignesh R
2019-02-12 19:20 ` Adam Ford
2019-02-12 20:24 ` Adam Ford
2019-02-13 3:51 ` Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 15/20] mtd: spi: Remove unused files Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 16/20] mtd: spi: Add lightweight SPI flash stack for SPL Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 17/20] spl: Kconfig: Enable SPI_FLASH_TINY by default " Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 18/20] configs: Remove SF_DUAL_FLASH Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 19/20] configs: Don't use SPI_FLASH_BAR as default Vignesh R
2019-02-05 5:59 ` [U-Boot] [PATCH v4 20/20] MAINTAINERS: Add an entry for SPI NOR Vignesh R
2019-02-06 8:13 ` [U-Boot] [PATCH v4 00/20] SF: Migrate to Linux SPI NOR framework Simon Goldschmidt
2019-02-06 17:32 ` Vignesh R
2019-02-06 19:05 ` Tom Rini
2019-02-07 12:43 ` Jagan Teki
2019-02-08 13:06 ` Vignesh R
2019-02-13 13:42 ` Boris Brezillon
2019-02-13 13:43 ` 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=20190205055929.24168-5-vigneshr@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox