* [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
@ 2024-10-02 15:34 David Lechner
2024-10-03 23:26 ` kernel test robot
0 siblings, 1 reply; 4+ messages in thread
From: David Lechner @ 2024-10-02 15:34 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Dan Williams, David Lechner
Add __must_check attribute to iio_device_claim_direct_mode().
Since we have now DEFINE_GUARD(iio_claim_direct, ...,
iio_device_claim_direct_mode, ...), it is possible to write:
guard(iio_claim_direct)(indio_dev);
This would be a bug, since the return value is not checked. Adding
__must_check to iio_device_claim_direct_mode() makes the compiler emit
a warning for the above code.
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
This comes from the suggestion at the end of [1]. It seems like a
reasonable thing to do regardless if the other series works out or not,
so submitting it separately.
[1]: https://lore.kernel.org/all/66fcac2dbde60_964f229426@dwillia2-xfh.jf.intel.com.notmuch/
---
include/linux/iio/iio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 18779b631e90..2dc6470d20a4 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -659,7 +659,7 @@ void iio_device_unregister(struct iio_dev *indio_dev);
int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev,
struct module *this_mod);
int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
-int iio_device_claim_direct_mode(struct iio_dev *indio_dev);
+__must_check int iio_device_claim_direct_mode(struct iio_dev *indio_dev);
void iio_device_release_direct_mode(struct iio_dev *indio_dev);
/*
---
base-commit: 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e
change-id: 20241002-iio-must-check-claim-direct-e6988a195368
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
2024-10-02 15:34 [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check David Lechner
@ 2024-10-03 23:26 ` kernel test robot
2024-10-04 17:57 ` Dan Williams
0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2024-10-03 23:26 UTC (permalink / raw)
To: David Lechner, Jonathan Cameron
Cc: llvm, oe-kbuild-all, linux-iio, linux-kernel, Dan Williams,
David Lechner
Hi David,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e]
url: https://github.com/intel-lab-lkp/linux/commits/David-Lechner/iio-core-make-iio_device_claim_direct_mode-__must_check/20241002-233644
base: 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e
patch link: https://lore.kernel.org/r/20241002-iio-must-check-claim-direct-v1-1-ab94ce728731%40baylibre.com
patch subject: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
config: arm-randconfig-001-20241004 (https://download.01.org/0day-ci/archive/20241004/202410040721.upAHwZJm-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project fef3566a25ff0e34fb87339ba5e13eca17cec00f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241004/202410040721.upAHwZJm-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410040721.upAHwZJm-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/iio/pressure/bmp280-regmap.c:6:
In file included from drivers/iio/pressure/bmp280.h:5:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/iio/pressure/bmp280-regmap.c:6:
In file included from drivers/iio/pressure/bmp280.h:7:
>> include/linux/iio/iio.h:669:50: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
669 | DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
include/linux/cleanup.h:291:54: note: expanded from macro 'DEFINE_GUARD'
291 | DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
| ^~~~~
include/linux/cleanup.h:248:13: note: expanded from macro 'DEFINE_CLASS'
248 | { _type t = _init; return t; }
| ^~~~~
2 warnings generated.
--
In file included from drivers/iio/pressure/ms5611_core.c:14:
>> include/linux/iio/iio.h:669:50: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
669 | DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
include/linux/cleanup.h:291:54: note: expanded from macro 'DEFINE_GUARD'
291 | DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
| ^~~~~
include/linux/cleanup.h:248:13: note: expanded from macro 'DEFINE_CLASS'
248 | { _type t = _init; return t; }
| ^~~~~
In file included from drivers/iio/pressure/ms5611_core.c:16:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
2 warnings generated.
--
In file included from drivers/iio/pressure/mpl115.c:11:
>> include/linux/iio/iio.h:669:50: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
669 | DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
include/linux/cleanup.h:291:54: note: expanded from macro 'DEFINE_GUARD'
291 | DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
| ^~~~~
include/linux/cleanup.h:248:13: note: expanded from macro 'DEFINE_CLASS'
248 | { _type t = _init; return t; }
| ^~~~~
1 warning generated.
vim +/warn_unused_result +669 include/linux/iio/iio.h
1dae0cb79ceacb Jonathan Cameron 2024-01-28 664
1dae0cb79ceacb Jonathan Cameron 2024-01-28 665 /*
1dae0cb79ceacb Jonathan Cameron 2024-01-28 666 * This autocleanup logic is normally used via
1dae0cb79ceacb Jonathan Cameron 2024-01-28 667 * iio_device_claim_direct_scoped().
1dae0cb79ceacb Jonathan Cameron 2024-01-28 668 */
1dae0cb79ceacb Jonathan Cameron 2024-01-28 @669 DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
1dae0cb79ceacb Jonathan Cameron 2024-01-28 670 iio_device_release_direct_mode(_T))
1dae0cb79ceacb Jonathan Cameron 2024-01-28 671
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
2024-10-03 23:26 ` kernel test robot
@ 2024-10-04 17:57 ` Dan Williams
2024-10-04 19:12 ` David Lechner
0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2024-10-04 17:57 UTC (permalink / raw)
To: kernel test robot, David Lechner, Jonathan Cameron
Cc: llvm, oe-kbuild-all, linux-iio, linux-kernel, Dan Williams,
David Lechner
kernel test robot wrote:
> Hi David,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e]
>
> url: https://github.com/intel-lab-lkp/linux/commits/David-Lechner/iio-core-make-iio_device_claim_direct_mode-__must_check/20241002-233644
> base: 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e
> patch link: https://lore.kernel.org/r/20241002-iio-must-check-claim-direct-v1-1-ab94ce728731%40baylibre.com
> patch subject: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
[..]
> >> include/linux/iio/iio.h:669:50: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
> 669 | DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
So I think this points to the fact that iio_device_claim_direct_mode()
should not be using DEFINE_GUARD() in the first instance. I think
iio_claim_direct() really wants to be using DEFINE_CLASS() directly.
Skip usage of DEFINE_GUARD() which I now see is unable to interoperate
with a __must_check locking function.
Perhaps the new class can be something like:
DEFINE_GUARD_EXCL_COND()
...which creates a guard that is exclusively conditional and has no
unconditional flavor. However, maybe that only lives in iio unless and
until another user arrives.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
2024-10-04 17:57 ` Dan Williams
@ 2024-10-04 19:12 ` David Lechner
0 siblings, 0 replies; 4+ messages in thread
From: David Lechner @ 2024-10-04 19:12 UTC (permalink / raw)
To: Dan Williams, kernel test robot, Jonathan Cameron
Cc: llvm, oe-kbuild-all, linux-iio, linux-kernel
On 10/4/24 12:57 PM, Dan Williams wrote:
> kernel test robot wrote:
>> Hi David,
>>
>> kernel test robot noticed the following build warnings:
>>
>> [auto build test WARNING on 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e]
>>
>> url: https://github.com/intel-lab-lkp/linux/commits/David-Lechner/iio-core-make-iio_device_claim_direct_mode-__must_check/20241002-233644
>> base: 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e
>> patch link: https://lore.kernel.org/r/20241002-iio-must-check-claim-direct-v1-1-ab94ce728731%40baylibre.com
>> patch subject: [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check
> [..]
>>>> include/linux/iio/iio.h:669:50: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
>> 669 | DEFINE_GUARD(iio_claim_direct, struct iio_dev *, iio_device_claim_direct_mode(_T),
>
> So I think this points to the fact that iio_device_claim_direct_mode()
> should not be using DEFINE_GUARD() in the first instance. I think
> iio_claim_direct() really wants to be using DEFINE_CLASS() directly.
> Skip usage of DEFINE_GUARD() which I now see is unable to interoperate
> with a __must_check locking function.
>
> Perhaps the new class can be something like:
>
> DEFINE_GUARD_EXCL_COND()
>
> ...which creates a guard that is exclusively conditional and has no
> unconditional flavor. However, maybe that only lives in iio unless and
> until another user arrives.
Hmm... I see what you mean. All other conditional guards (e.g.
mutex_trylock) have an unconditional counterpart (mutex_lock)
that is used with DEFINE_GUARD.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-04 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-02 15:34 [PATCH] iio: core: make iio_device_claim_direct_mode() __must_check David Lechner
2024-10-03 23:26 ` kernel test robot
2024-10-04 17:57 ` Dan Williams
2024-10-04 19:12 ` David Lechner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®