Re: [PATCH v2 2/5] iio: code: mark iio_dev as const in iio_buffer_enabled

From: Jonathan Cameron
Date: Sat Apr 26 2025 - 11:45:45 EST


On Tue, 22 Apr 2025 13:34:47 +0200
Jorge Marques <jorge.marques@xxxxxxxxxx> wrote:

> The iio_dev struct is never modified inside the method, mark it as
> const.
> This allows to be called from get_current_scan_type, and is useful
> when the scan_type depends on the buffer state.
Now I'm confused. scan type is only relevant when the buffer is enabled
so how can it change as a result of that action?

Maybe all will become clear in later patches!

Jonathan

>
> Signed-off-by: Jorge Marques <jorge.marques@xxxxxxxxxx>
> ---
> drivers/iio/industrialio-core.c | 2 +-
> include/linux/iio/iio.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 178e99b111debc59a247fcc3a6037e429db3bebf..bc6a2ac6415eccf201e148ea98c0b5982787eb6d 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(iio_device_id);
> *
> * Returns: True, if the buffer is enabled.
> */
> -bool iio_buffer_enabled(struct iio_dev *indio_dev)
> +bool iio_buffer_enabled(const struct iio_dev *indio_dev)
> {
> struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
>
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 638cf2420fbd85cf2924d09d061df601d1d4bb2a..88569e1a888bde4d2bfb5b9f030096af1c15d68d 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -629,7 +629,7 @@ struct iio_dev {
>
> int iio_device_id(struct iio_dev *indio_dev);
> int iio_device_get_current_mode(struct iio_dev *indio_dev);
> -bool iio_buffer_enabled(struct iio_dev *indio_dev);
> +bool iio_buffer_enabled(const struct iio_dev *indio_dev);
>
> const struct iio_chan_spec
> *iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
>