Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [ambarus:mtd/spimem-odd-octal-ops 3/3] drivers/mtd/spi-nor/core.c:2179: warning: bad line:
@ 2025-02-03 12:55 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-03 12:55 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: llvm, oe-kbuild-all, Tudor Ambarus, Michael Walle,
	Takahiro Kuwano

tree:   https://github.com/ambarus/linux-0day mtd/spimem-odd-octal-ops
head:   2fe5adeaab12de539cebb3a3d3fe321f4d267d53
commit: 2fe5adeaab12de539cebb3a3d3fe321f4d267d53 [3/3] mtd: spi-nor: core: avoid odd length/address writes in 8D-8D-8D mode
config: hexagon-randconfig-001-20250203 (https://download.01.org/0day-ci/archive/20250203/202502032020.x4VCTYwd-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 355d0b186f178668b103068537e517f3d52ad639)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250203/202502032020.x4VCTYwd-lkp@intel.com/reproduce)

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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502032020.x4VCTYwd-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/mtd/spi-nor/core.c:2179: warning: bad line: 


vim +2179 drivers/mtd/spi-nor/core.c

  2171	
  2172	/**
  2173	 * spi_nor_dtr_write() - write data to flash memory by avoiding odd lengths and
  2174	 * addresses.
  2175	 * @nor:        pointer to 'struct spi_nor'
  2176	 * @to:         offset to write to
  2177	 * @len:        number of bytes to write
  2178	 * @buf:        pointer to src buffer
> 2179	
  2180	 * On DTR capable flashes the writes cannot start or end at an odd address in
  2181	 * DTR mode. Extra 0xff bytes need to be appended or prepended to make sure the
  2182	 * start address and end address are even. 0xff is used because on NOR flashes
  2183	 * a program operation can only flip bits from 1 to 0, not the other way round.
  2184	 * 0 to 1 flip needs to happen via erases.
  2185	 *
  2186	 * Return: number of bytes written successfully, -errno otherwise.
  2187	 */
  2188	static int spi_nor_dtr_write(struct spi_nor *nor, loff_t to, size_t len,
  2189				     const u8 *buf)
  2190	{
  2191		u32 page_size = nor->params->page_size;
  2192		size_t bytes_written;
  2193		loff_t start, end;
  2194		u8 *tmp_buf;
  2195		int ret;
  2196	
  2197		if (IS_ALIGNED(to, 2) && IS_ALIGNED(len, 2))
  2198			return spi_nor_write_data(nor, to, len, buf);
  2199	
  2200		tmp_buf = kmalloc(page_size, GFP_KERNEL);
  2201		if (!tmp_buf)
  2202			return -ENOMEM;
  2203	
  2204		memset(tmp_buf, 0xff, page_size);
  2205	
  2206		start = round_down(to, 2);
  2207		end = round_up(to + len, 2);
  2208	
  2209		memcpy(tmp_buf + (to - start), buf, len);
  2210	
  2211		ret = spi_nor_write_data(nor, start, end - start, tmp_buf);
  2212		if (ret == 0) {
  2213			ret = -EIO;
  2214			goto out;
  2215		}
  2216		if (ret < 0)
  2217			goto out;
  2218	
  2219		/*
  2220		 * More bytes are written than actually requested, but that number can't
  2221		 * be reported to the calling function or it will confuse its
  2222		 * calculations. Calculate how many of the _requested_ bytes were
  2223		 * written.
  2224		 */
  2225		bytes_written = ret;
  2226	
  2227		if (to != start)
  2228			ret -= to - start;
  2229	
  2230		/*
  2231		 * Only account for extra bytes at the end if they were actually
  2232		 * written. For example, if for some reason the controller could only
  2233		 * complete a partial write then the adjustment for the extra bytes at
  2234		 * the end is not needed.
  2235		 */
  2236		if (start + bytes_written == end)
  2237			ret -= end - (to + len);
  2238	
  2239		/* Should not be possible. */
  2240		if (ret < 0)
  2241			ret = -EIO;
  2242	
  2243	out:
  2244		kfree(tmp_buf);
  2245		return ret;
  2246	}
  2247	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-03 12:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 12:55 [ambarus:mtd/spimem-odd-octal-ops 3/3] drivers/mtd/spi-nor/core.c:2179: warning: bad line: kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox