Skip to content

Commit 0395be9

Browse files
Apurva Nandanbroonie
authored andcommitted
spi: cadence-quadspi: Fix check condition for DTR ops
buswidth and dtr fields in spi_mem_op are only valid when the corresponding spi_mem_op phase has a non-zero length. For example, SPI NAND core doesn't set buswidth when using SPI_MEM_OP_NO_ADDR phase. Fix the dtr checks in set_protocol() and suppports_mem_op() to ignore empty spi_mem_op phases, as checking for dtr field in empty phase will result in false negatives. Signed-off-by: Apurva Nandan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0d5c395 commit 0395be9

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,15 @@ static int cqspi_set_protocol(struct cqspi_flash_pdata *f_pdata,
325325
f_pdata->inst_width = CQSPI_INST_TYPE_SINGLE;
326326
f_pdata->addr_width = CQSPI_INST_TYPE_SINGLE;
327327
f_pdata->data_width = CQSPI_INST_TYPE_SINGLE;
328-
f_pdata->dtr = op->data.dtr && op->cmd.dtr && op->addr.dtr;
328+
329+
/*
330+
* For an op to be DTR, cmd phase along with every other non-empty
331+
* phase should have dtr field set to 1. If an op phase has zero
332+
* nbytes, ignore its dtr field; otherwise, check its dtr field.
333+
*/
334+
f_pdata->dtr = op->cmd.dtr &&
335+
(!op->addr.nbytes || op->addr.dtr) &&
336+
(!op->data.nbytes || op->data.dtr);
329337

330338
switch (op->data.buswidth) {
331339
case 0:
@@ -1228,8 +1236,15 @@ static bool cqspi_supports_mem_op(struct spi_mem *mem,
12281236
{
12291237
bool all_true, all_false;
12301238

1231-
all_true = op->cmd.dtr && op->addr.dtr && op->dummy.dtr &&
1232-
op->data.dtr;
1239+
/*
1240+
* op->dummy.dtr is required for converting nbytes into ncycles.
1241+
* Also, don't check the dtr field of the op phase having zero nbytes.
1242+
*/
1243+
all_true = op->cmd.dtr &&
1244+
(!op->addr.nbytes || op->addr.dtr) &&
1245+
(!op->dummy.nbytes || op->dummy.dtr) &&
1246+
(!op->data.nbytes || op->data.dtr);
1247+
12331248
all_false = !op->cmd.dtr && !op->addr.dtr && !op->dummy.dtr &&
12341249
!op->data.dtr;
12351250

0 commit comments

Comments
 (0)