diff mbox

[v5,04/13] IIO: inkern: API for manipulating channel attributes

Message ID 1511881557-28596-5-git-send-email-arnaud.pouliquen@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arnaud POULIQUEN Nov. 28, 2017, 3:05 p.m. UTC
Extend the inkern API with functions for reading and writing
attribute of iio channels.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/iio/inkern.c         | 18 +++++++++++++-----
 include/linux/iio/consumer.h | 26 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)

Comments

Phil Reid Nov. 29, 2017, 6:20 a.m. UTC | #1
On 28/11/2017 23:05, Arnaud Pouliquen wrote:
> Extend the inkern API with functions for reading and writing
> attribute of iio channels.

I submitted a similar patch a while ago and never followed up with a v2.
This will address the same thing, nice.
> 
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> ---
>   drivers/iio/inkern.c         | 18 +++++++++++++-----
>   include/linux/iio/consumer.h | 26 ++++++++++++++++++++++++++
>   2 files changed, 39 insertions(+), 5 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..2017f35 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -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.
i think s/read/written/

> + *
> + * 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.
> + * @attribute:	info attribute to be written.
and also s/written/read/

> + *
> + * 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.
>
kernel test robot Dec. 1, 2017, 2:41 p.m. UTC | #2
Hi Arnaud,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on iio/togreg]
[also build test WARNING on v4.15-rc1 next-20171201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnaud-Pouliquen/Add-STM32-DFSDM-support/20171201-215409
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/iio//adc/envelope-detector.c:38:0:
>> include/linux/iio/consumer.h:228:20: warning: 'enum iio_chan_info_enum' declared inside parameter list
        int val2, enum iio_chan_info_enum attribute);
                       ^
>> include/linux/iio/consumer.h:228:20: warning: its scope is only this definition or declaration, which is probably not what you want
   include/linux/iio/consumer.h:242:27: warning: 'enum iio_chan_info_enum' declared inside parameter list
              int *val2, enum iio_chan_info_enum attribute);
                              ^

vim +228 include/linux/iio/consumer.h

   217	
   218	/**
   219	 * iio_write_channel_attribute() - Write values to the device attribute.
   220	 * @chan:	The channel being queried.
   221	 * @val:	Value being written.
   222	 * @val2:	Value being written.val2 use depends on attribute type.
   223	 * @attribute:	info attribute to be read.
   224	 *
   225	 * Returns an error code or 0.
   226	 */
   227	int iio_write_channel_attribute(struct iio_channel *chan, int val,
 > 228					int val2, enum iio_chan_info_enum attribute);
   229	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Dec. 1, 2017, 3:12 p.m. UTC | #3
Hi Arnaud,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on iio/togreg]
[also build test WARNING on v4.15-rc1 next-20171201]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnaud-Pouliquen/Add-STM32-DFSDM-support/20171201-215409
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: x86_64-randconfig-x012-201748 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from drivers/iio/adc/envelope-detector.c:38:0:
>> include/linux/iio/consumer.h:228:20: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
        int val2, enum iio_chan_info_enum attribute);
                       ^~~~~~~~~~~~~~~~~~
   include/linux/iio/consumer.h:242:27: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
              int *val2, enum iio_chan_info_enum attribute);
                              ^~~~~~~~~~~~~~~~~~
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 include/linux/kernel.h:kstrtoul
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock_irq
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irq
   Cyclomatic Complexity 1 include/linux/completion.h:__init_completion
   Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
   Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
   Cyclomatic Complexity 1 include/linux/workqueue.h:queue_delayed_work
   Cyclomatic Complexity 1 include/linux/workqueue.h:schedule_delayed_work
   Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
   Cyclomatic Complexity 2 include/linux/device.h:dev_name
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_priv
   Cyclomatic Complexity 1 include/linux/irq.h:irqd_get_trigger_type
   Cyclomatic Complexity 2 include/linux/irq.h:irq_get_trigger_type
   Cyclomatic Complexity 1 include/linux/interrupt.h:devm_request_irq
   Cyclomatic Complexity 1 include/linux/platform_device.h:platform_set_drvdata
   Cyclomatic Complexity 1 drivers/iio/adc/envelope-detector.c:envelope_detector_driver_init
   Cyclomatic Complexity 15 drivers/iio/adc/envelope-detector.c:envelope_detector_probe
   Cyclomatic Complexity 1 drivers/iio/adc/envelope-detector.c:envelope_detector_comp_isr
   Cyclomatic Complexity 3 drivers/iio/adc/envelope-detector.c:envelope_store_comp_interval
   Cyclomatic Complexity 1 drivers/iio/adc/envelope-detector.c:envelope_show_comp_interval
   Cyclomatic Complexity 1 drivers/iio/adc/envelope-detector.c:envelope_show_invert
   Cyclomatic Complexity 6 drivers/iio/adc/envelope-detector.c:envelope_store_invert
   Cyclomatic Complexity 3 drivers/iio/adc/envelope-detector.c:envelope_detector_comp_latch
   Cyclomatic Complexity 5 drivers/iio/adc/envelope-detector.c:envelope_detector_setup_compare
   Cyclomatic Complexity 5 drivers/iio/adc/envelope-detector.c:envelope_detector_read_raw
   Cyclomatic Complexity 3 drivers/iio/adc/envelope-detector.c:envelope_detector_timeout
   Cyclomatic Complexity 1 drivers/iio/adc/envelope-detector.c:envelope_detector_driver_exit
--
   In file included from drivers/iio/multiplexer/iio-mux.c:14:0:
>> include/linux/iio/consumer.h:228:20: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
        int val2, enum iio_chan_info_enum attribute);
                       ^~~~~~~~~~~~~~~~~~
   include/linux/iio/consumer.h:242:27: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
              int *val2, enum iio_chan_info_enum attribute);
                              ^~~~~~~~~~~~~~~~~~
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
   Cyclomatic Complexity 1 include/linux/device.h:devm_kzalloc
   Cyclomatic Complexity 2 include/linux/device.h:dev_name
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_channel_has_info
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_channel_has_available
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_priv
   Cyclomatic Complexity 1 include/linux/platform_device.h:platform_set_drvdata
   Cyclomatic Complexity 1 drivers/iio/multiplexer/iio-mux.c:mux_driver_init
   Cyclomatic Complexity 7 drivers/iio/multiplexer/iio-mux.c:iio_mux_select
   Cyclomatic Complexity 1 drivers/iio/multiplexer/iio-mux.c:iio_mux_deselect
   Cyclomatic Complexity 5 drivers/iio/multiplexer/iio-mux.c:mux_write_ext_info
   Cyclomatic Complexity 2 drivers/iio/multiplexer/iio-mux.c:mux_read_ext_info
   Cyclomatic Complexity 3 drivers/iio/multiplexer/iio-mux.c:mux_write_raw
   Cyclomatic Complexity 3 drivers/iio/multiplexer/iio-mux.c:mux_read_avail
   Cyclomatic Complexity 4 drivers/iio/multiplexer/iio-mux.c:mux_read_raw
   Cyclomatic Complexity 16 drivers/iio/multiplexer/iio-mux.c:mux_configure_channel
   Cyclomatic Complexity 20 drivers/iio/multiplexer/iio-mux.c:mux_probe
   Cyclomatic Complexity 1 drivers/iio/multiplexer/iio-mux.c:mux_driver_exit
--
   In file included from drivers/iio//adc/envelope-detector.c:38:0:
>> include/linux/iio/consumer.h:228:20: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
        int val2, enum iio_chan_info_enum attribute);
                       ^~~~~~~~~~~~~~~~~~
   include/linux/iio/consumer.h:242:27: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
              int *val2, enum iio_chan_info_enum attribute);
                              ^~~~~~~~~~~~~~~~~~
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 include/linux/kernel.h:kstrtoul
   Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock_irq
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irq
   Cyclomatic Complexity 1 include/linux/completion.h:__init_completion
   Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
   Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
   Cyclomatic Complexity 1 include/linux/workqueue.h:queue_delayed_work
   Cyclomatic Complexity 1 include/linux/workqueue.h:schedule_delayed_work
   Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
   Cyclomatic Complexity 2 include/linux/device.h:dev_name
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_priv
   Cyclomatic Complexity 1 include/linux/irq.h:irqd_get_trigger_type
   Cyclomatic Complexity 2 include/linux/irq.h:irq_get_trigger_type
   Cyclomatic Complexity 1 include/linux/interrupt.h:devm_request_irq
   Cyclomatic Complexity 1 include/linux/platform_device.h:platform_set_drvdata
   Cyclomatic Complexity 1 drivers/iio//adc/envelope-detector.c:envelope_detector_driver_init
   Cyclomatic Complexity 15 drivers/iio//adc/envelope-detector.c:envelope_detector_probe
   Cyclomatic Complexity 1 drivers/iio//adc/envelope-detector.c:envelope_detector_comp_isr
   Cyclomatic Complexity 3 drivers/iio//adc/envelope-detector.c:envelope_store_comp_interval
   Cyclomatic Complexity 1 drivers/iio//adc/envelope-detector.c:envelope_show_comp_interval
   Cyclomatic Complexity 1 drivers/iio//adc/envelope-detector.c:envelope_show_invert
   Cyclomatic Complexity 6 drivers/iio//adc/envelope-detector.c:envelope_store_invert
   Cyclomatic Complexity 3 drivers/iio//adc/envelope-detector.c:envelope_detector_comp_latch
   Cyclomatic Complexity 5 drivers/iio//adc/envelope-detector.c:envelope_detector_setup_compare
   Cyclomatic Complexity 5 drivers/iio//adc/envelope-detector.c:envelope_detector_read_raw
   Cyclomatic Complexity 3 drivers/iio//adc/envelope-detector.c:envelope_detector_timeout
   Cyclomatic Complexity 1 drivers/iio//adc/envelope-detector.c:envelope_detector_driver_exit
--
   In file included from drivers/iio//multiplexer/iio-mux.c:14:0:
>> include/linux/iio/consumer.h:228:20: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
        int val2, enum iio_chan_info_enum attribute);
                       ^~~~~~~~~~~~~~~~~~
   include/linux/iio/consumer.h:242:27: warning: 'enum iio_chan_info_enum' declared inside parameter list will not be visible outside of this definition or declaration
              int *val2, enum iio_chan_info_enum attribute);
                              ^~~~~~~~~~~~~~~~~~
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
   Cyclomatic Complexity 1 include/linux/device.h:devm_kzalloc
   Cyclomatic Complexity 2 include/linux/device.h:dev_name
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_channel_has_info
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_channel_has_available
   Cyclomatic Complexity 1 include/linux/iio/iio.h:iio_priv
   Cyclomatic Complexity 1 include/linux/platform_device.h:platform_set_drvdata
   Cyclomatic Complexity 1 drivers/iio//multiplexer/iio-mux.c:mux_driver_init
   Cyclomatic Complexity 7 drivers/iio//multiplexer/iio-mux.c:iio_mux_select
   Cyclomatic Complexity 1 drivers/iio//multiplexer/iio-mux.c:iio_mux_deselect
   Cyclomatic Complexity 5 drivers/iio//multiplexer/iio-mux.c:mux_write_ext_info
   Cyclomatic Complexity 2 drivers/iio//multiplexer/iio-mux.c:mux_read_ext_info
   Cyclomatic Complexity 3 drivers/iio//multiplexer/iio-mux.c:mux_write_raw
   Cyclomatic Complexity 3 drivers/iio//multiplexer/iio-mux.c:mux_read_avail
   Cyclomatic Complexity 4 drivers/iio//multiplexer/iio-mux.c:mux_read_raw
   Cyclomatic Complexity 16 drivers/iio//multiplexer/iio-mux.c:mux_configure_channel
   Cyclomatic Complexity 20 drivers/iio//multiplexer/iio-mux.c:mux_probe
   Cyclomatic Complexity 1 drivers/iio//multiplexer/iio-mux.c:mux_driver_exit

vim +228 include/linux/iio/consumer.h

   217	
   218	/**
   219	 * iio_write_channel_attribute() - Write values to the device attribute.
   220	 * @chan:	The channel being queried.
   221	 * @val:	Value being written.
   222	 * @val2:	Value being written.val2 use depends on attribute type.
   223	 * @attribute:	info attribute to be read.
   224	 *
   225	 * Returns an error code or 0.
   226	 */
   227	int iio_write_channel_attribute(struct iio_channel *chan, int val,
 > 228					int val2, enum iio_chan_info_enum attribute);
   229	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

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..2017f35 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -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.
+ * @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.