From b7e18bd3acc0bdfe1c373965805d6355d8945bc1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 29 Aug 2013 23:41:20 +0800 Subject: [PATCH] spi: altera: Use DIV_ROUND_UP to calculate hw->bytes_per_word The Altera SPI hardware can be configured to support data width from 1 to 32 since Quartus II 8.1. To avoid truncation by integer division, use DIV_ROUND_UP to calculate hw->bytes_per_word. Signed-off-by: Axel Lin Acked-by: Thomas Chou Signed-off-by: Mark Brown --- drivers/spi/spi-altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index dce4a7e69b46a..523f2f649e266 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c @@ -134,7 +134,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t) hw->tx = t->tx_buf; hw->rx = t->rx_buf; hw->count = 0; - hw->bytes_per_word = t->bits_per_word / 8; + hw->bytes_per_word = DIV_ROUND_UP(t->bits_per_word, 8); hw->len = t->len / hw->bytes_per_word; if (hw->irq >= 0) { -- 2.39.5