diff mbox series

[v2,1/4] iio: inkern: API for reading available iio channel attribute values

Message ID 20190323172809.14407-1-contact@artur-rojek.eu (mailing list archive)
State Not Applicable, archived
Headers show
Series [v2,1/4] iio: inkern: API for reading available iio channel attribute values | expand

Commit Message

Artur Rojek March 23, 2019, 5:28 p.m. UTC
Extend the inkern API with a function for reading available
attribute values of iio channels.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
---

Changes:

v2: no change

 drivers/iio/inkern.c         | 20 ++++++++++++++++++++
 include/linux/iio/consumer.h | 14 ++++++++++++++
 2 files changed, 34 insertions(+)

Comments

Jonathan Cameron March 24, 2019, 3:27 p.m. UTC | #1
On Sat, 23 Mar 2019 18:28:06 +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>
If this goes through a route other than IIO (otherwise
I'll just add a signed-off-by...)

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

> ---
> 
> Changes:
> 
> v2: no change
> 
>  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.
Jonathan Cameron April 14, 2019, 10:34 a.m. UTC | #2
On Sun, 24 Mar 2019 15:27:25 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sat, 23 Mar 2019 18:28:06 +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>  
> If this goes through a route other than IIO (otherwise
> I'll just add a signed-off-by...)
> 
> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Applied to the ib-jz47xx-prereq branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

I'll merge that into the togreg branch as well shortly.

Thanks,

Jonathan
> 
> > ---
> > 
> > Changes:
> > 
> > v2: no change
> > 
> >  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.  
>
Sebastian Reichel April 18, 2019, 7:47 p.m. UTC | #3
Hi,

On Sun, Apr 14, 2019 at 11:34:54AM +0100, Jonathan Cameron wrote:
> On Sun, 24 Mar 2019 15:27:25 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Sat, 23 Mar 2019 18:28:06 +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>  
> > If this goes through a route other than IIO (otherwise
> > I'll just add a signed-off-by...)
> > 
> > Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Applied to the ib-jz47xx-prereq branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> 
> I'll merge that into the togreg branch as well shortly.

Thanks, I pulled that branch into power-supply next for the
other two patches.

-- Sebastian
diff mbox series

Patch

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.