Message ID | 20250422-iio-driver-ad4052-v2-2-638af47e9eb3@analog.com |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | Add support for AD4052 device family | expand |
On Tue, Apr 22, 2025 at 01:34:47PM +0200, Jorge Marques 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. Assuming it compiles and works, Reviewed-by: Andy Shevchenko <andy@kernel.org>
On Tue, 22 Apr 2025 13:34:47 +0200 Jorge Marques <jorge.marques@analog.com> 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@analog.com> > --- > 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); >
On Sat, Apr 26, 2025 at 04:45:24PM +0100, Jonathan Cameron wrote: > On Tue, 22 Apr 2025 13:34:47 +0200 > Jorge Marques <jorge.marques@analog.com> 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 Hi Jonathan, you are right, this commit will be dropped in v3. The driver scan type depends on oversampling value, so it has an has_ext_scan_type, and is only relevant for buffer readings. My mistake came to fruition from the fact the tool libiio at any context but local does not support changes to /sys /dev, including scan_type changes (it scans once at service start), so I kept getting odd behaviour that led me to the wrong solution. So, in summary for V3, the widths are set as follows: * spi_transfer.bits_per_word = scan_type.realbits * spi_transfer.len = scan_type.realbits == 24 ? 4 : 2 * scan_type.storagebits = 32: Used by tools, such as libiio, to compute number of samples. This ensures the minimum number of bytes transferred in the SPI bus, to optimize speed, while respecting SPI Engine Limitation of a fixed width (generally 32-bits). Similar to commit ce45446e520c85db022 (iio: adc: ad4000: Avoid potential double data word read) Regards, Jorge > > > > > Signed-off-by: Jorge Marques <jorge.marques@analog.com> > > --- > > 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); > > >
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);
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. Signed-off-by: Jorge Marques <jorge.marques@analog.com> --- drivers/iio/industrialio-core.c | 2 +- include/linux/iio/iio.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)