Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Alex Elder <elder@riscstar.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Mark Brown <broonie@kernel.org>,
	Guodong Xu <guodong@riscstar.com>
Subject: [broonie-ci:spi-7.2 9/9] drivers/spi/spi-spacemit-k1.c:393:31: warning: overflow in expression; result is -589934592 with type 'long'
Date: Tue, 05 May 2026 04:12:18 +0800	[thread overview]
Message-ID: <202605050437.RS6mmV2b-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/ci.git spi-7.2
head:   efcd8b9d111177d48c841d09beca43b15d5b9e5f
commit: efcd8b9d111177d48c841d09beca43b15d5b9e5f [9/9] spi: spacemit: introduce SpacemiT K1 SPI controller driver
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20260505/202605050437.RS6mmV2b-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260505/202605050437.RS6mmV2b-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/202605050437.RS6mmV2b-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/spi/spi-spacemit-k1.c:393:31: warning: overflow in expression; result is -589934592 with type 'long' [-Winteger-overflow]
     393 |         nsec_per_word = NSEC_PER_SEC * BITS_PER_BYTE * drv_data->bytes;
         |                                      ^
   1 warning generated.


vim +/long +393 drivers/spi/spi-spacemit-k1.c

   356	
   357	/* Set the transfer speed; the SPI core code ensures it is supported */
   358	static int k1_spi_set_speed(struct k1_spi_driver_data *drv_data,
   359				    struct spi_transfer *transfer)
   360	{
   361		struct clk *clk = drv_data->clk;
   362		u64 nsec_per_word;
   363		u64 bus_ticks;
   364		u32 timeout;
   365		u32 val;
   366		int ret;
   367	
   368		ret = clk_set_rate(clk, transfer->speed_hz);
   369		if (ret)
   370			return ret;
   371	
   372		drv_data->rate = clk_get_rate(clk);
   373	
   374		/* No need for RX FIFO timeout if we're not receiving anything */
   375		if (!transfer->rx_buf)
   376			return 0;
   377	
   378		/*
   379		 * Compute the RX FIFO inactivity timeout value that should be used.
   380		 * The inactivity timer restarts with each word that lands in the
   381		 * FIFO.  If several "word transfer times" pass without any new data
   382		 * in the RX FIFO, we might as well read what's there.
   383		 *
   384		 * The rate at which words land in the FIFO is determined by the
   385		 * word size and the transfer rate.  One bit is transferred per
   386		 * clock tick, and 8 (or 16 or 32) bits are transferred per word.
   387		 *
   388		 * So we can get word transfer time (in nanoseconds) from:
   389		 *   nsec_per_tick = NSEC_PER_SEC / drv_data->rate;
   390		 *   ticks_per_word = BITS_PER_BYTE * drv_data->bytes;
   391		 * We do the divide last for better accuracy.
   392		 */
 > 393		nsec_per_word = NSEC_PER_SEC * BITS_PER_BYTE * drv_data->bytes;
   394		nsec_per_word = DIV_ROUND_UP_ULL(nsec_per_word, drv_data->rate);
   395	
   396		/*
   397		 * The timeout (which we'll set to three word transfer times) is
   398		 * expressed as a number of APB clock ticks.
   399		 *   bus_ticks = 3 * nsec * (drv_data->bus_rate / NSEC_PER_SEC)
   400		 */
   401		bus_ticks = 3 * nsec_per_word * drv_data->bus_rate;
   402		timeout = DIV_ROUND_UP_ULL(bus_ticks, NSEC_PER_SEC);
   403	
   404		/* Set the RX timeout period (required for both DMA and PIO) */
   405		val = FIELD_PREP(SSP_TIMEOUT_MASK, timeout);
   406		writel(val, drv_data->base + SSP_TIMEOUT);
   407	
   408		return 0;
   409	}
   410	

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

                 reply	other threads:[~2026-05-04 20:13 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=202605050437.RS6mmV2b-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=broonie@kernel.org \
    --cc=elder@riscstar.com \
    --cc=guodong@riscstar.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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