Re: [PATCHv3 9/9] iio: inkern: add iio_read_channel_average_raw

2014-03-15 Thread Jonathan Cameron

On 10/03/14 17:25, Sebastian Reichel wrote:

Add iio_read_channel_average_raw to support reading
averaged raw values in consumer drivers.

Signed-off-by: Sebastian Reichel 

As this one also stands fine on it's own and isn't actually used
by the rest of the patch set - applied to the togreg branch of iio.git
This will get pushed out initially as 'testing' for the autobuilders
to play.

Jonathan

---
  drivers/iio/inkern.c | 18 ++
  include/linux/iio/consumer.h | 13 +
  2 files changed, 31 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0cf5f8e..adeba5a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -443,6 +443,24 @@ err_unlock:
  }
  EXPORT_SYMBOL_GPL(iio_read_channel_raw);

+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+   int ret;
+
+   mutex_lock(>indio_dev->info_exist_lock);
+   if (chan->indio_dev->info == NULL) {
+   ret = -ENODEV;
+   goto err_unlock;
+   }
+
+   ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+   mutex_unlock(>indio_dev->info_exist_lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
  static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int raw, int *processed, unsigned int scale)
  {
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 2752b1f..651f9a0 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -123,6 +123,19 @@ int iio_read_channel_raw(struct iio_channel *chan,
 int *val);

  /**
+ * iio_read_channel_average_raw() - read from a given channel
+ * @chan:  The channel being queried.
+ * @val:   Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * In opposit to the normal iio_read_channel_raw this function
+ * returns the average of multiple reads.
+ */
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
+
+/**
   * iio_read_channel_processed() - read processed value from a given channel
   * @chan: The channel being queried.
   * @val:  Value read back.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 9/9] iio: inkern: add iio_read_channel_average_raw

2014-03-15 Thread Jonathan Cameron

On 10/03/14 17:25, Sebastian Reichel wrote:

Add iio_read_channel_average_raw to support reading
averaged raw values in consumer drivers.

Signed-off-by: Sebastian Reichel s...@debian.org

As this one also stands fine on it's own and isn't actually used
by the rest of the patch set - applied to the togreg branch of iio.git
This will get pushed out initially as 'testing' for the autobuilders
to play.

Jonathan

---
  drivers/iio/inkern.c | 18 ++
  include/linux/iio/consumer.h | 13 +
  2 files changed, 31 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0cf5f8e..adeba5a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -443,6 +443,24 @@ err_unlock:
  }
  EXPORT_SYMBOL_GPL(iio_read_channel_raw);

+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+   int ret;
+
+   mutex_lock(chan-indio_dev-info_exist_lock);
+   if (chan-indio_dev-info == NULL) {
+   ret = -ENODEV;
+   goto err_unlock;
+   }
+
+   ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+   mutex_unlock(chan-indio_dev-info_exist_lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
  static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int raw, int *processed, unsigned int scale)
  {
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 2752b1f..651f9a0 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -123,6 +123,19 @@ int iio_read_channel_raw(struct iio_channel *chan,
 int *val);

  /**
+ * iio_read_channel_average_raw() - read from a given channel
+ * @chan:  The channel being queried.
+ * @val:   Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * In opposit to the normal iio_read_channel_raw this function
+ * returns the average of multiple reads.
+ */
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
+
+/**
   * iio_read_channel_processed() - read processed value from a given channel
   * @chan: The channel being queried.
   * @val:  Value read back.



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 9/9] iio: inkern: add iio_read_channel_average_raw

2014-03-10 Thread Sebastian Reichel
Add iio_read_channel_average_raw to support reading
averaged raw values in consumer drivers.

Signed-off-by: Sebastian Reichel 
---
 drivers/iio/inkern.c | 18 ++
 include/linux/iio/consumer.h | 13 +
 2 files changed, 31 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0cf5f8e..adeba5a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -443,6 +443,24 @@ err_unlock:
 }
 EXPORT_SYMBOL_GPL(iio_read_channel_raw);
 
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+   int ret;
+
+   mutex_lock(>indio_dev->info_exist_lock);
+   if (chan->indio_dev->info == NULL) {
+   ret = -ENODEV;
+   goto err_unlock;
+   }
+
+   ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+   mutex_unlock(>indio_dev->info_exist_lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int raw, int *processed, unsigned int scale)
 {
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 2752b1f..651f9a0 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -123,6 +123,19 @@ int iio_read_channel_raw(struct iio_channel *chan,
 int *val);
 
 /**
+ * iio_read_channel_average_raw() - read from a given channel
+ * @chan:  The channel being queried.
+ * @val:   Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * In opposit to the normal iio_read_channel_raw this function
+ * returns the average of multiple reads.
+ */
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
+
+/**
  * iio_read_channel_processed() - read processed value from a given channel
  * @chan:  The channel being queried.
  * @val:   Value read back.
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 9/9] iio: inkern: add iio_read_channel_average_raw

2014-03-10 Thread Sebastian Reichel
Add iio_read_channel_average_raw to support reading
averaged raw values in consumer drivers.

Signed-off-by: Sebastian Reichel s...@debian.org
---
 drivers/iio/inkern.c | 18 ++
 include/linux/iio/consumer.h | 13 +
 2 files changed, 31 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0cf5f8e..adeba5a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -443,6 +443,24 @@ err_unlock:
 }
 EXPORT_SYMBOL_GPL(iio_read_channel_raw);
 
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+   int ret;
+
+   mutex_lock(chan-indio_dev-info_exist_lock);
+   if (chan-indio_dev-info == NULL) {
+   ret = -ENODEV;
+   goto err_unlock;
+   }
+
+   ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+   mutex_unlock(chan-indio_dev-info_exist_lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int raw, int *processed, unsigned int scale)
 {
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 2752b1f..651f9a0 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -123,6 +123,19 @@ int iio_read_channel_raw(struct iio_channel *chan,
 int *val);
 
 /**
+ * iio_read_channel_average_raw() - read from a given channel
+ * @chan:  The channel being queried.
+ * @val:   Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units required.
+ *
+ * In opposit to the normal iio_read_channel_raw this function
+ * returns the average of multiple reads.
+ */
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
+
+/**
  * iio_read_channel_processed() - read processed value from a given channel
  * @chan:  The channel being queried.
  * @val:   Value read back.
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/