1 From c9cae7e1e5c87d0aa76b7bededa5191a0c8cf25a Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Thu, 27 Jan 2022 10:17:57 +0100
4 Subject: [PATCH 05/15] spi: spi-mem: Check the controller extra capabilities
6 Controllers can now provide a spi-mem capabilities structure. Let's make
7 use of it in spi_mem_controller_default_supports_op(). As we want to
8 check for DTR operations as well as normal operations in a single
9 helper, let's pull the necessary checks from spi_mem_dtr_supports_op()
12 However, because no controller provide these extra capabilities, this
13 change has no effect so far.
15 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
16 Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
17 Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
18 Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
19 Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-3-miquel.raynal@bootlin.com
20 (cherry picked from commit cb7e96ee81edaa48c67d84c14df2cbe464391c37)
22 drivers/spi/spi-mem.c | 17 +++++++++++++----
23 1 file changed, 13 insertions(+), 4 deletions(-)
25 --- a/drivers/spi/spi-mem.c
26 +++ b/drivers/spi/spi-mem.c
27 @@ -173,11 +173,20 @@ EXPORT_SYMBOL_GPL(spi_mem_dtr_supports_o
28 bool spi_mem_default_supports_op(struct spi_mem *mem,
29 const struct spi_mem_op *op)
31 - if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
33 + struct spi_controller *ctlr = mem->spi->controller;
35 + op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr;
37 - if (op->cmd.nbytes != 1)
40 + if (!spi_mem_controller_is_capable(ctlr, dtr))
43 + if (op->cmd.nbytes != 2)
46 + if (op->cmd.nbytes != 1)
50 return spi_mem_check_buswidth(mem, op);