Re: [PATCH] iio: trigger: Avoid data race

From: Gyeyoung Baek
Date: Tue May 27 2025 - 17:10:46 EST


On Wed, May 28, 2025 at 5:25 AM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
>
> On Tue, May 27, 2025 at 10:05 PM Gyeyoung Baek <gye976@xxxxxxxxx> wrote:
> >
> > A data race could occur between `atomic_read()` and `atomic_set()`
> > Use `atomic_cmpxchg_relaxed()` to group them atomically.
> >
> > Previously the main logic was executed when `use_count` is 0.
> > Now it returns early when `use_count` is not 0.
>
> > - int i;
>
> I don't see the point in changing this line.
> ...
>
> > - int i;
>
> Ditto.
>
> ...
>
> At bare minimum they are not relevant to the patch change and haven't
> been described in the commit messages.

Hi Andy, thanks for your review.
I initially skipped this part as I thought it was minor.
But on a second look, it seems better to separate the declaration from
the logic.

What do you think about the data race logic? Would it make sense?

>
> --
> With Best Regards,
> Andy Shevchenko