Linux IIO development
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Jonathan Cameron <jic23@kernel.org>,
	Chris Morgan <macroalpha82@gmail.com>
Cc: linux-iio@vger.kernel.org, lars@metafoo.de,
	Chris Morgan <macromorgan@hotmail.com>
Subject: Re: [RFC] iio: multiplexer: Copy scan_type details from parent to child
Date: Tue, 19 Jul 2022 15:27:24 +0200	[thread overview]
Message-ID: <f845f910-fb46-e38e-b4e2-709ae4da006b@axentia.se> (raw)
In-Reply-To: <20220719095116.3dc46f3a@jic23-huawei>

Hi!

2022-07-19 at 10:51, Jonathan Cameron wrote:
> On Mon, 18 Jul 2022 13:43:12 -0500
> Chris Morgan <macroalpha82@gmail.com> wrote:
> 
>> From: Chris Morgan <macromorgan@hotmail.com>
>>
>> Copy the scan_type details from the parent iio channel to the child.
>> The scan_type is otherwise empty and things like the storagebits are
>> zero (which causes a problem for the adc-joystick driver which
>> validates the storagebits when used through a mux). I'm submitting this
>> as an RFC because I'm not sure if this is the correct way to handle
>> this scenario (a driver that checks the storagebits used with the iio
>> multiplexer).
>>
>> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> Seems sensible to me. Though Peter is expert on this one.

I really doubt that it is this simple. I'm no expert on buffered channels,
but after a quick look it certainly looks like adc-joystick requires
buffered channels. And iio-multiplexer does not support that at all. I
think it could be supported, but in that case the only obvious support
would be to support buffered channels one at a time, and the way I
read adc-joystick it expects to get one sample for each axes in one
go (i.e. the way "normal" ADCs deliver multiple parallel samples). See
e.g. the call to iio_channel_get_all_cb in adc-joystick, which dives
right into the buffered iio department.

So, the stuff in scan_type (along with scan_index, which is highly
related) is only relevant for buffered channels, and iio_multiplexer is
currently limited by its

	indio_dev->modes = INDIO_DIRECT_MODE;

which is ... not buffered. :-(

The simplest way forward is probably to lift the requirement of buffered
channels from adc-joystick, but that might be a hard sell as that driver
would then probably be a lot bigger and more complex.

That said, I would of course love to see the generic solution with support
for buffered channels in the mux, but my guess is that that gets much
more difficult, at least if you need the kind of buffered support
expected by adc-joystick.

Or, am I misreading the whole situation and you have actually gotten it
to work with the below one-liner? If it works, fine by me, but I think
you also need to do something with scan_index?

Cheers,
Peter

> One comment on the comment inline...
>> ---
>>  drivers/iio/multiplexer/iio-mux.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
>> index 93558fddfa9b..1de01ec878c4 100644
>> --- a/drivers/iio/multiplexer/iio-mux.c
>> +++ b/drivers/iio/multiplexer/iio-mux.c
>> @@ -322,6 +322,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
>>  	if (page)
>>  		devm_kfree(dev, page);
>>  
>> +	/* Copy scan type from parent to mux child. */
> Comment is in the obvious category, so drop that.
> 
>> +	chan->scan_type = pchan->scan_type;
>> +
>>  	return 0;
>>  }
>>  
> 

  reply	other threads:[~2022-07-19 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 18:43 [RFC] iio: multiplexer: Copy scan_type details from parent to child Chris Morgan
2022-07-19  8:51 ` Jonathan Cameron
2022-07-19 13:27   ` Peter Rosin [this message]
2022-07-19 14:19     ` Jonathan Cameron
2022-07-19 14:44       ` Chris Morgan
2022-07-19 17:54         ` Peter Rosin
2022-07-19 19:22           ` Chris Morgan
2022-07-20  8:25             ` 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=f845f910-fb46-e38e-b4e2-709ae4da006b@axentia.se \
    --to=peda@axentia.se \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=macroalpha82@gmail.com \
    --cc=macromorgan@hotmail.com \
    /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