From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA2E52CA2 for ; Thu, 22 Sep 2022 19:55:54 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id m22so1731713lfg.0 for ; Thu, 22 Sep 2022 12:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=xIPmujiyfWOajBJjBvgxKpjBtB45GgxFhMLGKXXMv8c=; b=ltfdWf65dwpZLGG8ThMq+jdLgqvJdSowvT+mlXGI3G6MEqQch/I/r90ti2743IU4kd qmarAkEahCduHlz00QlQjcwKbyGjJWNlgOKZ+PoDtbnY0cDunikVJNz5sNfF/+KytXtp AU4B+XbZVAE2qWWf0NAtE1K780ooN2MtnPFZFhmxCg6g3CcTuYUkqApdrewX+b4bT41D xW1PB4j0z4Y4vAs5m8MEmGM7KqfDgV15GXtNQNu5N+QEXIAu13IZIlsgsOP+0KWbBlVW gpstIYxmNdV0CqXLgHAyvGzue/HQoExCm3gZmWNR2RBb3Ms80k48nPZfgc/bXv4aouwm A+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=xIPmujiyfWOajBJjBvgxKpjBtB45GgxFhMLGKXXMv8c=; b=3PKuuOkWioCRHXoywm8jDvJSDMhqSh31LXtYUWH70KI7SPngTwQ8dzN/VOMysKySBM wUzBAtUrVEVz4fW3TmAbna5BHZwU940lqptXtBwjT3mvhs2dqYp7vibgbk5wxmXxVpvW FQyo2wVRe4b4/SfUP1MsUBaaYEU3PFxIIUpFHPjQY0e3+N+uJ6AJPrEi3AFcrNRvDYil 8hRyuTDV3LcJA/yCqYFkhCOINYWrHJ3Mwm6Ij9B2G2gF2zF0jWHkSshz0MZ9KPURLuHs 0pSvvyNKAKlC5l3gp7Awt+T+0cvt9Y8PU+w3Tmzt7n3VO09ysZ5hn3p39YCdzEeupDKX 8Tyg== X-Gm-Message-State: ACrzQf0NtsjX43UDrP0eACBqH2utcF+3S61LpnDHPuf9JtmFzeaMo7Ec MkZ/oBP7FRTzN9xpjWRq1cg= X-Google-Smtp-Source: AMsMyM5+J1LnuXaYj4dCuhVDmlbLEtQBfPA/XoqcT7tSpbnJlBpNwD2Ce58qJvoW4OlXJ2LNgjccog== X-Received: by 2002:ac2:4a61:0:b0:497:ae0c:4f66 with SMTP id q1-20020ac24a61000000b00497ae0c4f66mr1786866lfp.660.1663876552908; Thu, 22 Sep 2022 12:55:52 -0700 (PDT) Received: from gmail.com (82-209-154-112.cust.bredband2.com. [82.209.154.112]) by smtp.gmail.com with ESMTPSA id y18-20020a197512000000b004946aef1814sm1082016lfe.137.2022.09.22.12.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 12:55:51 -0700 (PDT) Date: Thu, 22 Sep 2022 22:01:57 +0200 From: Marcus Folkesson To: Jonathan Cameron Cc: kernel test robot , llvm@lists.linux.dev, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Andy Shevchenko Subject: Re: [jic23-iio:testing 58/58] drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but not used Message-ID: References: <202209220845.GmS9zryR-lkp@intel.com> <20220922115925.00004ec9@huawei.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cabgzS1QBwGhtYbU" Content-Disposition: inline In-Reply-To: <20220922115925.00004ec9@huawei.com> --cabgzS1QBwGhtYbU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 wrote: >=20 > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git t= esting > > head: d4e1a549566b9ea8b96e80f0cdcbe99714ac256e > > commit: d4e1a549566b9ea8b96e80f0cdcbe99714ac256e [58/58] iio: adc: mcp3= 911: add support to set PGA > > config: x86_64-randconfig-a012 > > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f2= 8c006a5895fc0e329fe15fead81e37457cb1d1) > > reproduce (this is a W=3D1 build): > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/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=3Dd4e1a549566b9ea8b96e80f0cdcbe99714ac256e > > git remote add jic23-iio https://git.kernel.org/pub/scm/linux/k= ernel/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=3D$HOME/0day COMPILER=3Dclang make.cross = W=3D1 O=3Dbuild_dir ARCH=3Dx86_64 SHELL=3D/bin/bash drivers/iio/adc/ > >=20 > > If you fix the issue, kindly add following tag where applicable > > | Reported-by: kernel test robot > >=20 > > All warnings (new ones prefixed by >>): > >=20 > > >> drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but no= t used [-Wunused-but-set-variable] =20 > > int tmp0, tmp1; > > ^ > > 1 warning generated. > >=20 > >=20 > > vim +/tmp0 +274 drivers/iio/adc/mcp3911.c > >=20 > > 268=09 > > 269 static int mcp3911_calc_scale_table(struct mcp3911 *adc) > > 270 { > > 271 u32 ref =3D MCP3911_INT_VREF_MV; > > 272 u32 div; > > 273 int ret; > > > 274 int tmp0, tmp1; =20 > > 275 s64 tmp2; > > 276=09 > > 277 if (adc->vref) { > > 278 ret =3D 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=09 > > 286 ref =3D ret / 1000; > > 287 } > > 288=09 > > 289 /* > > 290 * For 24-bit Conversion > > 291 * Raw =3D ((Voltage)/(Vref) * 2^23 * Gain * 1.5 > > 292 * Voltage =3D Raw * (Vref)/(2^23 * Gain * 1.5) > > 293 * > > 294 * ref =3D Reference voltage > > 295 * div =3D (2^23 * 1.5 * gain) =3D 12582912 * gain > > 296 */ > > 297 for (int i =3D 0; i < MCP3911_NUM_SCALES; i++) { > > 298 div =3D 12582912 * BIT(i); > > 299 tmp2 =3D div_s64((s64)ref * 1000000000LL, div); > > 300 tmp1 =3D div; > > 301 tmp0 =3D (int)div_s64_rem(tmp2, 1000000000, &tmp1); >=20 > Marcus,=20 > I'm guessing the intent here is just to get the remainder. =20 > Hence fix is probably just to drop tmp0? Yes, the intention was to keep the remainder. When I looked at the code a second time, tmp2 will have the same value as the reminder as the division does not make sense. So tmp1 and tmp0 is removed in the v7 patch. /Marcus=20 >=20 > If you confirm that I'll tweak the commit to do that. >=20 > Jonathan >=20 >=20 > > 302=09 > > 303 mcp3911_scale_table[i][0] =3D 0; > > 304 mcp3911_scale_table[i][1] =3D tmp1; > > 305 } > > 306=09 > > 307 return 0; > > 308 } > > 309=09 > >=20 >=20 --cabgzS1QBwGhtYbU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEBVGi6LZstU1kwSxliIBOb1ldUjIFAmMsvzAACgkQiIBOb1ld UjIhMg//fY1JE1gXpqqZMVu6OH/FV2bbm3KH1KSSqrBNURwXLpuoeXn76VW54KL+ oXE8/+XV70w3asz6zJW6Jg2JIi4B8MPloc5b1CA+LQgUjjvgNd7xsNd0XjkOMcQJ UECmIT3PabdCJM5WMaJnASjh3ULilgmFc3gho7eJ3Q4ZpUIg8hMqc9rD3I5BH9EH c0qkR+mfjSKVlnxMKUsayPF39UDRvMOM8wqCNaca7V9+9IjmndV6NhiGtw36KIj6 4ZeynNmL1+t3AaJHYWCunSjMRje2AMk9NNwd3/hkGTOcfBaKKoR9medSVH0FJtKB rLPiT7IgKGmJRifAoHGX97JuSI/MmzyGdVM7HC3NSMe66IIllcCKdLejJtYERM6A y6TrtugmRtZhfGLQ7o8cBowS4XkP/GVdeXODFOg+xKK8msUqojPcuVX+LSkAz7Yu vseyvLSdHnNFC8eVZJv8vW+KIpv1GPAcTe6IgrvR/WPNVSBCDafwyFvGlA8ujSTb xsnMCH0WPW3uDIC42otbT6tignprcCYMu2hISp22gXYZ8miDacAPu0Jw+6JsZme+ 8nLjMIllpL3MYyfE5zLHmSKLXjQKzF2/mSg6wa/VOD0SlTXJf7W6diVW4mxSBs7Q pvFP2Hw0pIKsM9KVGP4tbqL9XmAuaWvi1ZPAnYSmJHwMgcv94ac= =u9Lw -----END PGP SIGNATURE----- --cabgzS1QBwGhtYbU-- From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7633143914039579004==" MIME-Version: 1.0 From: Marcus Folkesson To: kbuild-all@lists.01.org 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 22:01:57 +0200 Message-ID: In-Reply-To: <20220922115925.00004ec9@huawei.com> List-Id: --===============7633143914039579004== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 wrote: > = > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git t= esting > > head: d4e1a549566b9ea8b96e80f0cdcbe99714ac256e > > commit: d4e1a549566b9ea8b96e80f0cdcbe99714ac256e [58/58] iio: adc: mcp3= 911: add support to set PGA > > config: x86_64-randconfig-a012 > > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f2= 8c006a5895fc0e329fe15fead81e37457cb1d1) > > reproduce (this is a W=3D1 build): > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/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=3Dd4e1a549566b9ea8b96e80f0cdcbe99714ac256e > > git remote add jic23-iio https://git.kernel.org/pub/scm/linux/k= ernel/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=3D$HOME/0day COMPILER=3Dclang make.cross = W=3D1 O=3Dbuild_dir ARCH=3Dx86_64 SHELL=3D/bin/bash drivers/iio/adc/ > > = > > If you fix the issue, kindly add following tag where applicable > > | Reported-by: kernel test robot > > = > > All warnings (new ones prefixed by >>): > > = > > >> drivers/iio/adc/mcp3911.c:274:6: warning: variable 'tmp0' set but no= t 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 =3D MCP3911_INT_VREF_MV; > > 272 u32 div; > > 273 int ret; > > > 274 int tmp0, tmp1; = > > 275 s64 tmp2; > > 276 = > > 277 if (adc->vref) { > > 278 ret =3D 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 =3D ret / 1000; > > 287 } > > 288 = > > 289 /* > > 290 * For 24-bit Conversion > > 291 * Raw =3D ((Voltage)/(Vref) * 2^23 * Gain * 1.5 > > 292 * Voltage =3D Raw * (Vref)/(2^23 * Gain * 1.5) > > 293 * > > 294 * ref =3D Reference voltage > > 295 * div =3D (2^23 * 1.5 * gain) =3D 12582912 * gain > > 296 */ > > 297 for (int i =3D 0; i < MCP3911_NUM_SCALES; i++) { > > 298 div =3D 12582912 * BIT(i); > > 299 tmp2 =3D div_s64((s64)ref * 1000000000LL, div); > > 300 tmp1 =3D div; > > 301 tmp0 =3D (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? Yes, the intention was to keep the remainder. When I looked at the code a second time, tmp2 will have the same value as the reminder as the division does not make sense. So tmp1 and tmp0 is removed in the v7 patch. /Marcus = > = > If you confirm that I'll tweak the commit to do that. > = > Jonathan > = > = > > 302 = > > 303 mcp3911_scale_table[i][0] =3D 0; > > 304 mcp3911_scale_table[i][1] =3D tmp1; > > 305 } > > 306 = > > 307 return 0; > > 308 } > > 309 = > > = >=20 --===============7633143914039579004== Content-Type: application/pgp-signature MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVCVkdpNkxac3RV MWt3U3hsaUlCT2IxbGRVaklGQW1Nc3Z6QUFDZ2tRaUlCT2IxbGQKVWpJaE1nLy9mWTFKRTFnWHBx cVpNVnU2T0gvRlYyYmJtM0tIMUtTU3FyQk5VUndYTHB1b2VYbjc2Vlc1NEtMKwpvWEU4LytYVjcw dzNhc3o2ekpXNkpnMkpJaTRCOE1QbG9jNWIxQ0ErTFFnVWpqdmdOZDd4c05kMFhqa09NY1FKClVF Q21JVDNQYWJkQ0pNNVdNYUpuQVNqaDNVTGlsZ21GYzNnaG83ZUozUTRacFVJZzhoTXFjOXJEM0k1 Qkg5RUgKYzBxa1IrbWZqU0tWbG54TUtVc2F5UEYzOVVEUnZNT004d3FDTmFjYTdWOSs5SWptbmRW Nk5oaUd0dzM2S0lqNgo0WmV5bk5tTDErdDNBYUpIWVdDdW5Tak1SamUyQU1rOU5Od2QzL2hrR1RP Y2ZCYUtLb1I5bWVkU1ZIMEZKdEtCCnJMUGlUN0lnS0dtSlJpZkFvSEdYOTdKdVNJL01tenlHZFZN N0hDM05TTWU2NklJbGxjQ0tkTGVqSnRZRVJNNkEKeTZUcnR1Z21SdFpoZkdMUTdvOGNCb3dTNFhr UC9HVmRlWE9ERk9nK3hLSzhtc1Vxb2pQY3VWWCtMU2tBejdZdQp2c2V5dkxTZEhuTkZDOGVWWkp2 OHZXK0tJcHYxR1BBY1RlNklncnZSL1dQTlZTQkNEYWZ3eUZ2R2xBOHVqU1RiCnhzbk1DSDBXUFcz dURJQzQyb3RiVDZ0aWducHJjQ1lNdTJoSVNwMjJnWFlaOG1pRGFjQVB1MEp3KzZKc1ptZSsKOG5M ak1JbGxwTDNNWXlmRTV6TEhtU0tMWGpRS3pGMi9tU2c2d2EvVk9EMFNsVFhKZjdXNmRpVlc0bXhT QnM3UQpwdkZQMkh3MHBJS3NNOUtWR1A0dGJxTDlYbUF1YVd2aTFaUEFuWVNtSkh3TWdjdjk0YWM9 Cj11OUx3Ci0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============7633143914039579004==--