[PATCH v2 13/16] iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs

Nuno Sá noname.nuno at gmail.com
Wed Oct 5 01:37:39 PDT 2022


On Tue, 2022-10-04 at 17:08 +0300, Andy Shevchenko wrote:
> On Tue, Oct 4, 2022 at 4:49 PM Nuno Sá <nuno.sa at analog.com> wrote:
> > 
> > These APIs are analogous to iio_device_claim_direct_mode() and
> > iio_device_release_direct_mode() but, as the name suggests, with
> > the
> > logic flipped. While this looks odd enough, it will have at least
> > two
> > users (in following changes) and it will be important to move the
> > iio
> > mlock to the private struct.
> 
> ...
> 
> > +int iio_device_claim_buffer_mode(struct iio_dev *indio_dev)
> > +{
> > +       mutex_lock(&indio_dev->mlock);
> > +
> > +       if (iio_buffer_enabled(indio_dev))
> 
> Do you need to annotate these two APIs to make sparse happy about
> locking balance?
> 
> (Try to run `make W=1 C=1 ...` with your patches and look if any new
> warnings appear.)

make W=1 C=1 drivers/iio/industrialio-core.o
#  UPD     include/config/kernel.release
  UPD     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CC      drivers/iio/industrialio-core.o
  CHECK   drivers/iio/industrialio-core.c
drivers/iio/industrialio-core.c: note: in included file (through
include/linux/bitops.h, include/linux/kernel.h):
./include/asm-generic/bitops/generic-non-atomic.h:30:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:31:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:33:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:33:16: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:28:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:39:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:40:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:42:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:42:16: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:37:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:57:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:58:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:60:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:60:15: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:55:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:75:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:76:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:77:9: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:79:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:79:14: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:79:20: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:80:17: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:80:23: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:80:9: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:73:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:95:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:96:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:97:9: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:99:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:99:14: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:99:21: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:100:17: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:100:23: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:100:9: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:93:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:107:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:108:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:109:9: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:111:10: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:111:14: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:111:20: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:112:17: warning:
unreplaced symbol 'old'
./include/asm-generic/bitops/generic-non-atomic.h:112:23: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:112:9: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:105:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:128:9: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:121:1: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:168:9: warning:
unreplaced symbol 'p'
./include/asm-generic/bitops/generic-non-atomic.h:169:9: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:170:9: warning:
unreplaced symbol 'val'
./include/asm-generic/bitops/generic-non-atomic.h:172:19: warning:
unreplaced symbol 'val'
./include/asm-generic/bitops/generic-non-atomic.h:172:25: warning:
unreplaced symbol 'mask'
./include/asm-generic/bitops/generic-non-atomic.h:172:9: warning:
unreplaced symbol 'return'
./include/asm-generic/bitops/generic-non-atomic.h:166:1: warning:
unreplaced symbol 'return'
drivers/iio/industrialio-core.c:2100: warning: expecting prototype for
iio_device_claim_buffered_mode(). Prototype was for
iio_device_claim_buffer_mode() instead

Don't really see anything odd in here... Am I missing something? 

Anyways, I guess you mean annotations as __acquires() and
__releases()... Well, this API is pretty much analogous to
iio_device_claim_direct_mode() which also don't have such annotations.
Thus, I would say to add them (if we are going too) in a future patch
to both APIs...

Also fine with adding them now if Jonathan feels it's necessary.

- Nuno Sá 




More information about the Linux-rockchip mailing list