]> git.baikalelectronics.ru Git - kernel.git/commitdiff
spi: altera: Use DIV_ROUND_UP to calculate hw->bytes_per_word
authorAxel Lin <axel.lin@ingics.com>
Thu, 29 Aug 2013 15:41:20 +0000 (23:41 +0800)
committerMark Brown <broonie@linaro.org>
Sat, 31 Aug 2013 13:10:41 +0000 (14:10 +0100)
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 <axel.lin@ingics.com>
Acked-by: Thomas Chou <thomas@wytron.com.tw>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-altera.c

index dce4a7e69b46aca461ca532ec47980eec094c1c8..523f2f649e2667971f75e5679403584769765a3d 100644 (file)
@@ -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) {