Skip to content

Commit 76a8570

Browse files
William Zhangbroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b7a8210 commit 76a8570

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

drivers/spi/spi-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
325325
if (!spi_mem_internal_supports_op(mem, op))
326326
return -ENOTSUPP;
327327

328-
if (ctlr->mem_ops && !mem->spi->cs_gpiod) {
328+
if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !mem->spi->cs_gpiod) {
329329
ret = spi_mem_access_start(mem);
330330
if (ret)
331331
return ret;

drivers/spi/spi.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,15 +3072,14 @@ static int spi_controller_check_ops(struct spi_controller *ctlr)
30723072
* The controller may implement only the high-level SPI-memory like
30733073
* operations if it does not support regular SPI transfers, and this is
30743074
* valid use case.
3075-
* If ->mem_ops is NULL, we request that at least one of the
3076-
* ->transfer_xxx() method be implemented.
3075+
* If ->mem_ops or ->mem_ops->exec_op is NULL, we request that at least
3076+
* one of the ->transfer_xxx() method be implemented.
30773077
*/
3078-
if (ctlr->mem_ops) {
3079-
if (!ctlr->mem_ops->exec_op)
3080-
return -EINVAL;
3081-
} else if (!ctlr->transfer && !ctlr->transfer_one &&
3078+
if (!ctlr->mem_ops || (ctlr->mem_ops && !ctlr->mem_ops->exec_op)) {
3079+
if (!ctlr->transfer && !ctlr->transfer_one &&
30823080
!ctlr->transfer_one_message) {
3083-
return -EINVAL;
3081+
return -EINVAL;
3082+
}
30843083
}
30853084

30863085
return 0;

0 commit comments

Comments
 (0)