* drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
@ 2021-11-06 9:20 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-11-06 9:20 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 27424 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Miquel Raynal <miquel.raynal@bootlin.com>
CC: 0day robot <lkp@intel.com>
tree: https://github.com/0day-ci/linux/commits/Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
head: 82403933ab13283e98041a4c285420988531362c
commit: 1e80dcadd79f6dec7346dc596fbafd508ea2844e iio: adc: max1027: Minimize the number of converted channels
date: 6 weeks ago
:::::: branch date: 6 weeks ago
:::::: commit date: 6 weeks ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/1e80dcadd79f6dec7346dc596fbafd508ea2844e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
git checkout 1e80dcadd79f6dec7346dc596fbafd508ea2844e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
info.offset = plane << fls(nand->memorg.pagesize);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/nand/spi/core.c:850:22: note: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'unsigned int'
info.offset = plane << fls(nand->memorg.pagesize);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/usb/core/message.c:1709:2: warning: Value stored to 'retval' is never read [clang-analyzer-deadcode.DeadStores]
retval = 0;
^ ~
drivers/usb/core/message.c:1709:2: note: Value stored to 'retval' is never read
retval = 0;
^ ~
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
drivers/usb/core/driver.c:1675:2: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
status = pm_runtime_put_sync_autosuspend(&udev->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/driver.c:1675:2: note: Value stored to 'status' is never read
status = pm_runtime_put_sync_autosuspend(&udev->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/driver.c:1737:2: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
status = pm_runtime_put_sync(&intf->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/driver.c:1737:2: note: Value stored to 'status' is never read
status = pm_runtime_put_sync(&intf->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/driver.c:1765:2: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
status = pm_runtime_put(&intf->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/driver.c:1765:2: note: Value stored to 'status' is never read
status = pm_runtime_put(&intf->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
drivers/usb/core/file.c:160:6: warning: Value stored to 'minor_base' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
int minor_base = class_driver->minor_base;
^~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/core/file.c:160:6: note: Value stored to 'minor_base' during its initialization is never read
int minor_base = class_driver->minor_base;
^~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
13 warnings generated.
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1259:3: warning: Value stored to 'tmp' is never read [clang-analyzer-deadcode.DeadStores]
tmp = REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC,
^
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1259:3: note: Value stored to 'tmp' is never read
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1264:3: warning: Value stored to 'tmp' is never read [clang-analyzer-deadcode.DeadStores]
tmp = REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC,
^
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1264:3: note: Value stored to 'tmp' is never read
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:2970:3: warning: Value stored to 'tmp' is never read [clang-analyzer-deadcode.DeadStores]
tmp = RREG32(mmSRBM_SOFT_RESET);
^
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:2970:3: note: Value stored to 'tmp' is never read
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/iio/adc/max1027.c:265:8: warning: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal).
Optimal fields order:
reg,
info,
spi,
trig,
buffer,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/adc/max1027.c:265:8: note: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). Optimal fields order: reg, info, spi, trig, buffer, lock, consider reordering the fields or adding explicit padding members
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
>> drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
drivers/iio/adc/max1027.c:399:6: note: Assuming 'state' is true
if (state) {
^~~~~
drivers/iio/adc/max1027.c:399:2: note: Taking true branch
if (state) {
^
drivers/iio/adc/max1027.c:404:7: note: Assuming 'ret' is >= 0
if (ret < 0)
^~~~~~~
drivers/iio/adc/max1027.c:404:3: note: Taking false branch
if (ret < 0)
^
drivers/iio/adc/max1027.c:412:14: note: The result of the left shift is undefined because the left operand is negative
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
drivers/w1/slaves/w1_therm.c:1252:5: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = -EIO;
^ ~~~~
drivers/w1/slaves/w1_therm.c:1252:5: note: Value stored to 'ret' is never read
ret = -EIO;
^ ~~~~
drivers/w1/slaves/w1_therm.c:1799:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
strcpy(p_args, buf);
^~~~~~
drivers/w1/slaves/w1_therm.c:1799:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
strcpy(p_args, buf);
^~~~~~
drivers/w1/slaves/w1_therm.c:2090:22: warning: The right operand of '==' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
if (sl->reg_num.id == reg_num->id)
^ ~~~~~~~~~~~
drivers/w1/slaves/w1_therm.c:2067:6: note: Assuming the condition is false
if (w1_reset_bus(sl->master))
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/w1/slaves/w1_therm.c:2067:2: note: Taking false branch
if (w1_reset_bus(sl->master))
^
drivers/w1/slaves/w1_therm.c:2077:6: note: Assuming 'ack' is equal to W1_42_SUCCESS_CONFIRM_BYTE
if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/w1/slaves/w1_therm.c:2077:2: note: Taking false branch
if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
^
drivers/w1/slaves/w1_therm.c:2081:2: note: Loop condition is true. Entering loop body
for (i = 0; i <= 64; i++) {
^
drivers/w1/slaves/w1_therm.c:2082:7: note: Assuming the condition is false
if (w1_reset_bus(sl->master))
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/w1/slaves/w1_therm.c:2082:3: note: Taking false branch
if (w1_reset_bus(sl->master))
^
drivers/w1/slaves/w1_therm.c:2088:7: note: Assuming field 'family' is not equal to W1_42_FINISHED_BYTE
if (reg_num->family == W1_42_FINISHED_BYTE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/w1/slaves/w1_therm.c:2088:3: note: Taking false branch
if (reg_num->family == W1_42_FINISHED_BYTE)
^
drivers/w1/slaves/w1_therm.c:2090:22: note: The right operand of '==' is a garbage value
if (sl->reg_num.id == reg_num->id)
^ ~~~~~~~~~~~
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
vim +412 drivers/iio/adc/max1027.c
fc167f62483325 Philippe Reynes 2014-06-14 264
fc167f62483325 Philippe Reynes 2014-06-14 @265 struct max1027_state {
fc167f62483325 Philippe Reynes 2014-06-14 266 const struct max1027_chip_info *info;
fc167f62483325 Philippe Reynes 2014-06-14 267 struct spi_device *spi;
fc167f62483325 Philippe Reynes 2014-06-14 268 struct iio_trigger *trig;
fc167f62483325 Philippe Reynes 2014-06-14 269 __be16 *buffer;
fc167f62483325 Philippe Reynes 2014-06-14 270 struct mutex lock;
fc167f62483325 Philippe Reynes 2014-06-14 271
fc167f62483325 Philippe Reynes 2014-06-14 272 u8 reg ____cacheline_aligned;
fc167f62483325 Philippe Reynes 2014-06-14 273 };
fc167f62483325 Philippe Reynes 2014-06-14 274
fc167f62483325 Philippe Reynes 2014-06-14 275 static int max1027_read_single_value(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 276 struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14 277 int *val)
fc167f62483325 Philippe Reynes 2014-06-14 278 {
fc167f62483325 Philippe Reynes 2014-06-14 279 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 280 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 281
fc167f62483325 Philippe Reynes 2014-06-14 282 if (iio_buffer_enabled(indio_dev)) {
fc167f62483325 Philippe Reynes 2014-06-14 283 dev_warn(&indio_dev->dev, "trigger mode already enabled");
fc167f62483325 Philippe Reynes 2014-06-14 284 return -EBUSY;
fc167f62483325 Philippe Reynes 2014-06-14 285 }
fc167f62483325 Philippe Reynes 2014-06-14 286
fc167f62483325 Philippe Reynes 2014-06-14 287 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 288 st->reg = MAX1027_SETUP_REG | MAX1027_REF_MODE2 | MAX1027_CKS_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 289 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 290 if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14 291 dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14 292 "Failed to configure setup register\n");
fc167f62483325 Philippe Reynes 2014-06-14 293 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 294 }
fc167f62483325 Philippe Reynes 2014-06-14 295
fc167f62483325 Philippe Reynes 2014-06-14 296 /* Configure conversion register with the requested chan */
fc167f62483325 Philippe Reynes 2014-06-14 297 st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
58b90a8d2c397a Sandhya Bankar 2016-09-24 298 MAX1027_NOSCAN;
58b90a8d2c397a Sandhya Bankar 2016-09-24 299 if (chan->type == IIO_TEMP)
58b90a8d2c397a Sandhya Bankar 2016-09-24 300 st->reg |= MAX1027_TEMP;
fc167f62483325 Philippe Reynes 2014-06-14 301 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 302 if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14 303 dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14 304 "Failed to configure conversion register\n");
fc167f62483325 Philippe Reynes 2014-06-14 305 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 306 }
fc167f62483325 Philippe Reynes 2014-06-14 307
fc167f62483325 Philippe Reynes 2014-06-14 308 /*
fc167f62483325 Philippe Reynes 2014-06-14 309 * For an unknown reason, when we use the mode "10" (write
fc167f62483325 Philippe Reynes 2014-06-14 310 * conversion register), the interrupt doesn't occur every time.
fc167f62483325 Philippe Reynes 2014-06-14 311 * So we just wait 1 ms.
fc167f62483325 Philippe Reynes 2014-06-14 312 */
fc167f62483325 Philippe Reynes 2014-06-14 313 mdelay(1);
fc167f62483325 Philippe Reynes 2014-06-14 314
fc167f62483325 Philippe Reynes 2014-06-14 315 /* Read result */
fc167f62483325 Philippe Reynes 2014-06-14 316 ret = spi_read(st->spi, st->buffer, (chan->type == IIO_TEMP) ? 4 : 2);
fc167f62483325 Philippe Reynes 2014-06-14 317 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 318 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 319
fc167f62483325 Philippe Reynes 2014-06-14 320 *val = be16_to_cpu(st->buffer[0]);
fc167f62483325 Philippe Reynes 2014-06-14 321
fc167f62483325 Philippe Reynes 2014-06-14 322 return IIO_VAL_INT;
fc167f62483325 Philippe Reynes 2014-06-14 323 }
fc167f62483325 Philippe Reynes 2014-06-14 324
fc167f62483325 Philippe Reynes 2014-06-14 325 static int max1027_read_raw(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 326 struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14 327 int *val, int *val2, long mask)
fc167f62483325 Philippe Reynes 2014-06-14 328 {
fc167f62483325 Philippe Reynes 2014-06-14 329 int ret = 0;
fc167f62483325 Philippe Reynes 2014-06-14 330 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 331
fc167f62483325 Philippe Reynes 2014-06-14 332 mutex_lock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14 333
fc167f62483325 Philippe Reynes 2014-06-14 334 switch (mask) {
fc167f62483325 Philippe Reynes 2014-06-14 335 case IIO_CHAN_INFO_RAW:
fc167f62483325 Philippe Reynes 2014-06-14 336 ret = max1027_read_single_value(indio_dev, chan, val);
fc167f62483325 Philippe Reynes 2014-06-14 337 break;
fc167f62483325 Philippe Reynes 2014-06-14 338 case IIO_CHAN_INFO_SCALE:
fc167f62483325 Philippe Reynes 2014-06-14 339 switch (chan->type) {
fc167f62483325 Philippe Reynes 2014-06-14 340 case IIO_TEMP:
fc167f62483325 Philippe Reynes 2014-06-14 341 *val = 1;
fc167f62483325 Philippe Reynes 2014-06-14 342 *val2 = 8;
fc167f62483325 Philippe Reynes 2014-06-14 343 ret = IIO_VAL_FRACTIONAL;
fc167f62483325 Philippe Reynes 2014-06-14 344 break;
fc167f62483325 Philippe Reynes 2014-06-14 345 case IIO_VOLTAGE:
fc167f62483325 Philippe Reynes 2014-06-14 346 *val = 2500;
7af5257d84275c Miquel Raynal 2019-10-11 347 *val2 = chan->scan_type.realbits;
fc167f62483325 Philippe Reynes 2014-06-14 348 ret = IIO_VAL_FRACTIONAL_LOG2;
fc167f62483325 Philippe Reynes 2014-06-14 349 break;
fc167f62483325 Philippe Reynes 2014-06-14 350 default:
fc167f62483325 Philippe Reynes 2014-06-14 351 ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 352 break;
fc167f62483325 Philippe Reynes 2014-06-14 353 }
fc167f62483325 Philippe Reynes 2014-06-14 354 break;
fc167f62483325 Philippe Reynes 2014-06-14 355 default:
fc167f62483325 Philippe Reynes 2014-06-14 356 ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 357 break;
fc167f62483325 Philippe Reynes 2014-06-14 358 }
fc167f62483325 Philippe Reynes 2014-06-14 359
fc167f62483325 Philippe Reynes 2014-06-14 360 mutex_unlock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14 361
fc167f62483325 Philippe Reynes 2014-06-14 362 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 363 }
fc167f62483325 Philippe Reynes 2014-06-14 364
fc167f62483325 Philippe Reynes 2014-06-14 365 static int max1027_debugfs_reg_access(struct iio_dev *indio_dev,
825ca5fefb8af9 Miquel Raynal 2021-09-21 366 unsigned int reg, unsigned int writeval,
825ca5fefb8af9 Miquel Raynal 2021-09-21 367 unsigned int *readval)
fc167f62483325 Philippe Reynes 2014-06-14 368 {
fc167f62483325 Philippe Reynes 2014-06-14 369 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 370 u8 *val = (u8 *)st->buffer;
fc167f62483325 Philippe Reynes 2014-06-14 371
038696f8bd2f2e Miquel Raynal 2019-10-11 372 if (readval) {
038696f8bd2f2e Miquel Raynal 2019-10-11 373 int ret = spi_read(st->spi, val, 2);
038696f8bd2f2e Miquel Raynal 2019-10-11 374 *readval = be16_to_cpu(st->buffer[0]);
038696f8bd2f2e Miquel Raynal 2019-10-11 375 return ret;
038696f8bd2f2e Miquel Raynal 2019-10-11 376 }
fc167f62483325 Philippe Reynes 2014-06-14 377
fc167f62483325 Philippe Reynes 2014-06-14 378 *val = (u8)writeval;
fc167f62483325 Philippe Reynes 2014-06-14 379 return spi_write(st->spi, val, 1);
fc167f62483325 Philippe Reynes 2014-06-14 380 }
fc167f62483325 Philippe Reynes 2014-06-14 381
fc167f62483325 Philippe Reynes 2014-06-14 382 static int max1027_validate_trigger(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 383 struct iio_trigger *trig)
fc167f62483325 Philippe Reynes 2014-06-14 384 {
fc167f62483325 Philippe Reynes 2014-06-14 385 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 386
fc167f62483325 Philippe Reynes 2014-06-14 387 if (st->trig != trig)
fc167f62483325 Philippe Reynes 2014-06-14 388 return -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 389
fc167f62483325 Philippe Reynes 2014-06-14 390 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 391 }
fc167f62483325 Philippe Reynes 2014-06-14 392
fc167f62483325 Philippe Reynes 2014-06-14 393 static int max1027_set_trigger_state(struct iio_trigger *trig, bool state)
fc167f62483325 Philippe Reynes 2014-06-14 394 {
fc167f62483325 Philippe Reynes 2014-06-14 395 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
fc167f62483325 Philippe Reynes 2014-06-14 396 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 397 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 398
fc167f62483325 Philippe Reynes 2014-06-14 399 if (state) {
fc167f62483325 Philippe Reynes 2014-06-14 400 /* Start acquisition on cnvst */
fc167f62483325 Philippe Reynes 2014-06-14 401 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE0 |
fc167f62483325 Philippe Reynes 2014-06-14 402 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 403 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 404 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 405 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 406
1e80dcadd79f6d Miquel Raynal 2021-09-21 407 /*
1e80dcadd79f6d Miquel Raynal 2021-09-21 408 * Scan from chan 0 to the highest requested channel.
1e80dcadd79f6d Miquel Raynal 2021-09-21 409 * Include temperature on demand.
1e80dcadd79f6d Miquel Raynal 2021-09-21 410 */
1e80dcadd79f6d Miquel Raynal 2021-09-21 411 st->reg = MAX1027_CONV_REG | MAX1027_SCAN_0_N;
1e80dcadd79f6d Miquel Raynal 2021-09-21 @412 st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
1e80dcadd79f6d Miquel Raynal 2021-09-21 413 if (*indio_dev->active_scan_mask & MAX1X27_SCAN_MASK_TEMP)
1e80dcadd79f6d Miquel Raynal 2021-09-21 414 st->reg |= MAX1027_TEMP;
1e80dcadd79f6d Miquel Raynal 2021-09-21 415
fc167f62483325 Philippe Reynes 2014-06-14 416 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 417 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 418 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 419 } else {
fc167f62483325 Philippe Reynes 2014-06-14 420 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 421 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE2 |
fc167f62483325 Philippe Reynes 2014-06-14 422 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 423 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 424 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 425 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 426 }
fc167f62483325 Philippe Reynes 2014-06-14 427
fc167f62483325 Philippe Reynes 2014-06-14 428 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 429 }
fc167f62483325 Philippe Reynes 2014-06-14 430
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34184 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
@ 2021-09-30 23:59 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-09-30 23:59 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 26693 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Miquel Raynal <miquel.raynal@bootlin.com>
CC: 0day robot <lkp@intel.com>
tree: https://github.com/0day-ci/linux/commits/Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
head: 82403933ab13283e98041a4c285420988531362c
commit: 1e80dcadd79f6dec7346dc596fbafd508ea2844e iio: adc: max1027: Minimize the number of converted channels
date: 9 days ago
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/1e80dcadd79f6dec7346dc596fbafd508ea2844e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
git checkout 1e80dcadd79f6dec7346dc596fbafd508ea2844e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
31 warnings generated.
Suppressed 31 warnings (10 in non-user code, 21 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
23 warnings generated.
Suppressed 23 warnings (10 in non-user code, 13 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/iio/accel/bma180.c:197:36: warning: The result of the left shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
u8 reg_val = (ret & ~mask) | (val << (ffs(mask) - 1));
^
drivers/iio/accel/bma180.c:914:8: note: Calling 'bma180_reset_intr'
ret = bma180_reset_intr(data);
^~~~~~~~~~~~~~~~~~~~~~~
drivers/iio/accel/bma180.c:207:12: note: Calling 'bma180_set_bits'
int ret = bma180_set_bits(data, data->part_info->int_reset_reg,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/iio/accel/bma180.c:197:36: note: The result of the left shift is undefined because the right operand is negative
u8 reg_val = (ret & ~mask) | (val << (ffs(mask) - 1));
^ ~~~~~~~~~~~~~~~
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (12 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/iio/adc/max1027.c:265:8: warning: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal).
Optimal fields order:
reg,
info,
spi,
trig,
buffer,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/adc/max1027.c:265:8: note: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). Optimal fields order: reg, info, spi, trig, buffer, lock, consider reordering the fields or adding explicit padding members
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
>> drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
drivers/iio/adc/max1027.c:399:6: note: Assuming 'state' is true
if (state) {
^~~~~
drivers/iio/adc/max1027.c:399:2: note: Taking true branch
if (state) {
^
drivers/iio/adc/max1027.c:404:7: note: Assuming 'ret' is >= 0
if (ret < 0)
^~~~~~~
drivers/iio/adc/max1027.c:404:3: note: Taking false branch
if (ret < 0)
^
drivers/iio/adc/max1027.c:412:14: note: The result of the left shift is undefined because the left operand is negative
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max11100.c:31:8: warning: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal).
Optimal fields order:
buffer,
vref_reg,
spi,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
drivers/iio/adc/max11100.c:31:8: note: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal). Optimal fields order: buffer, vref_reg, spi, consider reordering the fields or adding explicit padding members
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max1241.c:22:8: warning: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
spi,
vdd,
vref,
shutdown,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1241 {
~~~~~~~^~~~~~~~~
drivers/iio/adc/max1241.c:22:8: note: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal). Optimal fields order: data, spi, vdd, vref, shutdown, lock, consider reordering the fields or adding explicit padding members
struct max1241 {
~~~~~~~^~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ti-dac7311.c:47:8: warning: Excessive padding in 'struct ti_dac_chip' (101 padding bytes, where 37 is optimal).
Optimal fields order:
buf,
val,
vref,
spi,
lock,
powerdown,
powerdown_mode,
resolution,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ti_dac_chip {
~~~~~~~^~~~~~~~~~~~~
drivers/iio/dac/ti-dac7311.c:47:8: note: Excessive padding in 'struct ti_dac_chip' (101 padding bytes, where 37 is optimal). Optimal fields order: buf, val, vref, spi, lock, powerdown, powerdown_mode, resolution, consider reordering the fields or adding explicit padding members
struct ti_dac_chip {
~~~~~~~^~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
drivers/iio/gyro/adis16130.c:41:8: warning: Excessive padding in 'struct adis16130_state' (108 padding bytes, where 44 is optimal).
Optimal fields order:
buf,
us,
buf_lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct adis16130_state {
~~~~~~~^~~~~~~~~~~~~~~~~
drivers/iio/gyro/adis16130.c:41:8: note: Excessive padding in 'struct adis16130_state' (108 padding bytes, where 44 is optimal). Optimal fields order: buf, us, buf_lock, consider reordering the fields or adding explicit padding members
struct adis16130_state {
~~~~~~~^~~~~~~~~~~~~~~~~
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
vim +412 drivers/iio/adc/max1027.c
fc167f62483325 Philippe Reynes 2014-06-14 264
fc167f62483325 Philippe Reynes 2014-06-14 @265 struct max1027_state {
fc167f62483325 Philippe Reynes 2014-06-14 266 const struct max1027_chip_info *info;
fc167f62483325 Philippe Reynes 2014-06-14 267 struct spi_device *spi;
fc167f62483325 Philippe Reynes 2014-06-14 268 struct iio_trigger *trig;
fc167f62483325 Philippe Reynes 2014-06-14 269 __be16 *buffer;
fc167f62483325 Philippe Reynes 2014-06-14 270 struct mutex lock;
fc167f62483325 Philippe Reynes 2014-06-14 271
fc167f62483325 Philippe Reynes 2014-06-14 272 u8 reg ____cacheline_aligned;
fc167f62483325 Philippe Reynes 2014-06-14 273 };
fc167f62483325 Philippe Reynes 2014-06-14 274
fc167f62483325 Philippe Reynes 2014-06-14 275 static int max1027_read_single_value(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 276 struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14 277 int *val)
fc167f62483325 Philippe Reynes 2014-06-14 278 {
fc167f62483325 Philippe Reynes 2014-06-14 279 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 280 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 281
fc167f62483325 Philippe Reynes 2014-06-14 282 if (iio_buffer_enabled(indio_dev)) {
fc167f62483325 Philippe Reynes 2014-06-14 283 dev_warn(&indio_dev->dev, "trigger mode already enabled");
fc167f62483325 Philippe Reynes 2014-06-14 284 return -EBUSY;
fc167f62483325 Philippe Reynes 2014-06-14 285 }
fc167f62483325 Philippe Reynes 2014-06-14 286
fc167f62483325 Philippe Reynes 2014-06-14 287 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 288 st->reg = MAX1027_SETUP_REG | MAX1027_REF_MODE2 | MAX1027_CKS_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 289 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 290 if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14 291 dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14 292 "Failed to configure setup register\n");
fc167f62483325 Philippe Reynes 2014-06-14 293 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 294 }
fc167f62483325 Philippe Reynes 2014-06-14 295
fc167f62483325 Philippe Reynes 2014-06-14 296 /* Configure conversion register with the requested chan */
fc167f62483325 Philippe Reynes 2014-06-14 297 st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
58b90a8d2c397a Sandhya Bankar 2016-09-24 298 MAX1027_NOSCAN;
58b90a8d2c397a Sandhya Bankar 2016-09-24 299 if (chan->type == IIO_TEMP)
58b90a8d2c397a Sandhya Bankar 2016-09-24 300 st->reg |= MAX1027_TEMP;
fc167f62483325 Philippe Reynes 2014-06-14 301 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 302 if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14 303 dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14 304 "Failed to configure conversion register\n");
fc167f62483325 Philippe Reynes 2014-06-14 305 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 306 }
fc167f62483325 Philippe Reynes 2014-06-14 307
fc167f62483325 Philippe Reynes 2014-06-14 308 /*
fc167f62483325 Philippe Reynes 2014-06-14 309 * For an unknown reason, when we use the mode "10" (write
fc167f62483325 Philippe Reynes 2014-06-14 310 * conversion register), the interrupt doesn't occur every time.
fc167f62483325 Philippe Reynes 2014-06-14 311 * So we just wait 1 ms.
fc167f62483325 Philippe Reynes 2014-06-14 312 */
fc167f62483325 Philippe Reynes 2014-06-14 313 mdelay(1);
fc167f62483325 Philippe Reynes 2014-06-14 314
fc167f62483325 Philippe Reynes 2014-06-14 315 /* Read result */
fc167f62483325 Philippe Reynes 2014-06-14 316 ret = spi_read(st->spi, st->buffer, (chan->type == IIO_TEMP) ? 4 : 2);
fc167f62483325 Philippe Reynes 2014-06-14 317 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 318 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 319
fc167f62483325 Philippe Reynes 2014-06-14 320 *val = be16_to_cpu(st->buffer[0]);
fc167f62483325 Philippe Reynes 2014-06-14 321
fc167f62483325 Philippe Reynes 2014-06-14 322 return IIO_VAL_INT;
fc167f62483325 Philippe Reynes 2014-06-14 323 }
fc167f62483325 Philippe Reynes 2014-06-14 324
fc167f62483325 Philippe Reynes 2014-06-14 325 static int max1027_read_raw(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 326 struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14 327 int *val, int *val2, long mask)
fc167f62483325 Philippe Reynes 2014-06-14 328 {
fc167f62483325 Philippe Reynes 2014-06-14 329 int ret = 0;
fc167f62483325 Philippe Reynes 2014-06-14 330 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 331
fc167f62483325 Philippe Reynes 2014-06-14 332 mutex_lock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14 333
fc167f62483325 Philippe Reynes 2014-06-14 334 switch (mask) {
fc167f62483325 Philippe Reynes 2014-06-14 335 case IIO_CHAN_INFO_RAW:
fc167f62483325 Philippe Reynes 2014-06-14 336 ret = max1027_read_single_value(indio_dev, chan, val);
fc167f62483325 Philippe Reynes 2014-06-14 337 break;
fc167f62483325 Philippe Reynes 2014-06-14 338 case IIO_CHAN_INFO_SCALE:
fc167f62483325 Philippe Reynes 2014-06-14 339 switch (chan->type) {
fc167f62483325 Philippe Reynes 2014-06-14 340 case IIO_TEMP:
fc167f62483325 Philippe Reynes 2014-06-14 341 *val = 1;
fc167f62483325 Philippe Reynes 2014-06-14 342 *val2 = 8;
fc167f62483325 Philippe Reynes 2014-06-14 343 ret = IIO_VAL_FRACTIONAL;
fc167f62483325 Philippe Reynes 2014-06-14 344 break;
fc167f62483325 Philippe Reynes 2014-06-14 345 case IIO_VOLTAGE:
fc167f62483325 Philippe Reynes 2014-06-14 346 *val = 2500;
7af5257d84275c Miquel Raynal 2019-10-11 347 *val2 = chan->scan_type.realbits;
fc167f62483325 Philippe Reynes 2014-06-14 348 ret = IIO_VAL_FRACTIONAL_LOG2;
fc167f62483325 Philippe Reynes 2014-06-14 349 break;
fc167f62483325 Philippe Reynes 2014-06-14 350 default:
fc167f62483325 Philippe Reynes 2014-06-14 351 ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 352 break;
fc167f62483325 Philippe Reynes 2014-06-14 353 }
fc167f62483325 Philippe Reynes 2014-06-14 354 break;
fc167f62483325 Philippe Reynes 2014-06-14 355 default:
fc167f62483325 Philippe Reynes 2014-06-14 356 ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 357 break;
fc167f62483325 Philippe Reynes 2014-06-14 358 }
fc167f62483325 Philippe Reynes 2014-06-14 359
fc167f62483325 Philippe Reynes 2014-06-14 360 mutex_unlock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14 361
fc167f62483325 Philippe Reynes 2014-06-14 362 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 363 }
fc167f62483325 Philippe Reynes 2014-06-14 364
fc167f62483325 Philippe Reynes 2014-06-14 365 static int max1027_debugfs_reg_access(struct iio_dev *indio_dev,
825ca5fefb8af9 Miquel Raynal 2021-09-21 366 unsigned int reg, unsigned int writeval,
825ca5fefb8af9 Miquel Raynal 2021-09-21 367 unsigned int *readval)
fc167f62483325 Philippe Reynes 2014-06-14 368 {
fc167f62483325 Philippe Reynes 2014-06-14 369 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 370 u8 *val = (u8 *)st->buffer;
fc167f62483325 Philippe Reynes 2014-06-14 371
038696f8bd2f2e Miquel Raynal 2019-10-11 372 if (readval) {
038696f8bd2f2e Miquel Raynal 2019-10-11 373 int ret = spi_read(st->spi, val, 2);
038696f8bd2f2e Miquel Raynal 2019-10-11 374 *readval = be16_to_cpu(st->buffer[0]);
038696f8bd2f2e Miquel Raynal 2019-10-11 375 return ret;
038696f8bd2f2e Miquel Raynal 2019-10-11 376 }
fc167f62483325 Philippe Reynes 2014-06-14 377
fc167f62483325 Philippe Reynes 2014-06-14 378 *val = (u8)writeval;
fc167f62483325 Philippe Reynes 2014-06-14 379 return spi_write(st->spi, val, 1);
fc167f62483325 Philippe Reynes 2014-06-14 380 }
fc167f62483325 Philippe Reynes 2014-06-14 381
fc167f62483325 Philippe Reynes 2014-06-14 382 static int max1027_validate_trigger(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14 383 struct iio_trigger *trig)
fc167f62483325 Philippe Reynes 2014-06-14 384 {
fc167f62483325 Philippe Reynes 2014-06-14 385 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 386
fc167f62483325 Philippe Reynes 2014-06-14 387 if (st->trig != trig)
fc167f62483325 Philippe Reynes 2014-06-14 388 return -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14 389
fc167f62483325 Philippe Reynes 2014-06-14 390 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 391 }
fc167f62483325 Philippe Reynes 2014-06-14 392
fc167f62483325 Philippe Reynes 2014-06-14 393 static int max1027_set_trigger_state(struct iio_trigger *trig, bool state)
fc167f62483325 Philippe Reynes 2014-06-14 394 {
fc167f62483325 Philippe Reynes 2014-06-14 395 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
fc167f62483325 Philippe Reynes 2014-06-14 396 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 397 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 398
fc167f62483325 Philippe Reynes 2014-06-14 399 if (state) {
fc167f62483325 Philippe Reynes 2014-06-14 400 /* Start acquisition on cnvst */
fc167f62483325 Philippe Reynes 2014-06-14 401 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE0 |
fc167f62483325 Philippe Reynes 2014-06-14 402 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 403 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 404 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 405 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 406
1e80dcadd79f6d Miquel Raynal 2021-09-21 407 /*
1e80dcadd79f6d Miquel Raynal 2021-09-21 408 * Scan from chan 0 to the highest requested channel.
1e80dcadd79f6d Miquel Raynal 2021-09-21 409 * Include temperature on demand.
1e80dcadd79f6d Miquel Raynal 2021-09-21 410 */
1e80dcadd79f6d Miquel Raynal 2021-09-21 411 st->reg = MAX1027_CONV_REG | MAX1027_SCAN_0_N;
1e80dcadd79f6d Miquel Raynal 2021-09-21 @412 st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
1e80dcadd79f6d Miquel Raynal 2021-09-21 413 if (*indio_dev->active_scan_mask & MAX1X27_SCAN_MASK_TEMP)
1e80dcadd79f6d Miquel Raynal 2021-09-21 414 st->reg |= MAX1027_TEMP;
1e80dcadd79f6d Miquel Raynal 2021-09-21 415
fc167f62483325 Philippe Reynes 2014-06-14 416 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 417 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 418 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 419 } else {
fc167f62483325 Philippe Reynes 2014-06-14 420 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 421 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE2 |
fc167f62483325 Philippe Reynes 2014-06-14 422 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 423 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 424 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 425 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 426 }
fc167f62483325 Philippe Reynes 2014-06-14 427
fc167f62483325 Philippe Reynes 2014-06-14 428 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 429 }
fc167f62483325 Philippe Reynes 2014-06-14 430
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34184 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
@ 2021-09-30 2:43 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-09-30 2:43 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 17595 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Miquel Raynal <miquel.raynal@bootlin.com>
CC: 0day robot <lkp@intel.com>
tree: https://github.com/0day-ci/linux/commits/Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
head: 82403933ab13283e98041a4c285420988531362c
commit: 1e80dcadd79f6dec7346dc596fbafd508ea2844e iio: adc: max1027: Minimize the number of converted channels
date: 8 days ago
:::::: branch date: 8 days ago
:::::: commit date: 8 days ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/1e80dcadd79f6dec7346dc596fbafd508ea2844e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
git checkout 1e80dcadd79f6dec7346dc596fbafd508ea2844e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
struct adis16130_state {
~~~~~~~^~~~~~~~~~~~~~~~~
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
Suppressed 11 warnings (11 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ad5770r.c:133:8: warning: Excessive padding in 'struct ad5770r_state' (86 padding bytes, where 22 is optimal).
Optimal fields order:
transf_buf,
internal_ref,
external_res,
spi,
regmap,
vref_reg,
gpio_reset,
vref,
ch_pwr_down,
output_mode,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad5770r_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/dac/ad5770r.c:133:8: note: Excessive padding in 'struct ad5770r_state' (86 padding bytes, where 22 is optimal). Optimal fields order: transf_buf, internal_ref, external_res, spi, regmap, vref_reg, gpio_reset, vref, ch_pwr_down, output_mode, consider reordering the fields or adding explicit padding members
struct ad5770r_state {
~~~~~~~^~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ad7303.c:37:8: warning: Excessive padding in 'struct ad7303_state' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
config,
spi,
vdd_reg,
vref_reg,
lock,
dac_cache,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad7303_state {
~~~~~~~^~~~~~~~~~~~~~
drivers/iio/dac/ad7303.c:37:8: note: Excessive padding in 'struct ad7303_state' (98 padding bytes, where 34 is optimal). Optimal fields order: data, config, spi, vdd_reg, vref_reg, lock, dac_cache, consider reordering the fields or adding explicit padding members
struct ad7303_state {
~~~~~~~^~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ad8801.c:21:8: warning: Excessive padding in 'struct ad8801_state' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
dac_cache,
spi,
vrefh_mv,
vrefl_mv,
vrefh_reg,
vrefl_reg,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad8801_state {
~~~~~~~^~~~~~~~~~~~~~
drivers/iio/dac/ad8801.c:21:8: note: Excessive padding in 'struct ad8801_state' (98 padding bytes, where 34 is optimal). Optimal fields order: data, dac_cache, spi, vrefh_mv, vrefl_mv, vrefh_reg, vrefl_reg, consider reordering the fields or adding explicit padding members
struct ad8801_state {
~~~~~~~^~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/iio/adc/max1027.c:265:8: warning: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal).
Optimal fields order:
reg,
info,
spi,
trig,
buffer,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/adc/max1027.c:265:8: note: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). Optimal fields order: reg, info, spi, trig, buffer, lock, consider reordering the fields or adding explicit padding members
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
>> drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
drivers/iio/adc/max1027.c:399:6: note: Assuming 'state' is true
if (state) {
^~~~~
drivers/iio/adc/max1027.c:399:2: note: Taking true branch
if (state) {
^
drivers/iio/adc/max1027.c:404:7: note: Assuming 'ret' is >= 0
if (ret < 0)
^~~~~~~
drivers/iio/adc/max1027.c:404:3: note: Taking false branch
if (ret < 0)
^
drivers/iio/adc/max1027.c:412:14: note: The result of the left shift is undefined because the left operand is negative
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max11100.c:31:8: warning: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal).
Optimal fields order:
buffer,
vref_reg,
spi,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
drivers/iio/adc/max11100.c:31:8: note: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal). Optimal fields order: buffer, vref_reg, spi, consider reordering the fields or adding explicit padding members
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max1241.c:22:8: warning: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
spi,
vdd,
vref,
shutdown,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1241 {
~~~~~~~^~~~~~~~~
drivers/iio/adc/max1241.c:22:8: note: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal). Optimal fields order: data, spi, vdd, vref, shutdown, lock, consider reordering the fields or adding explicit padding members
struct max1241 {
~~~~~~~^~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
16 warnings generated.
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:589:11: warning: Value stored to 'hi_sidd' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
uint16_t hi_sidd = smu_data->power_tune_table.BapmVddCBaseLeakageHiSidd;
^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:589:11: note: Value stored to 'hi_sidd' during its initialization is never read
uint16_t hi_sidd = smu_data->power_tune_table.BapmVddCBaseLeakageHiSidd;
^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:590:11: warning: Value stored to 'lo_sidd' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
uint16_t lo_sidd = smu_data->power_tune_table.BapmVddCBaseLeakageLoSidd;
^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:590:11: note: Value stored to 'lo_sidd' during its initialization is never read
uint16_t lo_sidd = smu_data->power_tune_table.BapmVddCBaseLeakageLoSidd;
^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:967:2: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
result = polaris10_calculate_sclk_params(hwmgr, clock, &curr_sclk_setting);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:967:2: note: Value stored to 'result' is never read
result = polaris10_calculate_sclk_params(hwmgr, clock, &curr_sclk_setting);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1592:3: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
result = 0;
^ ~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1592:3: note: Value stored to 'result' is never read
result = 0;
^ ~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1600:3: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
result = 0;
^ ~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1600:3: note: Value stored to 'result' is never read
result = 0;
^ ~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1868:3: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
result = smu7_read_smc_sram_dword(hwmgr,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/smumgr/polaris10_smumgr.c:1868:3: note: Value stored to 'result' is never read
result = smu7_read_smc_sram_dword(hwmgr,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
vim +412 drivers/iio/adc/max1027.c
fc167f62483325 Philippe Reynes 2014-06-14 392
fc167f62483325 Philippe Reynes 2014-06-14 393 static int max1027_set_trigger_state(struct iio_trigger *trig, bool state)
fc167f62483325 Philippe Reynes 2014-06-14 394 {
fc167f62483325 Philippe Reynes 2014-06-14 395 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
fc167f62483325 Philippe Reynes 2014-06-14 396 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 397 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 398
fc167f62483325 Philippe Reynes 2014-06-14 399 if (state) {
fc167f62483325 Philippe Reynes 2014-06-14 400 /* Start acquisition on cnvst */
fc167f62483325 Philippe Reynes 2014-06-14 401 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE0 |
fc167f62483325 Philippe Reynes 2014-06-14 402 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 403 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 404 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 405 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 406
1e80dcadd79f6d Miquel Raynal 2021-09-21 407 /*
1e80dcadd79f6d Miquel Raynal 2021-09-21 408 * Scan from chan 0 to the highest requested channel.
1e80dcadd79f6d Miquel Raynal 2021-09-21 409 * Include temperature on demand.
1e80dcadd79f6d Miquel Raynal 2021-09-21 410 */
1e80dcadd79f6d Miquel Raynal 2021-09-21 411 st->reg = MAX1027_CONV_REG | MAX1027_SCAN_0_N;
1e80dcadd79f6d Miquel Raynal 2021-09-21 @412 st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
1e80dcadd79f6d Miquel Raynal 2021-09-21 413 if (*indio_dev->active_scan_mask & MAX1X27_SCAN_MASK_TEMP)
1e80dcadd79f6d Miquel Raynal 2021-09-21 414 st->reg |= MAX1027_TEMP;
1e80dcadd79f6d Miquel Raynal 2021-09-21 415
fc167f62483325 Philippe Reynes 2014-06-14 416 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 417 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 418 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 419 } else {
fc167f62483325 Philippe Reynes 2014-06-14 420 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 421 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE2 |
fc167f62483325 Philippe Reynes 2014-06-14 422 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 423 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 424 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 425 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 426 }
fc167f62483325 Philippe Reynes 2014-06-14 427
fc167f62483325 Philippe Reynes 2014-06-14 428 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 429 }
fc167f62483325 Philippe Reynes 2014-06-14 430
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34184 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
@ 2021-09-29 4:14 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-09-29 4:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 16238 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Miquel Raynal <miquel.raynal@bootlin.com>
CC: 0day robot <lkp@intel.com>
tree: https://github.com/0day-ci/linux/commits/Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
head: 82403933ab13283e98041a4c285420988531362c
commit: 1e80dcadd79f6dec7346dc596fbafd508ea2844e iio: adc: max1027: Minimize the number of converted channels
date: 7 days ago
:::::: branch date: 7 days ago
:::::: commit date: 7 days ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/1e80dcadd79f6dec7346dc596fbafd508ea2844e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
git checkout 1e80dcadd79f6dec7346dc596fbafd508ea2844e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
include/linux/list.h:135:13: note: Use of memory after it is freed
__list_del(entry->prev, entry->next);
^~~~~~~~~~~
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/ad7292.c:78:8: warning: Excessive padding in 'struct ad7292_state' (114 padding bytes, where 50 is optimal).
Optimal fields order:
d16,
vref_mv,
spi,
reg,
d8,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad7292_state {
~~~~~~~^~~~~~~~~~~~~~
drivers/iio/adc/ad7292.c:78:8: note: Excessive padding in 'struct ad7292_state' (114 padding bytes, where 50 is optimal). Optimal fields order: d16, vref_mv, spi, reg, d8, consider reordering the fields or adding explicit padding members
struct ad7292_state {
~~~~~~~^~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/ad7298.c:40:8: warning: Excessive padding in 'struct ad7298_state' (72 padding bytes, where 8 is optimal).
Optimal fields order:
rx_buf,
spi,
reg,
ext_ref,
ring_msg,
scan_single_msg,
scan_single_xfer,
ring_xfer,
tx_buf,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad7298_state {
~~~~~~~^~~~~~~~~~~~~~
drivers/iio/adc/ad7298.c:40:8: note: Excessive padding in 'struct ad7298_state' (72 padding bytes, where 8 is optimal). Optimal fields order: rx_buf, spi, reg, ext_ref, ring_msg, scan_single_msg, scan_single_xfer, ring_xfer, tx_buf, consider reordering the fields or adding explicit padding members
struct ad7298_state {
~~~~~~~^~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/ad7923.c:48:8: warning: Excessive padding in 'struct ad7923_state' (68 padding bytes, where 4 is optimal).
Optimal fields order:
rx_buf,
spi,
reg,
settings,
ring_msg,
scan_single_msg,
scan_single_xfer,
ring_xfer,
tx_buf,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad7923_state {
~~~~~~~^~~~~~~~~~~~~~
drivers/iio/adc/ad7923.c:48:8: note: Excessive padding in 'struct ad7923_state' (68 padding bytes, where 4 is optimal). Optimal fields order: rx_buf, spi, reg, settings, ring_msg, scan_single_msg, scan_single_xfer, ring_xfer, tx_buf, consider reordering the fields or adding explicit padding members
struct ad7923_state {
~~~~~~~^~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/gpu/drm/nouveau/nouveau_bo90b5.c:40:6: warning: Value stored to 'page_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
u32 page_count = new_reg->num_pages;
^~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/nouveau_bo90b5.c:40:6: note: Value stored to 'page_count' during its initialization is never read
u32 page_count = new_reg->num_pages;
^~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/iio/adc/max1027.c:265:8: warning: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal).
Optimal fields order:
reg,
info,
spi,
trig,
buffer,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/adc/max1027.c:265:8: note: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). Optimal fields order: reg, info, spi, trig, buffer, lock, consider reordering the fields or adding explicit padding members
struct max1027_state {
~~~~~~~^~~~~~~~~~~~~~~
>> drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
drivers/iio/adc/max1027.c:399:6: note: Assuming 'state' is true
if (state) {
^~~~~
drivers/iio/adc/max1027.c:399:2: note: Taking true branch
if (state) {
^
drivers/iio/adc/max1027.c:404:7: note: Assuming 'ret' is >= 0
if (ret < 0)
^~~~~~~
drivers/iio/adc/max1027.c:404:3: note: Taking false branch
if (ret < 0)
^
drivers/iio/adc/max1027.c:412:14: note: The result of the left shift is undefined because the left operand is negative
st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
^
drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
#define MAX1027_CHAN(n) ((n) << 3)
~~~ ^
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max11100.c:31:8: warning: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal).
Optimal fields order:
buffer,
vref_reg,
spi,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
drivers/iio/adc/max11100.c:31:8: note: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal). Optimal fields order: buffer, vref_reg, spi, consider reordering the fields or adding explicit padding members
struct max11100_state {
~~~~~~~^~~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/adc/max1241.c:22:8: warning: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
spi,
vdd,
vref,
shutdown,
lock,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct max1241 {
~~~~~~~^~~~~~~~~
drivers/iio/adc/max1241.c:22:8: note: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal). Optimal fields order: data, spi, vdd, vref, shutdown, lock, consider reordering the fields or adding explicit padding members
struct max1241 {
~~~~~~~^~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
18 warnings generated.
Suppressed 18 warnings (10 in non-user code, 8 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ad5770r.c:133:8: warning: Excessive padding in 'struct ad5770r_state' (86 padding bytes, where 22 is optimal).
Optimal fields order:
transf_buf,
internal_ref,
external_res,
spi,
regmap,
vref_reg,
gpio_reset,
vref,
ch_pwr_down,
output_mode,
consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
struct ad5770r_state {
~~~~~~~^~~~~~~~~~~~~~~
drivers/iio/dac/ad5770r.c:133:8: note: Excessive padding in 'struct ad5770r_state' (86 padding bytes, where 22 is optimal). Optimal fields order: transf_buf, internal_ref, external_res, spi, regmap, vref_reg, gpio_reset, vref, ch_pwr_down, output_mode, consider reordering the fields or adding explicit padding members
struct ad5770r_state {
~~~~~~~^~~~~~~~~~~~~~~
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
11 warnings generated.
drivers/iio/dac/ad7303.c:37:8: warning: Excessive padding in 'struct ad7303_state' (98 padding bytes, where 34 is optimal).
Optimal fields order:
data,
config,
spi,
vdd_reg,
vref_reg,
vim +412 drivers/iio/adc/max1027.c
fc167f62483325 Philippe Reynes 2014-06-14 392
fc167f62483325 Philippe Reynes 2014-06-14 393 static int max1027_set_trigger_state(struct iio_trigger *trig, bool state)
fc167f62483325 Philippe Reynes 2014-06-14 394 {
fc167f62483325 Philippe Reynes 2014-06-14 395 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
fc167f62483325 Philippe Reynes 2014-06-14 396 struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14 397 int ret;
fc167f62483325 Philippe Reynes 2014-06-14 398
fc167f62483325 Philippe Reynes 2014-06-14 399 if (state) {
fc167f62483325 Philippe Reynes 2014-06-14 400 /* Start acquisition on cnvst */
fc167f62483325 Philippe Reynes 2014-06-14 401 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE0 |
fc167f62483325 Philippe Reynes 2014-06-14 402 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 403 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 404 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 405 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 406
1e80dcadd79f6d Miquel Raynal 2021-09-21 407 /*
1e80dcadd79f6d Miquel Raynal 2021-09-21 408 * Scan from chan 0 to the highest requested channel.
1e80dcadd79f6d Miquel Raynal 2021-09-21 409 * Include temperature on demand.
1e80dcadd79f6d Miquel Raynal 2021-09-21 410 */
1e80dcadd79f6d Miquel Raynal 2021-09-21 411 st->reg = MAX1027_CONV_REG | MAX1027_SCAN_0_N;
1e80dcadd79f6d Miquel Raynal 2021-09-21 @412 st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
1e80dcadd79f6d Miquel Raynal 2021-09-21 413 if (*indio_dev->active_scan_mask & MAX1X27_SCAN_MASK_TEMP)
1e80dcadd79f6d Miquel Raynal 2021-09-21 414 st->reg |= MAX1027_TEMP;
1e80dcadd79f6d Miquel Raynal 2021-09-21 415
fc167f62483325 Philippe Reynes 2014-06-14 416 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 417 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 418 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 419 } else {
fc167f62483325 Philippe Reynes 2014-06-14 420 /* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14 421 st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE2 |
fc167f62483325 Philippe Reynes 2014-06-14 422 MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14 423 ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14 424 if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14 425 return ret;
fc167f62483325 Philippe Reynes 2014-06-14 426 }
fc167f62483325 Philippe Reynes 2014-06-14 427
fc167f62483325 Philippe Reynes 2014-06-14 428 return 0;
fc167f62483325 Philippe Reynes 2014-06-14 429 }
fc167f62483325 Philippe Reynes 2014-06-14 430
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34182 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-06 9:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 9:20 drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult] kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2021-09-30 23:59 kernel test robot
2021-09-30 2:43 kernel test robot
2021-09-29 4:14 kernel test robot
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.