Skip to content

Commit 8a9a784

Browse files
westeribroonie
authored andcommitted
spi: intel: Implement adjust_op_size()
This allows us to get rid of the checks in the intel_spi_[sh]w_cycle() and makes it possible for the SPI-NOR core to split the transaction into smaller chunks as needed. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Link: https://lore.kernel.org/r/20221025064623.22808-3-mika.westerberg@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f73f6bd commit 8a9a784

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/spi/spi-intel.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,6 @@ static int intel_spi_hw_cycle(struct intel_spi *ispi,
363363

364364
val = readl(ispi->base + HSFSTS_CTL);
365365
val &= ~(HSFSTS_CTL_FCYCLE_MASK | HSFSTS_CTL_FDBC_MASK);
366-
367-
if (len > INTEL_SPI_FIFO_SZ)
368-
return -EINVAL;
369-
370366
val |= (len - 1) << HSFSTS_CTL_FDBC_SHIFT;
371367
val |= HSFSTS_CTL_FCERR | HSFSTS_CTL_FDONE;
372368
val |= HSFSTS_CTL_FGO;
@@ -397,9 +393,6 @@ static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, size_t len,
397393
if (ret < 0)
398394
return ret;
399395

400-
if (len > INTEL_SPI_FIFO_SZ)
401-
return -EINVAL;
402-
403396
/*
404397
* Always clear it after each SW sequencer operation regardless
405398
* of whether it is successful or not.
@@ -704,6 +697,12 @@ static int intel_spi_erase(struct intel_spi *ispi, const struct spi_mem *mem,
704697
return 0;
705698
}
706699

700+
static int intel_spi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
701+
{
702+
op->data.nbytes = clamp_val(op->data.nbytes, 0, INTEL_SPI_FIFO_SZ);
703+
return 0;
704+
}
705+
707706
static bool intel_spi_cmp_mem_op(const struct intel_spi_mem_op *iop,
708707
const struct spi_mem_op *op)
709708
{
@@ -844,6 +843,7 @@ static ssize_t intel_spi_dirmap_write(struct spi_mem_dirmap_desc *desc, u64 offs
844843
}
845844

846845
static const struct spi_controller_mem_ops intel_spi_mem_ops = {
846+
.adjust_op_size = intel_spi_adjust_op_size,
847847
.supports_op = intel_spi_supports_mem_op,
848848
.exec_op = intel_spi_exec_mem_op,
849849
.get_name = intel_spi_get_name,

0 commit comments

Comments
 (0)