Skip to content

Commit 7e52be0

Browse files
msperlbroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Martin Sperl <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 3ecd37e commit 7e52be0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* GNU General Public License for more details.
2121
*/
2222

23+
#include <asm/page.h>
2324
#include <linux/clk.h>
2425
#include <linux/completion.h>
2526
#include <linux/delay.h>
@@ -378,18 +379,19 @@ static bool bcm2835_spi_can_dma(struct spi_master *master,
378379
}
379380

380381
/* if we run rx/tx_buf with word aligned addresses then we are OK */
381-
if (((u32)tfr->tx_buf % 4 == 0) && ((u32)tfr->tx_buf % 4 == 0))
382+
if ((((size_t)tfr->rx_buf & 3) == 0) &&
383+
(((size_t)tfr->tx_buf & 3) == 0))
382384
return true;
383385

384386
/* otherwise we only allow transfers within the same page
385387
* to avoid wasting time on dma_mapping when it is not practical
386388
*/
387-
if (((u32)tfr->tx_buf % SZ_4K) + tfr->len > SZ_4K) {
389+
if (((size_t)tfr->tx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
388390
dev_warn_once(&spi->dev,
389391
"Unaligned spi tx-transfer bridging page\n");
390392
return false;
391393
}
392-
if (((u32)tfr->rx_buf % SZ_4K) + tfr->len > SZ_4K) {
394+
if (((size_t)tfr->rx_buf & PAGE_MASK) + tfr->len > PAGE_SIZE) {
393395
dev_warn_once(&spi->dev,
394396
"Unaligned spi tx-transfer bridging page\n");
395397
return false;

0 commit comments

Comments
 (0)