drivers/spi/spi-nxp-xspi.c:783:25-26: WARNING opportunity for max()
kernel test robot <[email protected]>
| Newsgroups | dev.linux.lists.oe-kbuild |
|---|---|
| Message-ID | <[email protected]> |
BCC: [email protected] CC: [email protected] CC: [email protected] TO: Haibo Chen <[email protected]> CC: Mark Brown <[email protected]> CC: Frank Li <[email protected]> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: dd3210c47e8d3ac6b4e9141fc68acc03b38c0ba3 commit: 29c8c00d9f9db5fb659b6f05f9e8964afc13f3e2 spi: add driver for NXP XSPI controller date: 7 months ago :::::: branch date: 28 hours ago :::::: commit date: 7 months ago config: hexagon-randconfig-r051-20260709 (https://download.01.org/0day-ci/archive/20260712/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c279890c85da307abe34f10333442bbf72a60644) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Fixes: 29c8c00d9f9d ("spi: add driver for NXP XSPI controller") | Reported-by: kernel test robot <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/ cocci warnings: (new ones prefixed by >>) >> drivers/spi/spi-nxp-xspi.c:783:25-26: WARNING opportunity for max() vim +783 drivers/spi/spi-nxp-xspi.c 29c8c00d9f9db5 Haibo Chen 2025-12-16 770 29c8c00d9f9db5 Haibo Chen 2025-12-16 771 static int nxp_xspi_ahb_read(struct nxp_xspi *xspi, const struct spi_mem_op *op) 29c8c00d9f9db5 Haibo Chen 2025-12-16 772 { 29c8c00d9f9db5 Haibo Chen 2025-12-16 773 u32 start = op->addr.val; 29c8c00d9f9db5 Haibo Chen 2025-12-16 774 u32 len = op->data.nbytes; 29c8c00d9f9db5 Haibo Chen 2025-12-16 775 29c8c00d9f9db5 Haibo Chen 2025-12-16 776 /* If necessary, ioremap before AHB read */ 29c8c00d9f9db5 Haibo Chen 2025-12-16 777 if ((!xspi->ahb_addr) || start < xspi->memmap_start || 29c8c00d9f9db5 Haibo Chen 2025-12-16 778 start + len > xspi->memmap_start + xspi->memmap_len) { 29c8c00d9f9db5 Haibo Chen 2025-12-16 779 if (xspi->ahb_addr) 29c8c00d9f9db5 Haibo Chen 2025-12-16 780 iounmap(xspi->ahb_addr); 29c8c00d9f9db5 Haibo Chen 2025-12-16 781 29c8c00d9f9db5 Haibo Chen 2025-12-16 782 xspi->memmap_start = start; 29c8c00d9f9db5 Haibo Chen 2025-12-16 @783 xspi->memmap_len = len > NXP_XSPI_MIN_IOMAP ? 29c8c00d9f9db5 Haibo Chen 2025-12-16 784 len : NXP_XSPI_MIN_IOMAP; 29c8c00d9f9db5 Haibo Chen 2025-12-16 785 29c8c00d9f9db5 Haibo Chen 2025-12-16 786 xspi->ahb_addr = ioremap(xspi->memmap_phy + xspi->memmap_start, 29c8c00d9f9db5 Haibo Chen 2025-12-16 787 xspi->memmap_len); 29c8c00d9f9db5 Haibo Chen 2025-12-16 788 29c8c00d9f9db5 Haibo Chen 2025-12-16 789 if (!xspi->ahb_addr) { 29c8c00d9f9db5 Haibo Chen 2025-12-16 790 dev_err(xspi->dev, "failed to alloc memory\n"); 29c8c00d9f9db5 Haibo Chen 2025-12-16 791 return -ENOMEM; 29c8c00d9f9db5 Haibo Chen 2025-12-16 792 } 29c8c00d9f9db5 Haibo Chen 2025-12-16 793 } 29c8c00d9f9db5 Haibo Chen 2025-12-16 794 29c8c00d9f9db5 Haibo Chen 2025-12-16 795 /* Read out the data directly from the AHB buffer. */ 29c8c00d9f9db5 Haibo Chen 2025-12-16 796 memcpy_fromio(op->data.buf.in, 29c8c00d9f9db5 Haibo Chen 2025-12-16 797 xspi->ahb_addr + start - xspi->memmap_start, len); 29c8c00d9f9db5 Haibo Chen 2025-12-16 798 29c8c00d9f9db5 Haibo Chen 2025-12-16 799 return 0; 29c8c00d9f9db5 Haibo Chen 2025-12-16 800 } 29c8c00d9f9db5 Haibo Chen 2025-12-16 801 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki