From: kernel test robot <lkp@intel.com>
To: Pratyush Yadav <p.yadav@ti.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Michael Walle <michael@walle.cc>,
Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Subject: [ambarus:mtd/spimem-odd-octal-ops 3/3] drivers/mtd/spi-nor/core.c:2179: warning: bad line:
Date: Mon, 3 Feb 2025 20:55:02 +0800 [thread overview]
Message-ID: <202502032020.x4VCTYwd-lkp@intel.com> (raw)
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
reply other threads:[~2025-02-03 12:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202502032020.x4VCTYwd-lkp@intel.com \
--to=lkp@intel.com \
--cc=Takahiro.Kuwano@infineon.com \
--cc=llvm@lists.linux.dev \
--cc=michael@walle.cc \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=p.yadav@ti.com \
--cc=tudor.ambarus@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox