linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Artur Rojek <contact@artur-rojek.eu>
Cc: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-pm@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paul Cercueil <paul@crapouillou.net>
Subject: Re: [PATCH 1/7] iio: inkern: API for reading available iio channel attribute values
Date: Wed, 20 Feb 2019 11:14:54 +0000	[thread overview]
Message-ID: <20190220111447.31a6cdb7@archlinux> (raw)
In-Reply-To: <20190217142914.17433-1-contact@artur-rojek.eu>

On Sun, 17 Feb 2019 15:29:10 +0100
Artur Rojek <contact@artur-rojek.eu> wrote:

> Extend the inkern API with a function for reading available
> attribute values of iio channels.
> 
> Signed-off-by: Artur Rojek <contact@artur-rojek.eu>

Hmm. It would have been cleaner if we'd done the generic version
in the first place rather than just having the raw value
equivalent of this.

Would you mind sending a follow up patch to convert that call
over to a simple stub around this function?
The alternative would be to convert the few users over to this
function.  Hmm. Probably best to just share the code as much as
possible and for now leave the old function in place.

Anyhow, this looks good ;)

Given the battery driver is tied up with this, it will make sense
for them to go together.  Probably a case for an immutable branch
either in iio or the relevant battery tree.

Assuming it'll be the battery tree.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The cleanup suggested above can follow at some later time.

Thanks,

Jonathan


> ---
>  drivers/iio/inkern.c         | 20 ++++++++++++++++++++
>  include/linux/iio/consumer.h | 14 ++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 06ca3f7fcc44..f19dbde3c945 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -733,6 +733,26 @@ static int iio_channel_read_avail(struct iio_channel *chan,
>  						 vals, type, length, info);
>  }
>  
> +int iio_read_avail_channel_attribute(struct iio_channel *chan,
> +				     const int **vals, int *type, int *length,
> +				     enum iio_chan_info_enum attribute)
> +{
> +	int ret;
> +
> +	mutex_lock(&chan->indio_dev->info_exist_lock);
> +	if (!chan->indio_dev->info) {
> +		ret = -ENODEV;
> +		goto err_unlock;
> +	}
> +
> +	ret = iio_channel_read_avail(chan, vals, type, length, attribute);
> +err_unlock:
> +	mutex_unlock(&chan->indio_dev->info_exist_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute);
> +
>  int iio_read_avail_channel_raw(struct iio_channel *chan,
>  			       const int **vals, int *length)
>  {
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 9887f4f8e2a8..b2d34831ed7c 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -290,6 +290,20 @@ int iio_read_max_channel_raw(struct iio_channel *chan, int *val);
>  int iio_read_avail_channel_raw(struct iio_channel *chan,
>  			       const int **vals, int *length);
>  
> +/**
> + * iio_read_avail_channel_attribute() - read available channel attribute values
> + * @chan:		The channel being queried.
> + * @vals:		Available values read back.
> + * @type:		Type of values read back.
> + * @length:		Number of entries in vals.
> + * @attribute:		info attribute to be read back.
> + *
> + * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST.
> + */
> +int iio_read_avail_channel_attribute(struct iio_channel *chan,
> +				     const int **vals, int *type, int *length,
> +				     enum iio_chan_info_enum attribute);
> +
>  /**
>   * iio_get_channel_type() - get the type of a channel
>   * @channel:		The channel being queried.


      parent reply	other threads:[~2019-02-20 11:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-17 14:29 [PATCH 1/7] iio: inkern: API for reading available iio channel attribute values Artur Rojek
2019-02-17 14:29 ` [PATCH 2/7] power: supply: core: Add a field to support battery max voltage Artur Rojek
2019-02-17 14:29 ` [PATCH 3/7] dt-bindings: power: supply: Add voltage-max-design-microvolt property Artur Rojek
2019-02-17 14:29 ` [PATCH 4/7] dt-bindings: power: supply: Add docs for Ingenic JZ47xx SoCs battery Artur Rojek
2019-02-28 18:48   ` Rob Herring
2019-02-28 18:56     ` Paul Cercueil
2019-02-28 20:22     ` Artur Rojek
2019-02-17 14:29 ` [PATCH 5/7] power: supply: add Ingenic JZ47xx battery driver Artur Rojek
2019-02-20 11:14   ` Jonathan Cameron
2019-02-20 15:24     ` Artur Rojek
2019-02-21 19:18     ` Artur Rojek
2019-03-03 16:53       ` Jonathan Cameron
2019-02-17 14:37 ` [PATCH 1/7] iio: inkern: API for reading available iio channel attribute values Artur Rojek
2019-02-20 11:14 ` Jonathan Cameron [this message]

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=20190220111447.31a6cdb7@archlinux \
    --to=jic23@kernel.org \
    --cc=contact@artur-rojek.eu \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=paul@crapouillou.net \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.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).