diff options
author | William Zhang <william.zhang@broadcom.com> | 2023-02-09 12:02:43 -0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-02-10 21:36:43 +0000 |
commit | 76a85704cb917e3b25e00f02d5fd46e4e0a9077d (patch) | |
tree | fff69f1e8b99eacb63f82219e3a83ca6e3a76848 | |
parent | b7a82103f7c3a9168f0077e35688d4f9ce97294e (diff) | |
download | linux-stable-76a85704cb917e3b25e00f02d5fd46e4e0a9077d.tar.gz linux-stable-76a85704cb917e3b25e00f02d5fd46e4e0a9077d.tar.bz2 linux-stable-76a85704cb917e3b25e00f02d5fd46e4e0a9077d.zip |
spi: spi-mem: Allow controller supporting mem_ops without exec_op
Currently exec_op is always required if controller driver provides
mem_ops. But some controller such as bcm63xx-hsspi may only need to
implement other operation like supports_op and use the default
execution operation. This patch removes this restriction.
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Link: https://lore.kernel.org/r/20230209200246.141520-13-william.zhang@broadcom.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-mem.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi.c | 13 |
2 files changed, 7 insertions, 8 deletions
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 0c79193d9697..701838b6f0c4 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -325,7 +325,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) if (!spi_mem_internal_supports_op(mem, op)) return -ENOTSUPP; - if (ctlr->mem_ops && !mem->spi->cs_gpiod) { + if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !mem->spi->cs_gpiod) { ret = spi_mem_access_start(mem); if (ret) return ret; diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f4eb447c565d..91f71305817b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3072,15 +3072,14 @@ static int spi_controller_check_ops(struct spi_controller *ctlr) * The controller may implement only the high-level SPI-memory like * operations if it does not support regular SPI transfers, and this is * valid use case. - * If ->mem_ops is NULL, we request that at least one of the - * ->transfer_xxx() method be implemented. + * If ->mem_ops or ->mem_ops->exec_op is NULL, we request that at least + * one of the ->transfer_xxx() method be implemented. */ - if (ctlr->mem_ops) { - if (!ctlr->mem_ops->exec_op) - return -EINVAL; - } else if (!ctlr->transfer && !ctlr->transfer_one && + if (!ctlr->mem_ops || (ctlr->mem_ops && !ctlr->mem_ops->exec_op)) { + if (!ctlr->transfer && !ctlr->transfer_one && !ctlr->transfer_one_message) { - return -EINVAL; + return -EINVAL; + } } return 0; |