Re: [PATCH v3 2/2] iio: (bma400) add driver for the BMA400 (fwd)
From: Julia Lawall
Date: Tue Oct 15 2019 - 06:45:40 EST
acc_config is unsigned, so it won't be negative (line 390).
julia
---------- Forwarded message ----------
Date: Mon, 14 Oct 2019 07:23:53 +0800
From: kbuild test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxxxxxxxx
Cc: Julia Lawall <julia.lawall@xxxxxxx>
Subject: Re: [PATCH v3 2/2] iio: (bma400) add driver for the BMA400
Hi Dan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[cannot apply to v5.4-rc2 next-20191011]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dan-Robertson/iio-add-driver-for-Bosch-BMA400-accelerometer/20191014-035631
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Reported-by: Julia Lawall <julia.lawall@xxxxxxx>
>> drivers/iio/accel/bma400_core.c:390:6-16: WARNING: Unsigned expression compared with zero: acc_config < 0
# https://github.com/0day-ci/linux/commit/76b89222e99357a9fdbcfb61982e10d2fe74a409
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 76b89222e99357a9fdbcfb61982e10d2fe74a409
vim +390 drivers/iio/accel/bma400_core.c
76b89222e99357 Dan Robertson 2019-10-12 372
76b89222e99357 Dan Robertson 2019-10-12 373 static int bma400_set_accel_oversampling_ratio(struct bma400_data *data,
76b89222e99357 Dan Robertson 2019-10-12 374 int val)
76b89222e99357 Dan Robertson 2019-10-12 375 {
76b89222e99357 Dan Robertson 2019-10-12 376 int ret;
76b89222e99357 Dan Robertson 2019-10-12 377 unsigned int acc_config;
76b89222e99357 Dan Robertson 2019-10-12 378
76b89222e99357 Dan Robertson 2019-10-12 379 if (val & ~BMA400_TWO_BITS_MASK)
76b89222e99357 Dan Robertson 2019-10-12 380 return -EINVAL;
76b89222e99357 Dan Robertson 2019-10-12 381
76b89222e99357 Dan Robertson 2019-10-12 382 /*
76b89222e99357 Dan Robertson 2019-10-12 383 * The oversampling ratio is stored in a different register
76b89222e99357 Dan Robertson 2019-10-12 384 * based on the power-mode.
76b89222e99357 Dan Robertson 2019-10-12 385 */
76b89222e99357 Dan Robertson 2019-10-12 386 switch (data->power_mode) {
76b89222e99357 Dan Robertson 2019-10-12 387 case POWER_MODE_LOW:
76b89222e99357 Dan Robertson 2019-10-12 388 ret = regmap_read(data->regmap, BMA400_ACC_CONFIG0_REG,
76b89222e99357 Dan Robertson 2019-10-12 389 &acc_config);
76b89222e99357 Dan Robertson 2019-10-12 @390 if (acc_config < 0)
76b89222e99357 Dan Robertson 2019-10-12 391 return acc_config;
76b89222e99357 Dan Robertson 2019-10-12 392
76b89222e99357 Dan Robertson 2019-10-12 393 ret = regmap_write(data->regmap, BMA400_ACC_CONFIG0_REG,
76b89222e99357 Dan Robertson 2019-10-12 394 (acc_config & ~BMA400_LP_OSR_MASK) |
76b89222e99357 Dan Robertson 2019-10-12 395 (val << BMA400_LP_OSR_SHIFT));
76b89222e99357 Dan Robertson 2019-10-12 396 if (ret < 0) {
76b89222e99357 Dan Robertson 2019-10-12 397 dev_err(data->dev, "Failed to write out OSR");
76b89222e99357 Dan Robertson 2019-10-12 398 return ret;
76b89222e99357 Dan Robertson 2019-10-12 399 }
76b89222e99357 Dan Robertson 2019-10-12 400
76b89222e99357 Dan Robertson 2019-10-12 401 data->oversampling_ratio = val;
76b89222e99357 Dan Robertson 2019-10-12 402 return 0;
76b89222e99357 Dan Robertson 2019-10-12 403 case POWER_MODE_NORMAL:
76b89222e99357 Dan Robertson 2019-10-12 404 ret = regmap_read(data->regmap, BMA400_ACC_CONFIG1_REG,
76b89222e99357 Dan Robertson 2019-10-12 405 &acc_config);
76b89222e99357 Dan Robertson 2019-10-12 406 if (ret < 0)
76b89222e99357 Dan Robertson 2019-10-12 407 return ret;
76b89222e99357 Dan Robertson 2019-10-12 408
76b89222e99357 Dan Robertson 2019-10-12 409 ret = regmap_write(data->regmap, BMA400_ACC_CONFIG1_REG,
76b89222e99357 Dan Robertson 2019-10-12 410 (acc_config & ~BMA400_NP_OSR_MASK) |
76b89222e99357 Dan Robertson 2019-10-12 411 (val << BMA400_NP_OSR_SHIFT));
76b89222e99357 Dan Robertson 2019-10-12 412 if (ret < 0) {
76b89222e99357 Dan Robertson 2019-10-12 413 dev_err(data->dev, "Failed to write out OSR");
76b89222e99357 Dan Robertson 2019-10-12 414 return ret;
76b89222e99357 Dan Robertson 2019-10-12 415 }
76b89222e99357 Dan Robertson 2019-10-12 416
76b89222e99357 Dan Robertson 2019-10-12 417 data->oversampling_ratio = val;
76b89222e99357 Dan Robertson 2019-10-12 418 return 0;
76b89222e99357 Dan Robertson 2019-10-12 419 default:
76b89222e99357 Dan Robertson 2019-10-12 420 return -EINVAL;
76b89222e99357 Dan Robertson 2019-10-12 421 }
76b89222e99357 Dan Robertson 2019-10-12 422 return ret;
76b89222e99357 Dan Robertson 2019-10-12 423 }
76b89222e99357 Dan Robertson 2019-10-12 424
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation