All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: <oe-kbuild@lists.linux.dev>,
	shuaijie wang <wangshuaijie@awinic.com>, <lkp@intel.com>,
	<oe-kbuild-all@lists.linux.dev>
Subject: Re: [jic23-iio:testing 268/269] drivers/iio/proximity/aw96103.c:475 aw96103_reg_version_comp() warn: iterator 'i' not incremented
Date: Wed, 4 Sep 2024 10:28:45 +0100	[thread overview]
Message-ID: <20240904102845.00002fbf@Huawei.com> (raw)
In-Reply-To: <97914f05-0881-4c33-9acb-117f89dba35c@stanley.mountain>

On Tue, 3 Sep 2024 22:31:59 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
> head:   fa533227a89a1d8509a1ad4e93a35d683a77aa23
> commit: a369e1d1a10790f63b4b858dc74b53730146754f [268/269] iio: proximity: aw96103: Add support for aw96103/aw96105 proximity sensor
> config: riscv-randconfig-r072-20240901 (https://download.01.org/0day-ci/archive/20240904/202409040114.Rpkwt3gm-lkp@intel.com/config)
> compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 6f682c26b04f0b349c4c473756cb8625b4f37c6d)
> 
> 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>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202409040114.Rpkwt3gm-lkp@intel.com/
> 
> smatch warnings:
> drivers/iio/proximity/aw96103.c:475 aw96103_reg_version_comp() warn: iterator 'i' not incremented

True enough.  Odd code structure.
There shouldn't be an early return in the good path.

I'll fix up or Shuajie, if you want to send a patch that's fine too.

Jonathan


> 
> vim +/i +475 drivers/iio/proximity/aw96103.c
> 
> a369e1d1a10790f shuaijie wang 2024-08-27  457  static int aw96103_reg_version_comp(struct aw96103 *aw96103,
> a369e1d1a10790f shuaijie wang 2024-08-27  458  				    struct aw_bin *aw_bin)
> a369e1d1a10790f shuaijie wang 2024-08-27  459  {
> a369e1d1a10790f shuaijie wang 2024-08-27  460  	u32 blfilt1_data, fw_ver;
> a369e1d1a10790f shuaijie wang 2024-08-27  461  	unsigned char i;
> a369e1d1a10790f shuaijie wang 2024-08-27  462  	int ret;
> a369e1d1a10790f shuaijie wang 2024-08-27  463  
> a369e1d1a10790f shuaijie wang 2024-08-27  464  	ret = regmap_read(aw96103->regmap, AW96103_REG_FWVER2, &fw_ver);
> a369e1d1a10790f shuaijie wang 2024-08-27  465  	if (ret)
> a369e1d1a10790f shuaijie wang 2024-08-27  466  		return ret;
> a369e1d1a10790f shuaijie wang 2024-08-27  467  	/*
> a369e1d1a10790f shuaijie wang 2024-08-27  468  	 * If the chip version is AW96103A and the loaded register
> a369e1d1a10790f shuaijie wang 2024-08-27  469  	 * configuration file is for AW96103, special handling of the
> a369e1d1a10790f shuaijie wang 2024-08-27  470  	 * AW96103_REG_BLRSTRNG_CH0 register is required.
> a369e1d1a10790f shuaijie wang 2024-08-27  471  	 */
> a369e1d1a10790f shuaijie wang 2024-08-27  472  	if ((fw_ver != AW96103A) || (aw_bin->chip_type[7] != '\0'))
> a369e1d1a10790f shuaijie wang 2024-08-27  473  		return 0;
> a369e1d1a10790f shuaijie wang 2024-08-27  474  
> a369e1d1a10790f shuaijie wang 2024-08-27 @475  	for (i = 0; i < aw96103->max_channels; i++) {
> 
> This loop only iterates one time.
> 
> a369e1d1a10790f shuaijie wang 2024-08-27  476  		ret = regmap_read(aw96103->regmap,
> a369e1d1a10790f shuaijie wang 2024-08-27  477  			AW96103_REG_BLFILT_CH0 + (AW96103_BLFILT_CH_STEP * i),
> a369e1d1a10790f shuaijie wang 2024-08-27  478  			&blfilt1_data);
> a369e1d1a10790f shuaijie wang 2024-08-27  479  		if (ret)
> a369e1d1a10790f shuaijie wang 2024-08-27  480  			return ret;
> a369e1d1a10790f shuaijie wang 2024-08-27  481  		if (FIELD_GET(AW96103_BLERRTRIG_MASK, blfilt1_data) != 1)
> a369e1d1a10790f shuaijie wang 2024-08-27  482  			return 0;
> a369e1d1a10790f shuaijie wang 2024-08-27  483  
> a369e1d1a10790f shuaijie wang 2024-08-27  484  		return regmap_update_bits(aw96103->regmap,
> a369e1d1a10790f shuaijie wang 2024-08-27  485  			AW96103_REG_BLRSTRNG_CH0 + (AW96103_BLFILT_CH_STEP * i),
> a369e1d1a10790f shuaijie wang 2024-08-27  486  			AW96103_BLRSTRNG_MASK, 1 << i);
> a369e1d1a10790f shuaijie wang 2024-08-27  487  	}
> a369e1d1a10790f shuaijie wang 2024-08-27  488  
> a369e1d1a10790f shuaijie wang 2024-08-27  489  	return 0;
> a369e1d1a10790f shuaijie wang 2024-08-27  490  }
> 


  reply	other threads:[~2024-09-04  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03 19:31 [jic23-iio:testing 268/269] drivers/iio/proximity/aw96103.c:475 aw96103_reg_version_comp() warn: iterator 'i' not incremented Dan Carpenter
2024-09-04  9:28 ` Jonathan Cameron [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-03 17:30 kernel test robot

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=20240904102845.00002fbf@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dan.carpenter@linaro.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=wangshuaijie@awinic.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.