linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: Require strict scan mask matching in hardware mode
Date: Mon, 01 Jun 2015 11:34:46 +0100	[thread overview]
Message-ID: <556C3546.4020300@kernel.org> (raw)
In-Reply-To: <1432916062-15195-4-git-send-email-lars@metafoo.de>

On 29/05/15 17:14, Lars-Peter Clausen wrote:
> In hardware mode we can not use the software demuxer, this means that the
> selected scan mask needs to match one of the available scan masks exactly.
> 
> It also means that all attached buffers need to use the same scan mask.
> Given that when operating in hardware mode there is typically only a single
> buffer attached to the device this not an issue. Add a sanity check to make
> sure that only a single buffer is attached in hardware mode nevertheless.
> 
That pretty much sums up why devices supporting only hardware buffers
are probably not going to be a long term feature!
Mind you for fast devices we may want to allow forced bypassing of the
demux (i.e. a hardware buffer).

Out of curiosity is this series a precursor to another hardware buffered
device or just a useful intellectual exercise?


Applied. 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
>  drivers/iio/industrialio-buffer.c | 25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 4250e97..e174fcc 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -239,13 +239,19 @@ static ssize_t iio_scan_el_show(struct device *dev,
>  /* Note NULL used as error indicator as it doesn't make sense. */
>  static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks,
>  					  unsigned int masklength,
> -					  const unsigned long *mask)
> +					  const unsigned long *mask,
> +					  bool strict)
>  {
>  	if (bitmap_empty(mask, masklength))
>  		return NULL;
>  	while (*av_masks) {
> -		if (bitmap_subset(mask, av_masks, masklength))
> -			return av_masks;
> +		if (strict) {
> +			if (bitmap_equal(mask, av_masks, masklength))
> +				return av_masks;
> +		} else {
> +			if (bitmap_subset(mask, av_masks, masklength))
> +				return av_masks;
> +		}
>  		av_masks += BITS_TO_LONGS(masklength);
>  	}
>  	return NULL;
> @@ -295,7 +301,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
>  	if (indio_dev->available_scan_masks) {
>  		mask = iio_scan_mask_match(indio_dev->available_scan_masks,
>  					   indio_dev->masklength,
> -					   trialmask);
> +					   trialmask, false);
>  		if (!mask)
>  			goto err_invalid_mask;
>  	}
> @@ -602,6 +608,7 @@ static int iio_verify_update(struct iio_dev *indio_dev,
>  {
>  	unsigned long *compound_mask;
>  	const unsigned long *scan_mask;
> +	bool strict_scanmask = false;
>  	struct iio_buffer *buffer;
>  	bool scan_timestamp;
>  	unsigned int modes;
> @@ -631,7 +638,14 @@ static int iio_verify_update(struct iio_dev *indio_dev,
>  	if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
>  		config->mode = INDIO_BUFFER_TRIGGERED;
>  	} else if (modes & INDIO_BUFFER_HARDWARE) {
> +		/*
> +		 * Keep things simple for now and only allow a single buffer to
> +		 * be connected in hardware mode.
> +		 */
> +		if (insert_buffer && !list_empty(&indio_dev->buffer_list))
> +			return -EINVAL;
>  		config->mode = INDIO_BUFFER_HARDWARE;
> +		strict_scanmask = true;
>  	} else if (modes & INDIO_BUFFER_SOFTWARE) {
>  		config->mode = INDIO_BUFFER_SOFTWARE;
>  	} else {
> @@ -666,7 +680,8 @@ static int iio_verify_update(struct iio_dev *indio_dev,
>  	if (indio_dev->available_scan_masks) {
>  		scan_mask = iio_scan_mask_match(indio_dev->available_scan_masks,
>  				    indio_dev->masklength,
> -				    compound_mask);
> +				    compound_mask,
> +				    strict_scanmask);
>  		kfree(compound_mask);
>  		if (scan_mask == NULL)
>  			return -EINVAL;
> 


  reply	other threads:[~2015-06-01 21:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29 16:14 [PATCH 0/3] iio: Hardware buffer improvements Lars-Peter Clausen
2015-05-29 16:14 ` [PATCH 1/3] iio: Always compute masklength Lars-Peter Clausen
2015-06-01 10:28   ` Jonathan Cameron
2015-05-29 16:14 ` [PATCH 2/3] iio: Specify supported modes for buffers Lars-Peter Clausen
2015-06-01 10:31   ` Jonathan Cameron
2016-01-01 17:50   ` Jonathan Cameron
2015-05-29 16:14 ` [PATCH 3/3] iio: Require strict scan mask matching in hardware mode Lars-Peter Clausen
2015-06-01 10:34   ` Jonathan Cameron [this message]
2015-06-03 17:19     ` Lars-Peter Clausen
2015-06-06 21:07       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556C3546.4020300@kernel.org \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).