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: <20250607180658.7db5271c@jic23-huawei>
Date: Sat, 7 Jun 2025 18:06:58 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Marcelo Schmitt <marcelo.schmitt@...log.com>
Cc: <linux-iio@...r.kernel.org>, <devicetree@...r.kernel.org>,
 <linux-gpio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
 <lars@...afoo.de>, <Michael.Hennerich@...log.com>, <dlechner@...libre.com>,
 <nuno.sa@...log.com>, <andy@...nel.org>, <robh@...nel.org>,
 <krzk+dt@...nel.org>, <conor+dt@...nel.org>, <linus.walleij@...aro.org>,
 <brgl@...ev.pl>, <marcelo.schmitt1@...il.com>
Subject: Re: [PATCH v4 06/11] iio: adc: ad4170: Add support for buffered
 data capture

On Mon, 2 Jun 2025 08:38:46 -0300
Marcelo Schmitt <marcelo.schmitt@...log.com> wrote:

> Extend the AD4170 driver to allow buffered data capture in continuous read
> mode. In continuous read mode, the chip skips the instruction phase and
> outputs just ADC sample data, enabling faster sample rates to be reached.
> The internal channel sequencer always starts sampling from channel 0 and
> channel 0 must be enabled if more than one channel is selected for data
> capture. The scan mask validation callback checks if the aforementioned
> condition is met.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@...log.com>

A comment inline about possibly relaxing the channel 0 constraint
as far as userspace is concerned anyway. Not necessary for now though.


> diff --git a/drivers/iio/adc/ad4170.c b/drivers/iio/adc/ad4170.c
> index 3d83c3ace569..86ef70acbf21 100644
> --- a/drivers/iio/adc/ad4170.c
> +++ b/drivers/iio/adc/ad4170.c
> @@ -13,7 +13,11 @@

> +static bool ad4170_validate_scan_mask(struct iio_dev *indio_dev,
> +				      const unsigned long *scan_mask)
> +{
> +	unsigned int masklength = iio_get_masklength(indio_dev);

If this becomes a useability issue we could probably generative appropriate
available_scan_masks entries and let the demuxer in the IIO core deal with
dropping the unwanted first channel.  That might be preferable to just
failing if the channel isn't enabled.

As a general rule, I think we've always used validate_scan_mask
to prevent too many channels being turned on, or incompatible sets of channels
rather than to prevent too few being enabled.

Anyhow that would be a relaxation of constraints so can be done if it
turns out to be needed later.

> +
> +	/*
> +	 * The channel sequencer cycles through the enabled channels in
> +	 * sequential order, from channel 0 to channel 15, bypassing disabled
> +	 * channels. When more than one channel is enabled, channel 0 must
> +	 * always be enabled. See datasheet channel_en register description at
> +	 * page 95.
> +	 */
> +	if (bitmap_weight(scan_mask, masklength) > 1)
> +		return test_bit(0, scan_mask);
> +
> +	return bitmap_weight(scan_mask, masklength) == 1;
> +}



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ