Skip to content

Commit

Permalink
spi: spi-au1550: replace ternary operator with min()
Browse files Browse the repository at this point in the history
Fix the following coccicheck warnings:

drivers/spi/spi-au1550.c:408:21-22: WARNING opportunity for min()
drivers/spi/spi-au1550.c:542:21-22: WARNING opportunity for min()

min() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Link: https://lore.kernel.org/r/20220513130333.58379-1-guozhengkui@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Guo Zhengkui authored and Mark Brown committed May 16, 2022
1 parent 22d35e4 commit b1849f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/spi/spi-au1550.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
dma_unmap_single(hw->dev, dma_tx_addr, t->len,
DMA_TO_DEVICE);

return hw->rx_count < hw->tx_count ? hw->rx_count : hw->tx_count;
return min(hw->rx_count, hw->tx_count);
}

static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw)
Expand Down Expand Up @@ -539,7 +539,7 @@ static int au1550_spi_pio_txrxb(struct spi_device *spi, struct spi_transfer *t)

wait_for_completion(&hw->master_done);

return hw->rx_count < hw->tx_count ? hw->rx_count : hw->tx_count;
return min(hw->rx_count, hw->tx_count);
}

static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw)
Expand Down

0 comments on commit b1849f5

Please sign in to comment.