[PATCH v2 13/16] iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs
Andy Shevchenko
andy.shevchenko at gmail.com
Tue Oct 4 07:08:35 PDT 2022
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.)
> + return 0;
> +
> + mutex_unlock(&indio_dev->mlock);
> + return -EBUSY;
> +}
...
> +void iio_device_release_buffer_mode(struct iio_dev *indio_dev)
> +{
> + mutex_unlock(&indio_dev->mlock);
> +}
--
With Best Regards,
Andy Shevchenko
More information about the Linux-rockchip
mailing list