llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: [jic23-iio:testing 58/58] drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but not used
Date: Thu, 22 Sep 2022 17:41:25 +0200	[thread overview]
Message-ID: <YyyCJX374uWYrPTN@gmail.com> (raw)
In-Reply-To: <20220922115925.00004ec9@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 4146 bytes --]

On Thu, Sep 22, 2022 at 11:59:25AM +0100, Jonathan Cameron wrote:
> On Thu, 22 Sep 2022 08:50:17 +0800
> kernel test robot <lkp@intel.com> wrote:
> 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
> > head:   d4e1a549566b9ea8b96e80f0cdcbe99714ac256e
> > commit: d4e1a549566b9ea8b96e80f0cdcbe99714ac256e [58/58] iio: adc: mcp3911: add support to set PGA
> > config: x86_64-randconfig-a012
> > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=d4e1a549566b9ea8b96e80f0cdcbe99714ac256e
> >         git remote add jic23-iio https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> >         git fetch --no-tags jic23-iio testing
> >         git checkout d4e1a549566b9ea8b96e80f0cdcbe99714ac256e
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/iio/adc/
> > 
> > If you fix the issue, kindly add following tag where applicable
> > | Reported-by: kernel test robot <lkp@intel.com>
> > 
> > All warnings (new ones prefixed by >>):
> > 
> > >> drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but not used [-Wunused-but-set-variable]  
> >            int tmp0, tmp1;
> >                ^
> >    1 warning generated.
> > 
> > 
> > vim +/tmp0 +274 drivers/iio/adc/mcp3911.c
> > 
> >    268	
> >    269	static int mcp3911_calc_scale_table(struct mcp3911 *adc)
> >    270	{
> >    271		u32 ref = MCP3911_INT_VREF_MV;
> >    272		u32 div;
> >    273		int ret;
> >  > 274		int tmp0, tmp1;  
> >    275		s64 tmp2;
> >    276	
> >    277		if (adc->vref) {
> >    278			ret = regulator_get_voltage(adc->vref);
> >    279			if (ret < 0) {
> >    280				dev_err(&adc->spi->dev,
> >    281					"failed to get vref voltage: %d\n",
> >    282				       ret);
> >    283				return ret;
> >    284			}
> >    285	
> >    286			ref = ret / 1000;
> >    287		}
> >    288	
> >    289		/*
> >    290		 * For 24-bit Conversion
> >    291		 * Raw = ((Voltage)/(Vref) * 2^23 * Gain * 1.5
> >    292		 * Voltage = Raw * (Vref)/(2^23 * Gain * 1.5)
> >    293		 *
> >    294		 * ref = Reference voltage
> >    295		 * div = (2^23 * 1.5 * gain) = 12582912 * gain
> >    296		 */
> >    297		for (int i = 0; i < MCP3911_NUM_SCALES; i++) {
> >    298			div = 12582912 * BIT(i);
> >    299			tmp2 = div_s64((s64)ref * 1000000000LL, div);
> >    300			tmp1 = div;
> >    301			tmp0 = (int)div_s64_rem(tmp2, 1000000000, &tmp1);
> 
> Marcus, 
> I'm guessing the intent here is just to get the remainder.  
> Hence fix is probably just to drop tmp0?
> 
> If you confirm that I'll tweak the commit to do that.
> 
> Jonathan


Hum, Yes. I actually think we can drop div, tmp0, tmp1 and tmp2.
I think they are remnats for when I did the calculation differently.

Do you want me to update the patchset?

 static int mcp3911_calc_scale_table(struct mcp3911 *adc)
 {
        u32 ref = MCP3911_INT_VREF_MV;
-       u32 div;
        int ret;
-       int tmp0, tmp1;
-       s64 tmp2;


....



        for (int i = 0; i < MCP3911_NUM_SCALES; i++) {
-               div = 12582912 * BIT(i);
-               tmp2 = div_s64((s64)ref * 1000000000LL, div);
-               tmp1 = div;
-               tmp0 = (int)div_s64_rem(tmp2, 1000000000, &tmp1);
-
                mcp3911_scale_table[i][0] = 0;
-               mcp3911_scale_table[i][1] = tmp1;
+               mcp3911_scale_table[i][1] = 12582912 * BIT(i);
        }


/Marcus

> 
> 
> >    302	
> >    303			mcp3911_scale_table[i][0] = 0;
> >    304			mcp3911_scale_table[i][1] = tmp1;
> >    305		}
> >    306	
> >    307		return 0;
> >    308	}
> >    309	
> > 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-09-22 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  0:50 [jic23-iio:testing 58/58] drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but not used kernel test robot
2022-09-22 10:59 ` Jonathan Cameron
2022-09-22 15:41   ` Marcus Folkesson [this message]
2022-09-22 16:29     ` Jonathan Cameron
2022-09-22 16:40       ` Jonathan Cameron
2022-09-22 20:01   ` Marcus Folkesson

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=YyyCJX374uWYrPTN@gmail.com \
    --to=marcus.folkesson@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@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;
as well as URLs for NNTP newsgroup(s).