mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Olivier Moysan <olivier.moysan@foss.st.com>,
	fabrice.gasnier@foss.st.com,  Nuno Sa <nuno.sa@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/8] iio: add read raw service to iio backend framework
Date: Wed, 26 Jun 2024 10:50:00 +0200	[thread overview]
Message-ID: <0a5f82ad9ba032d03b389fce54360a82914c15af.camel@gmail.com> (raw)
In-Reply-To: <20240625150717.1038212-2-olivier.moysan@foss.st.com>

On Tue, 2024-06-25 at 17:07 +0200, Olivier Moysan wrote:
> Add iio_backend_read_raw() service to support attributes read
> from an IIO backend.
> 
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> ---
>  drivers/iio/industrialio-backend.c | 21 +++++++++++++++++++++
>  include/linux/iio/backend.h        |  6 +++++-
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-
> backend.c
> index 929aff4040ed..0e2653de1956 100644
> --- a/drivers/iio/industrialio-backend.c
> +++ b/drivers/iio/industrialio-backend.c
> @@ -357,6 +357,27 @@ int devm_iio_backend_request_buffer(struct device *dev,
>  }
>  EXPORT_SYMBOL_NS_GPL(devm_iio_backend_request_buffer, IIO_BACKEND);
>  
> +/**
> + * iio_backend_read_raw - Request a channel attribute from the IIO backend.
> + * @back:	Backend device
> + * @chan:	IIO channel reference
> + * @val:	First element of the returned value
> + * @val2:	Second element of the returned value
> + * @mask:	Specify value to retrieve
> + *
> + * This callback replicates the read_raw callback of the IIO framework, and
> is intended to
> + * request miscellaneous channel attributes from the backend device.
> + *
> + * RETURNS:
> + * 0 on success, negative error number on failure.
> + */
> +int iio_backend_read_raw(struct iio_backend *back, struct iio_chan_spec const
> *chan, int *val,
> +			 int *val2, long mask)
> +{
> +	return iio_backend_op_call(back, read_raw, chan, val, val2, mask);
> +}
> +EXPORT_SYMBOL_NS_GPL(iio_backend_read_raw, IIO_BACKEND);

I actually got an idea when looking at this for my existential crisis between
dedicated APIs and a catch all .read_raw() :). What we can do is just provide
the .read_raw() or write_raw() ops to backends (so we minimize the number of
ops) and then we build on top of them for providing more readable (depending on
the case; some cases it does make sense to just call iio_backend_read_raw())
APIs to frontends.

So in your case you could have in backend.h

static inline int iio_backend_read_scale(...)
{
	return iio_backend_read_raw(..., IIO_CHAN_INFO_SCALE);
}

Naturally no need for you to do this right now in your series. Just wanted to
write it down before I go into other stuff and forget about this :)

- Nuno Sá



  reply	other threads:[~2024-06-26  8:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 15:07 [PATCH v2 0/8] iio: adc: dfsdm: add scaling support Olivier Moysan
2024-06-25 15:07 ` [PATCH v2 1/8] iio: add read raw service to iio backend framework Olivier Moysan
2024-06-26  8:50   ` Nuno Sá [this message]
2024-06-26 16:12     ` Olivier MOYSAN
2024-06-29 18:48   ` Jonathan Cameron
2024-06-25 15:07 ` [PATCH v2 2/8] iio: add enable and disable services " Olivier Moysan
2024-06-25 15:07 ` [PATCH v2 3/8] iio: add child nodes support in " Olivier Moysan
2024-06-26  8:53   ` Nuno Sá
2024-06-29 18:54   ` Jonathan Cameron
2024-06-25 15:07 ` [PATCH v2 4/8] dt-bindings: iio: dfsdm: move to " Olivier Moysan
2024-06-28 21:35   ` Rob Herring
2024-07-03  8:28     ` Olivier MOYSAN
2024-06-25 15:07 ` [PATCH v2 5/8] dt-bindings: iio: add sigma delta modulator backend Olivier Moysan
2024-06-25 15:34   ` Conor Dooley
2024-06-26 16:40     ` Olivier MOYSAN
2024-06-27 16:13       ` Conor Dooley
2024-07-03  7:06         ` Olivier MOYSAN
2024-07-03  7:22         ` Olivier MOYSAN
2024-06-25 15:07 ` [PATCH v2 6/8] iio: adc: stm32-dfsdm: adopt generic channels bindings Olivier Moysan
2024-06-29 19:03   ` Jonathan Cameron
2024-06-25 15:07 ` [PATCH v2 7/8] iio: add sd modulator generic iio backend Olivier Moysan
2024-06-26  8:55   ` Nuno Sá
2024-06-25 15:07 ` [PATCH v2 8/8] iio: adc: stm32-dfsdm: add scaling support to dfsdm Olivier Moysan
2024-06-26  8:59   ` Nuno Sá
2024-06-26 16:15     ` Olivier MOYSAN

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=0a5f82ad9ba032d03b389fce54360a82914c15af.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=olivier.moysan@foss.st.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

all inboxes | Powered by JetHome®