From: jic23@kernel.org (Jonathan Cameron)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 04/13] IIO: inkern: API for manipulating channel attributes
Date: Sat, 2 Dec 2017 14:46:23 +0000 [thread overview]
Message-ID: <20171202144623.27438bb2@archlinux> (raw)
In-Reply-To: <1512150020-20335-5-git-send-email-arnaud.pouliquen@st.com>
On Fri, 1 Dec 2017 18:40:11 +0100
Arnaud Pouliquen <arnaud.pouliquen@st.com> wrote:
> Extend the inkern API with functions for reading and writing
> attribute of iio channels.
>
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> ---
> V5 to V6 update:
> Replace include type.h with iio.h to fix build warning
Except don't do that. Consumers should not be able to see the internals
of iio devices.. Hence instead, move the required enum to types.h please.
One other passing comment inline (not one I'm expecting you to do anything
about!). Otherwise this is fine with me.
Thanks,
Jonathan
>
> drivers/iio/inkern.c | 18 +++++++++++++-----
> include/linux/iio/consumer.h | 28 +++++++++++++++++++++++++++-
> 2 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 069defc..f2e7824 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -664,9 +664,8 @@ int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
> }
> EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed);
>
> -static int iio_read_channel_attribute(struct iio_channel *chan,
> - int *val, int *val2,
> - enum iio_chan_info_enum attribute)
> +int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
> + enum iio_chan_info_enum attribute)
> {
> int ret;
>
> @@ -682,6 +681,8 @@ static int iio_read_channel_attribute(struct iio_channel *chan,
>
> return ret;
> }
> +EXPORT_SYMBOL_GPL(iio_read_channel_attribute);
> +
>
> int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2)
> {
> @@ -850,7 +851,8 @@ static int iio_channel_write(struct iio_channel *chan, int val, int val2,
> chan->channel, val, val2, info);
> }
>
> -int iio_write_channel_raw(struct iio_channel *chan, int val)
> +int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
> + enum iio_chan_info_enum attribute)
> {
> int ret;
>
> @@ -860,12 +862,18 @@ int iio_write_channel_raw(struct iio_channel *chan, int val)
> goto err_unlock;
> }
>
> - ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);
> + ret = iio_channel_write(chan, val, val2, attribute);
> err_unlock:
> mutex_unlock(&chan->indio_dev->info_exist_lock);
>
> return ret;
> }
> +EXPORT_SYMBOL_GPL(iio_write_channel_attribute);
> +
> +int iio_write_channel_raw(struct iio_channel *chan, int val)
> +{
> + return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_RAW);
> +}
> EXPORT_SYMBOL_GPL(iio_write_channel_raw);
>
> unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 5e347a9..70658b1 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -11,7 +11,7 @@
> #define _IIO_INKERN_CONSUMER_H_
>
> #include <linux/types.h>
> -#include <linux/iio/types.h>
> +#include <linux/iio/iio.h>
Hmm. Not keen on this include as it just exposed the internals
to IIO consumers which we really don't want to do.
This is to allow access to the enum iio_chan_info_enum?
Move it to types.h please.
>
> struct iio_dev;
> struct iio_chan_spec;
> @@ -216,6 +216,32 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
> int iio_read_channel_processed(struct iio_channel *chan, int *val);
>
> /**
> + * iio_write_channel_attribute() - Write values to the device attribute.
> + * @chan: The channel being queried.
> + * @val: Value being written.
> + * @val2: Value being written.val2 use depends on attribute type.
> + * @attribute: info attribute to be read.
> + *
> + * Returns an error code or 0.
> + */
> +int iio_write_channel_attribute(struct iio_channel *chan, int val,
> + int val2, enum iio_chan_info_enum attribute);
> +
> +/**
> + * iio_read_channel_attribute() - Read values from the device attribute.
> + * @chan: The channel being queried.
> + * @val: Value being written.
> + * @val2: Value being written.Val2 use depends on attribute type.
This pretty much highlights that we are still missing a function to allow us
to query what form write data should be presented in...
Here we have tightly coupled hardware so we know the answer, but in general
we don't.
Still can be a follow up patch when someone needs it.
> + * @attribute: info attribute to be written.
> + *
> + * Returns an error code if failed. Else returns a description of what is in val
> + * and val2, such as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
> + * + val2/1e6
> + */
> +int iio_read_channel_attribute(struct iio_channel *chan, int *val,
> + int *val2, enum iio_chan_info_enum attribute);
> +
> +/**
> * iio_write_channel_raw() - write to a given channel
> * @chan: The channel being queried.
> * @val: Value being written.
next prev parent reply other threads:[~2017-12-02 14:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 17:40 [PATCH v6 00/13] Add STM32 DFSDM support Arnaud Pouliquen
2017-12-01 17:40 ` [PATCH v6 01/13] iio: Add hardware consumer buffer support Arnaud Pouliquen
2017-12-02 14:50 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 02/13] docs: driver-api: add iio hw consumer section Arnaud Pouliquen
2017-12-02 14:51 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 03/13] IIO: hw_consumer: add devm_iio_hw_consumer_alloc Arnaud Pouliquen
2017-12-02 14:52 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 04/13] IIO: inkern: API for manipulating channel attributes Arnaud Pouliquen
2017-12-02 14:46 ` Jonathan Cameron [this message]
2017-12-01 17:40 ` [PATCH v6 05/13] IIO: Add DT bindings for sigma delta adc modulator Arnaud Pouliquen
2017-12-02 14:52 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 06/13] IIO: ADC: add sigma delta modulator support Arnaud Pouliquen
2017-12-02 14:54 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 07/13] IIO: add DT bindings for stm32 DFSDM filter Arnaud Pouliquen
2017-12-02 14:55 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 08/13] IIO: ADC: add stm32 DFSDM core support Arnaud Pouliquen
2017-12-01 17:40 ` [PATCH v6 09/13] IIO: ADC: add STM32 DFSDM sigma delta ADC support Arnaud Pouliquen
2017-12-02 14:58 ` Jonathan Cameron
2017-12-01 17:40 ` [PATCH v6 10/13] IIO: ADC: add stm32 DFSDM support for PDM microphone Arnaud Pouliquen
2017-12-01 17:40 ` [PATCH v6 11/13] IIO: consumer: allow to set buffer sizes Arnaud Pouliquen
2017-12-01 17:40 ` [PATCH v6 12/13] ASoC: add bindings for stm32 DFSDM filter Arnaud Pouliquen
2017-12-04 21:51 ` Rob Herring
2017-12-01 17:40 ` [PATCH v6 13/13] ASoC: stm32: add DFSDM DAI support Arnaud Pouliquen
2017-12-02 15:09 ` Jonathan Cameron
2017-12-04 8:58 ` Arnaud Pouliquen
2017-12-04 16:58 ` Mark Brown
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=20171202144623.27438bb2@archlinux \
--to=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).