Skip to contentSkip to conversation

drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848 (fwd)

PATCH In review Julia Lawall 2 participants 2 messages Sep 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 32/34 drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848 (fwd)

Is it intended to hold the lock when successfully exiting the function? If so, perhaps that information could be added to the predecing comment.

julia

---------- Forwarded message ----------
Date: Tue, 26 Sep 2023 02:24:25 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [chrome-os:chromeos-5.4 32/34]

    drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848

BCC: [email protected]
CC: [email protected]
TO: [email protected]
TO: Guenter Roeck <[email protected]>

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head:   47a5bab6041a6e6381156a2dfe5781ded89ffa63
commit: 16382e4ab8163f25b527ef0982887c66a9042a42 [32/34] BACKPORT: iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs

:::::: branch date: 2 days ago
:::::: commit date: 4 days ago
config: x86_64-randconfig-101-20230925 (https://download.01.org/0day-ci/archive/20230926/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230926/[email protected]/reproduce)

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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848

vim +1851 drivers/iio/industrialio-core.c

08a33805518e784 Alison Schofield 2016-03-09 1834

16382e4ab8163f2 Nuno Sá          2022-10-12  1835  /**
16382e4ab8163f2 Nuno Sá          2022-10-12  1836   * iio_device_claim_buffer_mode - Keep device in buffer mode
16382e4ab8163f2 Nuno Sá          2022-10-12  1837   * @indio_dev:	the iio_dev associated with the device
16382e4ab8163f2 Nuno Sá          2022-10-12  1838   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1839   * If the device is in buffer mode it is guaranteed to stay
16382e4ab8163f2 Nuno Sá          2022-10-12  1840   * that way until iio_device_release_buffer_mode() is called.
16382e4ab8163f2 Nuno Sá          2022-10-12  1841   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1842   * Use with iio_device_release_buffer_mode().
16382e4ab8163f2 Nuno Sá          2022-10-12  1843   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1844   * Returns: 0 on success, -EBUSY on failure.
16382e4ab8163f2 Nuno Sá          2022-10-12  1845   */
16382e4ab8163f2 Nuno Sá          2022-10-12  1846  int iio_device_claim_buffer_mode(struct iio_dev *indio_dev)
16382e4ab8163f2 Nuno Sá          2022-10-12  1847  {
16382e4ab8163f2 Nuno Sá          2022-10-12 @1848  	mutex_lock(&indio_dev->mlock);
16382e4ab8163f2 Nuno Sá          2022-10-12  1849
16382e4ab8163f2 Nuno Sá          2022-10-12  1850  	if (iio_buffer_enabled(indio_dev))
16382e4ab8163f2 Nuno Sá          2022-10-12 @1851  		return 0;
16382e4ab8163f2 Nuno Sá          2022-10-12  1852
16382e4ab8163f2 Nuno Sá          2022-10-12  1853  	mutex_unlock(&indio_dev->mlock);
16382e4ab8163f2 Nuno Sá          2022-10-12  1854  	return -EBUSY;
16382e4ab8163f2 Nuno Sá          2022-10-12  1855  }
16382e4ab8163f2 Nuno Sá          2022-10-12  1856  EXPORT_SYMBOL_GPL(iio_device_claim_buffer_mode);
16382e4ab8163f2 Nuno Sá          2022-10-12  1857
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw

Hi Julia,

Quoted 4 lines · Julia Lawall

Is it intended to hold the lock when successfully exiting the function? If so, perhaps that information could be added to the predecing comment.

This code originates from the upstream kernel, and it indeed locks the mutex in one function and releases it in another. Should the functions be tagged with __acquires() and __releases() ? If so, that should probably be done in the upstream kernel.

Thanks,
Guenter

Quoted 63 lines

julia

---------- Forwarded message ----------
Date: Tue, 26 Sep 2023 02:24:25 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [chrome-os:chromeos-5.4 32/34]

    drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848

BCC: [email protected]
CC: [email protected]
TO: [email protected]
TO: Guenter Roeck <[email protected]>

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head:   47a5bab6041a6e6381156a2dfe5781ded89ffa63
commit: 16382e4ab8163f25b527ef0982887c66a9042a42 [32/34] BACKPORT: iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs

:::::: branch date: 2 days ago
:::::: commit date: 4 days ago
config: x86_64-randconfig-101-20230925 (https://download.01.org/0day-ci/archive/20230926/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230926/[email protected]/reproduce)

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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/iio/industrialio-core.c:1851:2-8: preceding lock on line 1848

vim +1851 drivers/iio/industrialio-core.c

08a33805518e784 Alison Schofield 2016-03-09 1834

16382e4ab8163f2 Nuno Sá          2022-10-12  1835  /**
16382e4ab8163f2 Nuno Sá          2022-10-12  1836   * iio_device_claim_buffer_mode - Keep device in buffer mode
16382e4ab8163f2 Nuno Sá          2022-10-12  1837   * @indio_dev:       the iio_dev associated with the device
16382e4ab8163f2 Nuno Sá          2022-10-12  1838   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1839   * If the device is in buffer mode it is guaranteed to stay
16382e4ab8163f2 Nuno Sá          2022-10-12  1840   * that way until iio_device_release_buffer_mode() is called.
16382e4ab8163f2 Nuno Sá          2022-10-12  1841   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1842   * Use with iio_device_release_buffer_mode().
16382e4ab8163f2 Nuno Sá          2022-10-12  1843   *
16382e4ab8163f2 Nuno Sá          2022-10-12  1844   * Returns: 0 on success, -EBUSY on failure.
16382e4ab8163f2 Nuno Sá          2022-10-12  1845   */
16382e4ab8163f2 Nuno Sá          2022-10-12  1846  int iio_device_claim_buffer_mode(struct iio_dev *indio_dev)
16382e4ab8163f2 Nuno Sá          2022-10-12  1847  {
16382e4ab8163f2 Nuno Sá          2022-10-12 @1848       mutex_lock(&indio_dev->mlock);
16382e4ab8163f2 Nuno Sá          2022-10-12  1849
16382e4ab8163f2 Nuno Sá          2022-10-12  1850       if (iio_buffer_enabled(indio_dev))
16382e4ab8163f2 Nuno Sá          2022-10-12 @1851               return 0;
16382e4ab8163f2 Nuno Sá          2022-10-12  1852
16382e4ab8163f2 Nuno Sá          2022-10-12  1853       mutex_unlock(&indio_dev->mlock);
16382e4ab8163f2 Nuno Sá          2022-10-12  1854       return -EBUSY;
16382e4ab8163f2 Nuno Sá          2022-10-12  1855  }
16382e4ab8163f2 Nuno Sá          2022-10-12  1856  EXPORT_SYMBOL_GPL(iio_device_claim_buffer_mode);
16382e4ab8163f2 Nuno Sá          2022-10-12  1857

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