提交 7e52be0d 编写于 作者: M Martin Sperl 提交者: Mark Brown

spi: bcm2835: fix kbuild compile warnings/errors and a typo

fixes several warnings/error emmitted by the kbuild system:
* warn: cast from pointer to integer of different size
  using size_t instead of u32
* error: 'SZ_4K' undeclared
  moved to PAGE_SIZE and PAGE_MASK instead

Review showed also a typo in the same code where tx_buff
was checked twice instead of checking both rx and tx_buff.

Reported by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 3ecd37ed
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <asm/page.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -378,18 +379,19 @@ static bool bcm2835_spi_can_dma(struct spi_master *master, ...@@ -378,18 +379,19 @@ static bool bcm2835_spi_can_dma(struct spi_master *master,
} }
/* if we run rx/tx_buf with word aligned addresses then we are OK */ /* if we run rx/tx_buf with word aligned addresses then we are OK */
if (((u32)tfr->tx_buf % 4 == 0) && ((u32)tfr->tx_buf % 4 == 0)) if ((((size_t)tfr->rx_buf & 3) == 0) &&
(((size_t)tfr->tx_buf & 3) == 0))
return true; return true;
/* otherwise we only allow transfers within the same page /* otherwise we only allow transfers within the same page
* to avoid wasting time on dma_mapping when it is not practical * to avoid wasting time on dma_mapping when it is not practical
*/ */
if (((u32)tfr->tx_buf % SZ_4K) + tfr->len > SZ_4K) { if (((size_t)tfr->tx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
dev_warn_once(&spi->dev, dev_warn_once(&spi->dev,
"Unaligned spi tx-transfer bridging page\n"); "Unaligned spi tx-transfer bridging page\n");
return false; return false;
} }
if (((u32)tfr->rx_buf % SZ_4K) + tfr->len > SZ_4K) { if (((size_t)tfr->rx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
dev_warn_once(&spi->dev, dev_warn_once(&spi->dev,
"Unaligned spi tx-transfer bridging page\n"); "Unaligned spi tx-transfer bridging page\n");
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册