[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aXMu6DMwRXjsjk6J@smile.fi.intel.com>
Date: Fri, 23 Jan 2026 10:18:48 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Tomas Melin <tomas.melin@...sala.com>
Cc: Michael Hennerich <Michael.Hennerich@...log.com>,
Nuno Sa <nuno.sa@...log.com>, Lars-Peter Clausen <lars@...afoo.de>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Andy Shevchenko <andy@...nel.org>,
Olivier Moysan <olivier.moysan@...s.st.com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 4/4] iio: adc: ad9467: check for backend capabilities
On Fri, Jan 23, 2026 at 09:10:20AM +0200, Tomas Melin wrote:
> On 21/01/2026 14:58, Andy Shevchenko wrote:
> > On Wed, Jan 21, 2026 at 12:08:33PM +0000, Tomas Melin wrote:
...
> >> static int __ad9467_update_clock(struct ad9467_state *st, long r_clk)
> >
> >> if (ret)
> >> return ret;
> >>
> >> - guard(mutex)(&st->lock);
> >
> > I would leave this as is. Yes, practically we don't need to cover
> > iio_backend_has_caps() with mutex to access the data, but it just makes code
> > slightly more maintainable in my opinion. If anything appears here, it would
> > probably mean some kind of if (...) do_blablabla(...); pattern that will need
> > a mutex.
>
> I have no strong opinion on this. Current option was chosen as it seemed
> cleaner in the sense that it a) takes the mutex only when needed and b)
> check for caps does not require the mutex to be held. Based on this I
> still suggest keeping as is but will change if you insist.
If you want your way, do not use guard()(). guard()() inside branches is
unintuitive and not the common way of doing it. Most likely you wanted
scoped_guard(). So, to me, guard() indented to more than 1 tab is suspicious
(I don't say it's forbidden or wrong).
> >> - return ad9467_calibrate(st);
> >> + if (iio_backend_has_caps(st->back, IIO_BACKEND_CAP_CALIBRATION)) {
> >> + guard(mutex)(&st->lock);
> >> + return ad9467_calibrate(st);
> >> + }
> >> + return 0;
> >> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists