drivers/spi/spi-armada-3700.c:500:65: sparse: sparse: incorrect type in argument 3 (different base types)

From: kernel test robot
Date: Fri Aug 05 2022 - 23:33:33 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6614a3c3164a5df2b54abb0b3559f51041cf705b
commit: 66bbf1441d218316948877f7ec6b477c9a49d554 spi: a3700: support BE for AC5 SPI driver
date: 11 days ago
config: arm64-randconfig-s052-20220804 (https://download.01.org/0day-ci/archive/20220806/202208061151.1zncglDW-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=66bbf1441d218316948877f7ec6b477c9a49d554
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 66bbf1441d218316948877f7ec6b477c9a49d554
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/block/null_blk/./ drivers/spi/ fs/zonefs/./

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

sparse warnings: (new ones prefixed by >>)
>> drivers/spi/spi-armada-3700.c:500:65: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned int [usertype] data @@ got restricted __le32 [usertype] @@
drivers/spi/spi-armada-3700.c:500:65: sparse: expected unsigned int [usertype] data
drivers/spi/spi-armada-3700.c:500:65: sparse: got restricted __le32 [usertype]
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32
>> drivers/spi/spi-armada-3700.c:522:31: sparse: sparse: cast to restricted __le32

vim +500 drivers/spi/spi-armada-3700.c

493
494 static int a3700_spi_fifo_write(struct a3700_spi *a3700_spi)
495 {
496 u32 val;
497
498 while (!a3700_is_wfifo_full(a3700_spi) && a3700_spi->buf_len) {
499 val = *(u32 *)a3700_spi->tx_buf;
> 500 spireg_write(a3700_spi, A3700_SPI_DATA_OUT_REG, cpu_to_le32(val));
501 a3700_spi->buf_len -= 4;
502 a3700_spi->tx_buf += 4;
503 }
504
505 return 0;
506 }
507
508 static int a3700_is_rfifo_empty(struct a3700_spi *a3700_spi)
509 {
510 u32 val = spireg_read(a3700_spi, A3700_SPI_IF_CTRL_REG);
511
512 return (val & A3700_SPI_RFIFO_EMPTY);
513 }
514
515 static int a3700_spi_fifo_read(struct a3700_spi *a3700_spi)
516 {
517 u32 val;
518
519 while (!a3700_is_rfifo_empty(a3700_spi) && a3700_spi->buf_len) {
520 val = spireg_read(a3700_spi, A3700_SPI_DATA_IN_REG);
521 if (a3700_spi->buf_len >= 4) {
> 522 val = le32_to_cpu(val);
523 memcpy(a3700_spi->rx_buf, &val, 4);
524
525 a3700_spi->buf_len -= 4;
526 a3700_spi->rx_buf += 4;
527 } else {
528 /*
529 * When remain bytes is not larger than 4, we should
530 * avoid memory overwriting and just write the left rx
531 * buffer bytes.
532 */
533 while (a3700_spi->buf_len) {
534 *a3700_spi->rx_buf = val & 0xff;
535 val >>= 8;
536
537 a3700_spi->buf_len--;
538 a3700_spi->rx_buf++;
539 }
540 }
541 }
542
543 return 0;
544 }
545

--
0-DAY CI Kernel Test Service
https://01.org/lkp