brcm2708: switch to linux 4.4 and update patches
[openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0157-spi-bcm2835-fix-kbuild-compile-warnings-errors-and-a.patch
1 From 17013b51143d2f549f736e784af64f861d01a717 Mon Sep 17 00:00:00 2001
2 From: Martin Sperl <kernel@martin.sperl.org>
3 Date: Tue, 12 May 2015 10:32:08 +0000
4 Subject: [PATCH 157/222] spi: bcm2835: fix kbuild compile warnings/errors and
5  a typo
6
7 fixes several warnings/error emmitted by the kbuild system:
8 * warn: cast from pointer to integer of different size
9   using size_t instead of u32
10 * error: 'SZ_4K' undeclared
11   moved to PAGE_SIZE and PAGE_MASK instead
12
13 Review showed also a typo in the same code where tx_buff
14 was checked twice instead of checking both rx and tx_buff.
15
16 Reported by: Stephen Rothwell <sfr@canb.auug.org.au>
17 Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
18 Signed-off-by: Mark Brown <broonie@kernel.org>
19 (cherry picked from commit 7e52be0d576e8f7bc99a606f07b9d000c4340f04)
20 ---
21  drivers/spi/spi-bcm2835.c | 8 +++++---
22  1 file changed, 5 insertions(+), 3 deletions(-)
23
24 --- a/drivers/spi/spi-bcm2835.c
25 +++ b/drivers/spi/spi-bcm2835.c
26 @@ -20,6 +20,7 @@
27   * GNU General Public License for more details.
28   */
29  
30 +#include <asm/page.h>
31  #include <linux/clk.h>
32  #include <linux/completion.h>
33  #include <linux/delay.h>
34 @@ -378,18 +379,19 @@ static bool bcm2835_spi_can_dma(struct s
35         }
36  
37         /* if we run rx/tx_buf with word aligned addresses then we are OK */
38 -       if (((u32)tfr->tx_buf % 4 == 0) && ((u32)tfr->tx_buf % 4 == 0))
39 +       if ((((size_t)tfr->rx_buf & 3) == 0) &&
40 +           (((size_t)tfr->tx_buf & 3) == 0))
41                 return true;
42  
43         /* otherwise we only allow transfers within the same page
44          * to avoid wasting time on dma_mapping when it is not practical
45          */
46 -       if (((u32)tfr->tx_buf % SZ_4K) + tfr->len > SZ_4K) {
47 +       if (((size_t)tfr->tx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
48                 dev_warn_once(&spi->dev,
49                               "Unaligned spi tx-transfer bridging page\n");
50                 return false;
51         }
52 -       if (((u32)tfr->rx_buf % SZ_4K) + tfr->len > SZ_4K) {
53 +       if (((size_t)tfr->rx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
54                 dev_warn_once(&spi->dev,
55                               "Unaligned spi tx-transfer bridging page\n");
56                 return false;