brcm2708: update 4.1 patches
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0182-backport-spi-bcm2835-BUG-fix-wrong-use-of-PAGE_MASK.patch
1 From 6460bf849143979acff90f3664f78bf3907aad0f Mon Sep 17 00:00:00 2001
2 From: Martin Sperl <kernel@martin.sperl.org>
3 Date: Thu, 10 Sep 2015 09:32:14 +0000
4 Subject: [PATCH 182/203] backport: spi: bcm2835: BUG: fix wrong use of
5 PAGE_MASK
6
7 There is a bug in the alignment checking of transfers,
8 that results in DMA not being used for un-aligned
9 transfers that do not cross page-boundries, which is valid.
10
11 This is due to a missconception of the meaning PAGE_MASK
12 when implementing that check originally - (PAGE_SIZE - 1)
13 should have been used instead.
14
15 Also fixes a copy/paste error.
16
17 Reported-by: <robert@axium.co.nz>
18 Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
19 Signed-off-by: Mark Brown <broonie@kernel.org>
20 Cc: stable@vger.kernel.org
21 ---
22 drivers/spi/spi-bcm2835.c | 6 +++---
23 1 file changed, 3 insertions(+), 3 deletions(-)
24
25 --- a/drivers/spi/spi-bcm2835.c
26 +++ b/drivers/spi/spi-bcm2835.c
27 @@ -386,14 +386,14 @@ static bool bcm2835_spi_can_dma(struct s
28 /* otherwise we only allow transfers within the same page
29 * to avoid wasting time on dma_mapping when it is not practical
30 */
31 - if (((size_t)tfr->tx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
32 + if (((size_t)tfr->tx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
33 dev_warn_once(&spi->dev,
34 "Unaligned spi tx-transfer bridging page\n");
35 return false;
36 }
37 - if (((size_t)tfr->rx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
38 + if (((size_t)tfr->rx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
39 dev_warn_once(&spi->dev,
40 - "Unaligned spi tx-transfer bridging page\n");
41 + "Unaligned spi rx-transfer bridging page\n");
42 return false;
43 }
44