Skip to content

Commit

Permalink
spi: spi-mem: Compute length only when needed
Browse files Browse the repository at this point in the history
When adjust_op_size is defined, len is never used. Move the len
computation where it's actually used.

Signed-off-by: Tudor Ambarus <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
ambarus authored and broonie committed Feb 28, 2020
1 parent 3d24b2a commit c0e035a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/spi/spi-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,13 @@ int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
struct spi_controller *ctlr = mem->spi->controller;
size_t len;

len = sizeof(op->cmd.opcode) + op->addr.nbytes + op->dummy.nbytes;

if (ctlr->mem_ops && ctlr->mem_ops->adjust_op_size)
return ctlr->mem_ops->adjust_op_size(mem, op);

if (!ctlr->mem_ops || !ctlr->mem_ops->exec_op) {
len = sizeof(op->cmd.opcode) + op->addr.nbytes +
op->dummy.nbytes;

if (len > spi_max_transfer_size(mem->spi))
return -EINVAL;

Expand Down

0 comments on commit c0e035a

Please sign in to comment.