All of lore.kernel.org
 help / color / mirror / Atom feed
* atomic use is not atomic?
@ 2021-06-08 12:35 Andy Shevchenko
  2021-06-08 12:44 ` Lars-Peter Clausen
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-06-08 12:35 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald

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.

What did I miss?

[1]: https://elixir.bootlin.com/linux/latest/source/drivers/iio/industrialio-trigger.c#L166

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-08 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 12:35 atomic use is not atomic? Andy Shevchenko
2021-06-08 12:44 ` Lars-Peter Clausen
2021-06-08 13:14   ` Andy Shevchenko
2021-06-08 13:22     ` Lars-Peter Clausen
2021-06-08 13:30       ` Andy Shevchenko
2021-06-08 16:00         ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.