lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <o5uaw756dho7v76pzvkn7ukfpsam4vmaryzvmtxmfehu7hnqa7@ppasiqfu44rq>
Date: Mon, 2 Jun 2025 11:48:26 +0200
From: Jorge Marques <gastmaier@...il.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Jorge Marques <jorge.marques@...log.com>, 
	Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>, 
	Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, 
	Conor Dooley <conor+dt@...nel.org>, Jonathan Corbet <corbet@....net>, 
	David Lechner <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, 
	Andy Shevchenko <andy@...nel.org>, Uwe Kleine-König <ukleinek@...nel.org>, 
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-doc@...r.kernel.org, linux-pwm@...r.kernel.org
Subject: Re: [PATCH v2 2/5] iio: code: mark iio_dev as const in
 iio_buffer_enabled

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@...log.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@...log.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);
> > 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ