On 6/8/21 2:35 PM, Andy Shevchenko wrote:
Hi!
Can anybody explain this code [1] in terms of atomicity?
if (!atomic_read(&trig->use_count)) {
atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
...
}
AFAIU how atomics are supposed to work the above doesn't do anything
atomically. I.o.w. use_count may be simple int with the same effect.
The operations here do not require atomic access, it is just operating
on a atomic type. The atomic access is the atomic_dec_and_test() in
iio_trigger_notify_done().