Thread (32 messages) 32 messages, 2 authors, 2020-05-22

Re: [PATCH v5 01/19] spi: spi-mem: allow specifying whether an op is DTR or not

From: Pratyush Yadav <hidden>
Date: 2020-05-22 10:46:07
Also in: linux-mediatek, linux-spi, lkml

[Seems like I forgot to send this and it stayed in my Drafts folder. 
Anyway, fixed in v7]

Hi Mason,

On 21/05/20 04:27PM, masonccyang@mxic.com.tw wrote:
Hi Pratyush,

Given cmd.nbytes a initial value & check it !
quoted
[PATCH v5 01/19] spi: spi-mem: allow specifying whether an op is DTR or 
not
quoted
Each phase is given a separate 'dtr' field so mixed protocols like
4S-4D-4D can be supported.

Signed-off-by: Pratyush Yadav <redacted>
---
 drivers/spi/spi-mem.c       | 3 +++
 include/linux/spi/spi-mem.h | 8 ++++++++
 2 files changed, 11 insertions(+)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 9a86cc27fcc0..93e255287ab9 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -156,6 +156,9 @@ bool spi_mem_default_supports_op(struct spi_mem 
*mem,
quoted
                op->data.dir == SPI_MEM_DATA_OUT))
       return false;

+   if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
+      return false;
+
+       if (op->cmd.nbytes != 1)
+               return false;
Good catch. Will fix.
 
quoted
    return true;
 }
 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);

 static int spi_mem_check_op(const struct spi_mem_op *op)
 {
-                if (!op->cmd.buswidth)
+                if (!op->cmd.buswidth || op->cmd.nbytes < 1 || 
op->cmd.nbytes > 2)
                                 return -EINVAL;
Will fix.
 
quoted
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index af9ff2f0f1b2..e3dcb956bf61 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
#define SPI_MEM_OP_CMD(__opcode, __buswidth)                    \
         {                                                       \
                 .buswidth = __buswidth,                         \
                 .opcode = __opcode,                             \
+                .nbytes = 1,                                    \
         }
Will fix. Thanks.

-- 
Regards,
Pratyush Yadav
Texas Instruments India

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help