[broonie-spi:for-6.15 10/22] drivers/spi/spi-sg2044-nor.c:243 sg2044_spifmc_write() warn: unsigned 'ret' is never less than zero.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-6.15
head:   336a41c90c86b883aa06ed19f138eee19ddf9958
commit: de16c322eefbe9026d4eabc8ae934bb778cffd1d [10/22] spi: sophgo: add SG2044 SPI NOR controller driver
config: openrisc-randconfig-r072-20250314 (https://download.01.org/0day-ci/archive/20250315/202503151344.DRTW7z9o-lkp@xxxxxxxxx/config)
compiler: or1k-linux-gcc (GCC) 14.2.0

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
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503151344.DRTW7z9o-lkp@xxxxxxxxx/

New smatch warnings:
drivers/spi/spi-sg2044-nor.c:243 sg2044_spifmc_write() warn: unsigned 'ret' is never less than zero.
drivers/spi/spi-sg2044-nor.c:450 sg2044_spifmc_probe() error: uninitialized symbol 'base'.

Old smatch warnings:
drivers/spi/spi-sg2044-nor.c:253 sg2044_spifmc_write() warn: unsigned 'ret' is never less than zero.
drivers/spi/spi-sg2044-nor.c:263 sg2044_spifmc_write() warn: unsigned 'ret' is never less than zero.

vim +/ret +243 drivers/spi/spi-sg2044-nor.c

   212	
   213	static ssize_t sg2044_spifmc_write(struct sg2044_spifmc *spifmc,
   214					   const struct spi_mem_op *op)
   215	{
   216		size_t xfer_size;
   217		const u8 *dout = op->data.buf.out;
   218		int i, offset;
   219		size_t ret;
   220		u32 reg;
   221	
   222		reg = sg2044_spifmc_init_reg(spifmc);
   223		reg |= (op->addr.nbytes + op->dummy.nbytes) << SPIFMC_TRAN_CSR_ADDR_BYTES_SHIFT;
   224		reg |= SPIFMC_TRAN_CSR_FIFO_TRG_LVL_8_BYTE;
   225		reg |= SPIFMC_TRAN_CSR_WITH_CMD;
   226		reg |= SPIFMC_TRAN_CSR_TRAN_MODE_TX;
   227	
   228		writel(0, spifmc->io_base + SPIFMC_FIFO_PT);
   229		writeb(op->cmd.opcode, spifmc->io_base + SPIFMC_FIFO_PORT);
   230	
   231		for (i = op->addr.nbytes - 1; i >= 0; i--)
   232			writeb((op->addr.val >> i * 8) & 0xff, spifmc->io_base + SPIFMC_FIFO_PORT);
   233	
   234		for (i = 0; i < op->dummy.nbytes; i++)
   235			writeb(0xff, spifmc->io_base + SPIFMC_FIFO_PORT);
   236	
   237		writel(0, spifmc->io_base + SPIFMC_INT_STS);
   238		writel(op->data.nbytes, spifmc->io_base + SPIFMC_TRAN_NUM);
   239		reg |= SPIFMC_TRAN_CSR_GO_BUSY;
   240		writel(reg, spifmc->io_base + SPIFMC_TRAN_CSR);
   241	
   242		ret = sg2044_spifmc_wait_xfer_size(spifmc, 0);
 > 243		if (ret < 0)
   244			return ret;
   245	
   246		writel(0, spifmc->io_base + SPIFMC_FIFO_PT);
   247	
   248		offset = 0;
   249		while (offset < op->data.nbytes) {
   250			xfer_size = min_t(size_t, SPIFMC_MAX_FIFO_DEPTH, op->data.nbytes - offset);
   251	
   252			ret = sg2044_spifmc_wait_xfer_size(spifmc, 0);
   253			if (ret < 0)
   254				return ret;
   255	
   256			for (i = 0; i < xfer_size; i++)
   257				writeb(dout[i + offset], spifmc->io_base + SPIFMC_FIFO_PORT);
   258	
   259			offset += xfer_size;
   260		}
   261	
   262		ret = sg2044_spifmc_wait_int(spifmc, SPIFMC_INT_TRAN_DONE);
   263		if (ret < 0)
   264			return ret;
   265	
   266		writel(0, spifmc->io_base + SPIFMC_FIFO_PT);
   267	
   268		return 0;
   269	}
   270	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux