Re: [PATCH v2 2/4] iio: pressure: dps310: introduce consistent error handling

From: Dan Carpenter
Date: Thu Apr 11 2024 - 06:14:56 EST


Hi Thomas,

kernel test robot noticed the following build warnings:

url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Haemmerle/iio-pressure-dps310-support-negative-temperature-values/20240410-183937
base: 2c71fdf02a95b3dd425b42f28fd47fb2b1d22702
patch link: https://lore.kernel.org/r/20240410103604.992989-3-thomas.haemmerle%40leica-geosystems.com
patch subject: [PATCH v2 2/4] iio: pressure: dps310: introduce consistent error handling
config: i386-randconfig-141-20240411 (https://download.01.org/0day-ci/archive/20240411/202404110708.7BQYVa7Z-lkp@xxxxxxxxx/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202404110708.7BQYVa7Z-lkp@xxxxxxxxx/

smatch warnings:
drivers/iio/pressure/dps310.c:497 dps310_read_pres_raw() warn: inconsistent returns '&data->lock'.
drivers/iio/pressure/dps310.c:541 dps310_read_temp_raw() warn: inconsistent returns '&data->lock'.

vim +497 drivers/iio/pressure/dps310.c

d711a3c7dc829c Eddie James 2019-05-20 466 static int dps310_read_pres_raw(struct dps310_data *data)
ba6ec48e76bcd4 Joel Stanley 2019-05-20 467 {
ba6ec48e76bcd4 Joel Stanley 2019-05-20 468 int rc;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 469 int rate;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 470 int timeout;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 471 s32 raw;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 472 u8 val[3];
ba6ec48e76bcd4 Joel Stanley 2019-05-20 473
ba6ec48e76bcd4 Joel Stanley 2019-05-20 474 if (mutex_lock_interruptible(&data->lock))
ba6ec48e76bcd4 Joel Stanley 2019-05-20 475 return -EINTR;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 476
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 477 rc = dps310_get_pres_samp_freq(data, &rate);
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 478 if (rc)
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 479 return rc;

goto unlock

f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 480
ba6ec48e76bcd4 Joel Stanley 2019-05-20 481 timeout = DPS310_POLL_TIMEOUT_US(rate);
ba6ec48e76bcd4 Joel Stanley 2019-05-20 482
ba6ec48e76bcd4 Joel Stanley 2019-05-20 483 /* Poll for sensor readiness; base the timeout upon the sample rate. */
7b4ab4abcea4c0 Eddie James 2022-09-15 484 rc = dps310_ready(data, DPS310_PRS_RDY, timeout);
d711a3c7dc829c Eddie James 2019-05-20 485 if (rc)
d711a3c7dc829c Eddie James 2019-05-20 486 goto done;
d711a3c7dc829c Eddie James 2019-05-20 487
d711a3c7dc829c Eddie James 2019-05-20 488 rc = regmap_bulk_read(data->regmap, DPS310_PRS_BASE, val, sizeof(val));
ba6ec48e76bcd4 Joel Stanley 2019-05-20 489 if (rc < 0)
ba6ec48e76bcd4 Joel Stanley 2019-05-20 490 goto done;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 491
d711a3c7dc829c Eddie James 2019-05-20 492 raw = (val[0] << 16) | (val[1] << 8) | val[2];
d711a3c7dc829c Eddie James 2019-05-20 493 data->pressure_raw = sign_extend32(raw, 23);
d711a3c7dc829c Eddie James 2019-05-20 494
d711a3c7dc829c Eddie James 2019-05-20 495 done:
d711a3c7dc829c Eddie James 2019-05-20 496 mutex_unlock(&data->lock);
d711a3c7dc829c Eddie James 2019-05-20 @497 return rc;
d711a3c7dc829c Eddie James 2019-05-20 498 }

[ snip ]

d711a3c7dc829c Eddie James 2019-05-20 517 static int dps310_read_temp_raw(struct dps310_data *data)
d711a3c7dc829c Eddie James 2019-05-20 518 {
d711a3c7dc829c Eddie James 2019-05-20 519 int rc;
d711a3c7dc829c Eddie James 2019-05-20 520 int rate;
d711a3c7dc829c Eddie James 2019-05-20 521 int timeout;
d711a3c7dc829c Eddie James 2019-05-20 522
d711a3c7dc829c Eddie James 2019-05-20 523 if (mutex_lock_interruptible(&data->lock))
d711a3c7dc829c Eddie James 2019-05-20 524 return -EINTR;
d711a3c7dc829c Eddie James 2019-05-20 525
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 526 rc = dps310_get_temp_samp_freq(data, &rate);
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 527 if (rc)
f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 528 return rc;

goto unlock

f3e28d813ae8d1 Thomas Haemmerle 2024-04-10 529
d711a3c7dc829c Eddie James 2019-05-20 530 timeout = DPS310_POLL_TIMEOUT_US(rate);
d711a3c7dc829c Eddie James 2019-05-20 531
d711a3c7dc829c Eddie James 2019-05-20 532 /* Poll for sensor readiness; base the timeout upon the sample rate. */
7b4ab4abcea4c0 Eddie James 2022-09-15 533 rc = dps310_ready(data, DPS310_TMP_RDY, timeout);
7b4ab4abcea4c0 Eddie James 2022-09-15 534 if (rc)
d711a3c7dc829c Eddie James 2019-05-20 535 goto done;
d711a3c7dc829c Eddie James 2019-05-20 536
d711a3c7dc829c Eddie James 2019-05-20 537 rc = dps310_read_temp_ready(data);
d711a3c7dc829c Eddie James 2019-05-20 538
ba6ec48e76bcd4 Joel Stanley 2019-05-20 539 done:
ba6ec48e76bcd4 Joel Stanley 2019-05-20 540 mutex_unlock(&data->lock);
ba6ec48e76bcd4 Joel Stanley 2019-05-20 @541 return rc;
ba6ec48e76bcd4 Joel Stanley 2019-05-20 542 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki