linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper
@ 2013-09-19 12:59 Lars-Peter Clausen
  2013-09-19 12:59 ` [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
                   ` (23 more replies)
  0 siblings, 24 replies; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Oleksandr Kravchenko, Josh Wu,
	Denis Ciocca, Manuel Stahl, Ge Gao, Peter Meerwald,
	Jacek Anaszewski, Fabio Estevam, Marek Vasut

Drivers using software buffers often store the timestamp in their data buffer
before calling iio_push_to_buffers() with that data buffer. Storing the
timestamp in the buffer usually involves some ugly pointer arithmetic. This
patch adds a new helper function called iio_push_buffers_with_timestamp() which
is similar to iio_push_to_buffers but takes an additional timestamp parameter.
The function will help to hide to uglyness in one central place instead of
exposing it in every driver. If timestamps are enabled for the IIO device
iio_push_buffers_with_timestamp() will store the timestamp as the last element
in buffer, before passing the buffer on to iio_push_buffers(). The buffer needs
large enough to hold the timestamp in this case. If timestamps are disabled
iio_push_buffers_with_timestamp() will behave just like iio_push_buffers().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Cc: Josh Wu <josh.wu@atmel.com>
Cc: Denis Ciocca <denis.ciocca@gmail.com>
Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Cc: Ge Gao <ggao@invensense.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Marek Vasut <marex@denx.de>
---
 include/linux/iio/buffer.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index e5507e9..a1124bd 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -122,6 +122,31 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
  */
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
 
+/*
+ * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
+ * @indio_dev:		iio_dev structure for device.
+ * @data:		sample data
+ * @timestamp:		timestamp for the sample data
+ *
+ * Pushes data to the IIO device's buffers. If timestamps are enabled for the
+ * device the function will store the supplied timestamp as the last element in
+ * the sample data buffer before pushing it to the device buffers. The sample
+ * data buffer needs to be large enough to hold the additional timestamp
+ * (usually the buffer should be indio->scan_bytes bytes large).
+ *
+ * Returns 0 on success, a negative error code otherwise.
+ */
+static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
+	void *data, int64_t timestamp)
+{
+	if (indio_dev->scan_timestamp) {
+		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
+		((int64_t *)data)[ts_offset] = timestamp;
+	}
+
+	return iio_push_to_buffers(indio_dev, data);
+}
+
 int iio_update_demux(struct iio_dev *indio_dev);
 
 /**
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:08   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
                   ` (22 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Oleksandr Kravchenko

Makes the code shorter and a bit less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
---
 drivers/iio/accel/bma180.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 3eff246..bda7a83 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -471,13 +471,10 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct bma180_data *data = iio_priv(indio_dev);
+	int64_t time_ns = iio_get_time_ns();
 	int bit, ret, i = 0;
 
 	mutex_lock(&data->mutex);
-	if (indio_dev->scan_timestamp) {
-		ret = indio_dev->scan_bytes / sizeof(s64) - 1;
-		((s64 *)data->buff)[ret] = iio_get_time_ns();
-	}
 
 	for_each_set_bit(bit, indio_dev->buffer->scan_mask,
 			 indio_dev->masklength) {
@@ -490,7 +487,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
 	}
 	mutex_unlock(&data->mutex);
 
-	iio_push_to_buffers(indio_dev, data->buff);
+	iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
 err:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
  2013-09-19 12:59 ` [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:10   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 04/24] iio:ad7298: " Lars-Peter Clausen
                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7266.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index c304966..656aa3e 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -96,9 +96,8 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
 
 	ret = spi_read(st->spi, st->data, 4);
 	if (ret == 0) {
-		if (indio_dev->scan_timestamp)
-			((s64 *)st->data)[1] = pf->timestamp;
-		iio_push_to_buffers(indio_dev, st->data);
+		iio_push_to_buffers_with_timestamp(indio_dev, st->data,
+			    pf->timestamp);
 	}
 
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 04/24] iio:ad7298: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
  2013-09-19 12:59 ` [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
  2013-09-19 12:59 ` [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:11   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 05/24] iio:ad7476: " Lars-Peter Clausen
                   ` (20 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7298.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 0812556..2a3b65c 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -159,20 +159,14 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad7298_state *st = iio_priv(indio_dev);
-	s64 time_ns = 0;
 	int b_sent;
 
 	b_sent = spi_sync(st->spi, &st->ring_msg);
 	if (b_sent)
 		goto done;
 
-	if (indio_dev->scan_timestamp) {
-		time_ns = iio_get_time_ns();
-		memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
-			&time_ns, sizeof(time_ns));
-	}
-
-	iio_push_to_buffers(indio_dev, st->rx_buf);
+	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
+		iio_get_time_ns());
 
 done:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 05/24] iio:ad7476: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (2 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 04/24] iio:ad7298: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:11   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 06/24] iio:ad7887: " Lars-Peter Clausen
                   ` (19 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7476.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 6d2b1d8..8d808b9 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -64,19 +64,14 @@ static irqreturn_t ad7476_trigger_handler(int irq, void  *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad7476_state *st = iio_priv(indio_dev);
-	s64 time_ns;
 	int b_sent;
 
 	b_sent = spi_sync(st->spi, &st->msg);
 	if (b_sent < 0)
 		goto done;
 
-	time_ns = iio_get_time_ns();
-
-	if (indio_dev->scan_timestamp)
-		((s64 *)st->data)[1] = time_ns;
-
-	iio_push_to_buffers(indio_dev, st->data);
+	iio_push_to_buffers_with_timestamp(indio_dev, st->data,
+		iio_get_time_ns());
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 06/24] iio:ad7887: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (3 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 05/24] iio:ad7476: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:11   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 07/24] iio:ad7923: " Lars-Peter Clausen
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7887.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 9dd077b..faedd0e 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -121,20 +121,14 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad7887_state *st = iio_priv(indio_dev);
-	s64 time_ns;
 	int b_sent;
 
 	b_sent = spi_sync(st->spi, st->ring_msg);
 	if (b_sent)
 		goto done;
 
-	time_ns = iio_get_time_ns();
-
-	if (indio_dev->scan_timestamp)
-		memcpy(st->data + indio_dev->scan_bytes - sizeof(s64),
-		       &time_ns, sizeof(time_ns));
-
-	iio_push_to_buffers(indio_dev, st->data);
+	iio_push_to_buffers_with_timestamp(indio_dev, st->data,
+		iio_get_time_ns());
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 07/24] iio:ad7923: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (4 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 06/24] iio:ad7887: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:12   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 08/24] iio:ad_sigma_delta: " Lars-Peter Clausen
                   ` (17 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7923.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 7eb4cb5..28732c2 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -174,20 +174,14 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad7923_state *st = iio_priv(indio_dev);
-	s64 time_ns = 0;
 	int b_sent;
 
 	b_sent = spi_sync(st->spi, &st->ring_msg);
 	if (b_sent)
 		goto done;
 
-	if (indio_dev->scan_timestamp) {
-		time_ns = iio_get_time_ns();
-		memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
-			&time_ns, sizeof(time_ns));
-	}
-
-	iio_push_to_buffers(indio_dev, st->rx_buf);
+	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
+		iio_get_time_ns());
 
 done:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 08/24] iio:ad_sigma_delta: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (5 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 07/24] iio:ad7923: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:12   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 09/24] iio:at91_adc: " Lars-Peter Clausen
                   ` (16 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad_sigma_delta.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 78d276f..2b59112 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -368,10 +368,6 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
 
 	memset(data, 0x00, 16);
 
-	/* Guaranteed to be aligned with 8 byte boundary */
-	if (indio_dev->scan_timestamp)
-		((s64 *)data)[1] = pf->timestamp;
-
 	reg_size = indio_dev->channels[0].scan_type.realbits +
 			indio_dev->channels[0].scan_type.shift;
 	reg_size = DIV_ROUND_UP(reg_size, 8);
@@ -391,7 +387,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
 		break;
 	}
 
-	iio_push_to_buffers(indio_dev, data);
+	iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp);
 
 	iio_trigger_notify_done(indio_dev->trig);
 	sigma_delta->irq_dis = false;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 09/24] iio:at91_adc: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (6 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 08/24] iio:ad_sigma_delta: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:12   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 10/24] iio:max1363: " Lars-Peter Clausen
                   ` (15 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Josh Wu

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Josh Wu <josh.wu@atmel.com>
---
 drivers/iio/adc/at91_adc.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 6da5ebb..ee5f51ca 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -83,13 +83,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
 		j++;
 	}
 
-	if (idev->scan_timestamp) {
-		s64 *timestamp = (s64 *)((u8 *)st->buffer +
-					ALIGN(j, sizeof(s64)));
-		*timestamp = pf->timestamp;
-	}
-
-	iio_push_to_buffers(idev, st->buffer);
+	iio_push_to_buffers_with_timestamp(idev, st->buffer, pf->timestamp);
 
 	iio_trigger_notify_done(idev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 10/24] iio:max1363: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (7 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 09/24] iio:at91_adc: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:13   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 11/24] iio:st_sensors: " Lars-Peter Clausen
                   ` (14 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/max1363.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index 1e7160d..b4bc166 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -1436,7 +1436,6 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct max1363_state *st = iio_priv(indio_dev);
-	s64 time_ns;
 	__u8 *rxbuf;
 	int b_sent;
 	size_t d_size;
@@ -1470,11 +1469,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
 	if (b_sent < 0)
 		goto done_free;
 
-	time_ns = iio_get_time_ns();
-
-	if (indio_dev->scan_timestamp)
-		memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
-	iio_push_to_buffers(indio_dev, rxbuf);
+	iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, iio_get_time_ns());
 
 done_free:
 	kfree(rxbuf);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 11/24] iio:st_sensors: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (8 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 10/24] iio:max1363: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:13   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 12/24] iio:itg3200: " Lars-Peter Clausen
                   ` (13 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Denis Ciocca

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Denis Ciocca <denis.ciocca@gmail.com>
---
 drivers/iio/common/st_sensors/st_sensors_buffer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index 71a2c5f..1665c8e 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -113,11 +113,8 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
 	if (len < 0)
 		goto st_sensors_get_buffer_element_error;
 
-	if (indio_dev->scan_timestamp)
-		*(s64 *)((u8 *)sdata->buffer_data +
-				ALIGN(len, sizeof(s64))) = pf->timestamp;
-
-	iio_push_to_buffers(indio_dev, sdata->buffer_data);
+	iio_push_to_buffers_with_timestamp(indio_dev, sdata->buffer_data,
+		pf->timestamp);
 
 st_sensors_get_buffer_element_error:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 12/24] iio:itg3200: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (9 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 11/24] iio:st_sensors: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:14   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 13/24] iio:adis16400: " Lars-Peter Clausen
                   ` (12 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Manuel Stahl

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
---
 drivers/iio/gyro/itg3200_buffer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
index 6b3c301..e3b3c50 100644
--- a/drivers/iio/gyro/itg3200_buffer.c
+++ b/drivers/iio/gyro/itg3200_buffer.c
@@ -55,11 +55,8 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
 	if (ret < 0)
 		goto error_ret;
 
-	if (indio_dev->scan_timestamp)
-		memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
-				&pf->timestamp, sizeof(pf->timestamp));
+	iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp);
 
-	iio_push_to_buffers(indio_dev, buf);
 	iio_trigger_notify_done(indio_dev->trig);
 
 error_ret:
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 13/24] iio:adis16400: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (10 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 12/24] iio:itg3200: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:15   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 14/24] iio:adis_lib: " Lars-Peter Clausen
                   ` (11 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/imu/adis16400_buffer.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
index 054c01d..f2cf829 100644
--- a/drivers/iio/imu/adis16400_buffer.c
+++ b/drivers/iio/imu/adis16400_buffer.c
@@ -82,13 +82,8 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
 		spi_setup(st->adis.spi);
 	}
 
-	/* Guaranteed to be aligned with 8 byte boundary */
-	if (indio_dev->scan_timestamp) {
-		void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64);
-		*(s64 *)b = pf->timestamp;
-	}
-
-	iio_push_to_buffers(indio_dev, adis->buffer);
+	iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
+		pf->timestamp);
 
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 14/24] iio:adis_lib: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (11 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 13/24] iio:adis16400: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:15   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 15/24] iio:mpu6050: " Lars-Peter Clausen
                   ` (10 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/imu/adis_buffer.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index 99d8e0b..cb32b59 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -102,13 +102,8 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
 		mutex_unlock(&adis->txrx_lock);
 	}
 
-	/* Guaranteed to be aligned with 8 byte boundary */
-	if (indio_dev->scan_timestamp) {
-		void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64);
-		*(s64 *)b = pf->timestamp;
-	}
-
-	iio_push_to_buffers(indio_dev, adis->buffer);
+	iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
+		pf->timestamp);
 
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 15/24] iio:mpu6050: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (12 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 14/24] iio:adis_lib: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:16   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 16/24] iio:adjd_s311: " Lars-Peter Clausen
                   ` (9 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Ge Gao

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Ge Gao <ggao@invensense.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
index 7da0832..4295171 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
@@ -124,7 +124,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
 	u8 data[INV_MPU6050_OUTPUT_DATA_SIZE];
 	u16 fifo_count;
 	s64 timestamp;
-	u64 *tmp;
 
 	mutex_lock(&indio_dev->mlock);
 	if (!(st->chip_config.accl_fifo_enable |
@@ -170,9 +169,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
 		if (0 == result)
 			timestamp = 0;
 
-		tmp = (u64 *)data;
-		tmp[DIV_ROUND_UP(bytes_per_datum, 8)] = timestamp;
-		result = iio_push_to_buffers(indio_dev, data);
+		result = iio_push_to_buffers_with_timestamp(indio_dev, data,
+			timestamp);
 		if (result)
 			goto flush_fifo;
 		fifo_count -= bytes_per_datum;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 16/24] iio:adjd_s311: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (13 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 15/24] iio:mpu6050: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:16   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 17/24] iio:tcs3472: " Lars-Peter Clausen
                   ` (8 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Peter Meerwald

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/light/adjd_s311.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
index c9c8b00..39f6392 100644
--- a/drivers/iio/light/adjd_s311.c
+++ b/drivers/iio/light/adjd_s311.c
@@ -138,10 +138,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
 		len += 2;
 	}
 
-	if (indio_dev->scan_timestamp)
-		*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
-			= time_ns;
-	iio_push_to_buffers(indio_dev, data->buffer);
+	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, time_ns);
 
 done:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 17/24] iio:tcs3472: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (14 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 16/24] iio:adjd_s311: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:17   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 18/24] iio:gp2ap020a00f: " Lars-Peter Clausen
                   ` (7 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Peter Meerwald

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/light/tcs3472.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index 7bf2969..0bc15cf 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -192,10 +192,8 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
 		len += 2;
 	}
 
-	if (indio_dev->scan_timestamp)
-		*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
-			= iio_get_time_ns();
-	iio_push_to_buffers(indio_dev, data->buffer);
+	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+		iio_get_time_ns());
 
 done:
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 18/24] iio:gp2ap020a00f: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (15 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 17/24] iio:tcs3472: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:17   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 19/24] staging:iio:lis3l02dq: " Lars-Peter Clausen
                   ` (6 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Jacek Anaszewski

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
---
 drivers/iio/light/gp2ap020a00f.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
index 62809b5..b1e4615 100644
--- a/drivers/iio/light/gp2ap020a00f.c
+++ b/drivers/iio/light/gp2ap020a00f.c
@@ -988,13 +988,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data)
 		}
 	}
 
-	if (indio_dev->scan_timestamp) {
-		s64 *timestamp = (s64 *)((u8 *)priv->buffer +
-						ALIGN(d_size, sizeof(s64)));
-		*timestamp = pf->timestamp;
-	}
-
-	iio_push_to_buffers(indio_dev, priv->buffer);
+	iio_push_to_buffers_with_timestamp(indio_dev, priv->buffer,
+		pf->timestamp);
 done:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 19/24] staging:iio:lis3l02dq: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (16 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 18/24] iio:gp2ap020a00f: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:18   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 20/24] staging:iio:ad7606: " Lars-Peter Clausen
                   ` (5 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index 36dcc7e..aae86dd 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -146,11 +146,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
 	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
 		len = lis3l02dq_get_buffer_element(indio_dev, data);
 
-	  /* Guaranteed to be aligned with 8 byte boundary */
-	if (indio_dev->scan_timestamp)
-		*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
-			= pf->timestamp;
-	iio_push_to_buffers(indio_dev, data);
+	iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp);
 
 	kfree(data);
 done:
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 20/24] staging:iio:ad7606: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (17 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 19/24] staging:iio:lis3l02dq: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:18   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 21/24] staging:iio:ad799x: " Lars-Peter Clausen
                   ` (4 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad7606_ring.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
index 2b25cb0..3bf174c 100644
--- a/drivers/staging/iio/adc/ad7606_ring.c
+++ b/drivers/staging/iio/adc/ad7606_ring.c
@@ -46,7 +46,6 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 	struct ad7606_state *st = container_of(work_s, struct ad7606_state,
 						poll_work);
 	struct iio_dev *indio_dev = iio_priv_to_dev(st);
-	s64 time_ns;
 	__u8 *buf;
 	int ret;
 
@@ -78,12 +77,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 			goto done;
 	}
 
-	time_ns = iio_get_time_ns();
-
-	if (indio_dev->scan_timestamp)
-		*((s64 *)(buf + indio_dev->scan_bytes - sizeof(s64))) = time_ns;
-
-	iio_push_to_buffers(indio_dev, buf);
+	iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns());
 done:
 	gpio_set_value(st->pdata->gpio_convst, 0);
 	iio_trigger_notify_done(indio_dev->trig);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 21/24] staging:iio:ad799x: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (18 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 20/24] staging:iio:ad7606: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:19   ` Jonathan Cameron
  2013-09-19 12:59 ` [PATCH 22/24] staging:iio:mxs-lradc: " Lars-Peter Clausen
                   ` (3 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/adc/ad799x_ring.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c
index c2ebae1..0ff6c03 100644
--- a/drivers/staging/iio/adc/ad799x_ring.c
+++ b/drivers/staging/iio/adc/ad799x_ring.c
@@ -35,7 +35,6 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ad799x_state *st = iio_priv(indio_dev);
-	s64 time_ns;
 	int b_sent;
 	u8 cmd;
 
@@ -65,13 +64,8 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
 	if (b_sent < 0)
 		goto out;
 
-	time_ns = iio_get_time_ns();
-
-	if (indio_dev->scan_timestamp)
-		memcpy(st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
-			&time_ns, sizeof(time_ns));
-
-	iio_push_to_buffers(indio_dev, st->rx_buf);
+	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
+			iio_get_time_ns());
 out:
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 22/24] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (19 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 21/24] staging:iio:ad799x: " Lars-Peter Clausen
@ 2013-09-19 12:59 ` Lars-Peter Clausen
  2013-09-21 12:19   ` Jonathan Cameron
  2013-09-19 13:00 ` [PATCH 23/24] staging:iio:dummy: " Lars-Peter Clausen
                   ` (2 subsequent siblings)
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 12:59 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Fabio Estevam

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/staging/iio/adc/mxs-lradc.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 7401230..9da64bf 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -625,13 +625,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p)
 		j++;
 	}
 
-	if (iio->scan_timestamp) {
-		s64 *timestamp = (s64 *)((u8 *)lradc->buffer +
-					ALIGN(j, sizeof(s64)));
-		*timestamp = pf->timestamp;
-	}
-
-	iio_push_to_buffers(iio, lradc->buffer);
+	iio_push_to_buffers_with_timestamp(iio, lradc->buffer, pf->timestamp);
 
 	iio_trigger_notify_done(iio->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 23/24] staging:iio:dummy: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (20 preceding siblings ...)
  2013-09-19 12:59 ` [PATCH 22/24] staging:iio:mxs-lradc: " Lars-Peter Clausen
@ 2013-09-19 13:00 ` Lars-Peter Clausen
  2013-09-21 12:19   ` Jonathan Cameron
  2013-09-19 13:00 ` [PATCH 24/24] staging:iio:ade7758: " Lars-Peter Clausen
  2013-09-21 12:08 ` [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Jonathan Cameron
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 13:00 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/iio_simple_dummy_buffer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c
index 3921865..09c93ac 100644
--- a/drivers/staging/iio/iio_simple_dummy_buffer.c
+++ b/drivers/staging/iio/iio_simple_dummy_buffer.c
@@ -82,11 +82,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
 			len += 2;
 		}
 	}
-	/* Store the timestamp at an 8 byte aligned offset */
-	if (indio_dev->scan_timestamp)
-		*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
-			= iio_get_time_ns();
-	iio_push_to_buffers(indio_dev, data);
+
+	iio_push_to_buffers_with_timestamp(indio_dev, data, iio_get_time_ns());
 
 	kfree(data);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 24/24] staging:iio:ade7758: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (21 preceding siblings ...)
  2013-09-19 13:00 ` [PATCH 23/24] staging:iio:dummy: " Lars-Peter Clausen
@ 2013-09-19 13:00 ` Lars-Peter Clausen
  2013-09-21 12:20   ` Jonathan Cameron
  2013-09-21 12:08 ` [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Jonathan Cameron
  23 siblings, 1 reply; 48+ messages in thread
From: Lars-Peter Clausen @ 2013-09-19 13:00 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Makes the code a bit shorter and less ugly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/meter/ade7758_ring.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
index 3d8bc2d..4080995 100644
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ b/drivers/staging/iio/meter/ade7758_ring.c
@@ -69,11 +69,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
 		if (ade7758_spi_read_burst(indio_dev) >= 0)
 			*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
 
-	/* Guaranteed to be aligned with 8 byte boundary */
-	if (indio_dev->scan_timestamp)
-		dat64[1] = pf->timestamp;
-
-	iio_push_to_buffers(indio_dev, dat64);
+	iio_push_to_buffers_with_timestamp(indio_dev, dat64, pf->timestamp);
 
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper
  2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
                   ` (22 preceding siblings ...)
  2013-09-19 13:00 ` [PATCH 24/24] staging:iio:ade7758: " Lars-Peter Clausen
@ 2013-09-21 12:08 ` Jonathan Cameron
  23 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:08 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: linux-iio, Oleksandr Kravchenko, Josh Wu, Denis Ciocca,
	Manuel Stahl, Ge Gao, Peter Meerwald, Jacek Anaszewski,
	Fabio Estevam, Marek Vasut

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Drivers using software buffers often store the timestamp in their data buffer
> before calling iio_push_to_buffers() with that data buffer. Storing the
> timestamp in the buffer usually involves some ugly pointer arithmetic. This
> patch adds a new helper function called iio_push_buffers_with_timestamp() which
> is similar to iio_push_to_buffers but takes an additional timestamp parameter.
> The function will help to hide to uglyness in one central place instead of
> exposing it in every driver. If timestamps are enabled for the IIO device
> iio_push_buffers_with_timestamp() will store the timestamp as the last element
> in buffer, before passing the buffer on to iio_push_buffers(). The buffer needs
> large enough to hold the timestamp in this case. If timestamps are disabled
> iio_push_buffers_with_timestamp() will behave just like iio_push_buffers().
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> Cc: Josh Wu <josh.wu@atmel.com>
> Cc: Denis Ciocca <denis.ciocca@gmail.com>
> Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
> Cc: Ge Gao <ggao@invensense.com>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Marek Vasut <marex@denx.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  include/linux/iio/buffer.h | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
> index e5507e9..a1124bd 100644
> --- a/include/linux/iio/buffer.h
> +++ b/include/linux/iio/buffer.h
> @@ -122,6 +122,31 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
>   */
>  int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
>  
> +/*
> + * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
> + * @indio_dev:		iio_dev structure for device.
> + * @data:		sample data
> + * @timestamp:		timestamp for the sample data
> + *
> + * Pushes data to the IIO device's buffers. If timestamps are enabled for the
> + * device the function will store the supplied timestamp as the last element in
> + * the sample data buffer before pushing it to the device buffers. The sample
> + * data buffer needs to be large enough to hold the additional timestamp
> + * (usually the buffer should be indio->scan_bytes bytes large).
> + *
> + * Returns 0 on success, a negative error code otherwise.
> + */
> +static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
> +	void *data, int64_t timestamp)
> +{
> +	if (indio_dev->scan_timestamp) {
> +		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
> +		((int64_t *)data)[ts_offset] = timestamp;
> +	}
> +
> +	return iio_push_to_buffers(indio_dev, data);
> +}
> +
>  int iio_update_demux(struct iio_dev *indio_dev);
>  
>  /**
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-21 12:08   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:08 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Oleksandr Kravchenko

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code shorter and a bit less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/accel/bma180.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 3eff246..bda7a83 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -471,13 +471,10 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct bma180_data *data = iio_priv(indio_dev);
> +	int64_t time_ns = iio_get_time_ns();
>  	int bit, ret, i = 0;
>  
>  	mutex_lock(&data->mutex);
> -	if (indio_dev->scan_timestamp) {
> -		ret = indio_dev->scan_bytes / sizeof(s64) - 1;
> -		((s64 *)data->buff)[ret] = iio_get_time_ns();
> -	}
>  
>  	for_each_set_bit(bit, indio_dev->buffer->scan_mask,
>  			 indio_dev->masklength) {
> @@ -490,7 +487,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
>  	}
>  	mutex_unlock(&data->mutex);
>  
> -	iio_push_to_buffers(indio_dev, data->buff);
> +	iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
>  err:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-21 12:10   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:10 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad7266.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index c304966..656aa3e 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -96,9 +96,8 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
>  
>  	ret = spi_read(st->spi, st->data, 4);
>  	if (ret == 0) {
> -		if (indio_dev->scan_timestamp)
> -			((s64 *)st->data)[1] = pf->timestamp;
> -		iio_push_to_buffers(indio_dev, st->data);
> +		iio_push_to_buffers_with_timestamp(indio_dev, st->data,
> +			    pf->timestamp);
>  	}
>  
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 04/24] iio:ad7298: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 04/24] iio:ad7298: " Lars-Peter Clausen
@ 2013-09-21 12:11   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:11 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad7298.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
> index 0812556..2a3b65c 100644
> --- a/drivers/iio/adc/ad7298.c
> +++ b/drivers/iio/adc/ad7298.c
> @@ -159,20 +159,14 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad7298_state *st = iio_priv(indio_dev);
> -	s64 time_ns = 0;
>  	int b_sent;
>  
>  	b_sent = spi_sync(st->spi, &st->ring_msg);
>  	if (b_sent)
>  		goto done;
>  
> -	if (indio_dev->scan_timestamp) {
> -		time_ns = iio_get_time_ns();
> -		memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
> -			&time_ns, sizeof(time_ns));
> -	}
> -
> -	iio_push_to_buffers(indio_dev, st->rx_buf);
> +	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
> +		iio_get_time_ns());
>  
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 05/24] iio:ad7476: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 05/24] iio:ad7476: " Lars-Peter Clausen
@ 2013-09-21 12:11   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:11 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad7476.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index 6d2b1d8..8d808b9 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -64,19 +64,14 @@ static irqreturn_t ad7476_trigger_handler(int irq, void  *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad7476_state *st = iio_priv(indio_dev);
> -	s64 time_ns;
>  	int b_sent;
>  
>  	b_sent = spi_sync(st->spi, &st->msg);
>  	if (b_sent < 0)
>  		goto done;
>  
> -	time_ns = iio_get_time_ns();
> -
> -	if (indio_dev->scan_timestamp)
> -		((s64 *)st->data)[1] = time_ns;
> -
> -	iio_push_to_buffers(indio_dev, st->data);
> +	iio_push_to_buffers_with_timestamp(indio_dev, st->data,
> +		iio_get_time_ns());
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 06/24] iio:ad7887: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 06/24] iio:ad7887: " Lars-Peter Clausen
@ 2013-09-21 12:11   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:11 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad7887.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
> index 9dd077b..faedd0e 100644
> --- a/drivers/iio/adc/ad7887.c
> +++ b/drivers/iio/adc/ad7887.c
> @@ -121,20 +121,14 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad7887_state *st = iio_priv(indio_dev);
> -	s64 time_ns;
>  	int b_sent;
>  
>  	b_sent = spi_sync(st->spi, st->ring_msg);
>  	if (b_sent)
>  		goto done;
>  
> -	time_ns = iio_get_time_ns();
> -
> -	if (indio_dev->scan_timestamp)
> -		memcpy(st->data + indio_dev->scan_bytes - sizeof(s64),
> -		       &time_ns, sizeof(time_ns));
> -
> -	iio_push_to_buffers(indio_dev, st->data);
> +	iio_push_to_buffers_with_timestamp(indio_dev, st->data,
> +		iio_get_time_ns());
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 07/24] iio:ad7923: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 07/24] iio:ad7923: " Lars-Peter Clausen
@ 2013-09-21 12:12   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:12 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad7923.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index 7eb4cb5..28732c2 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -174,20 +174,14 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad7923_state *st = iio_priv(indio_dev);
> -	s64 time_ns = 0;
>  	int b_sent;
>  
>  	b_sent = spi_sync(st->spi, &st->ring_msg);
>  	if (b_sent)
>  		goto done;
>  
> -	if (indio_dev->scan_timestamp) {
> -		time_ns = iio_get_time_ns();
> -		memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
> -			&time_ns, sizeof(time_ns));
> -	}
> -
> -	iio_push_to_buffers(indio_dev, st->rx_buf);
> +	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
> +		iio_get_time_ns());
>  
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 08/24] iio:ad_sigma_delta: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 08/24] iio:ad_sigma_delta: " Lars-Peter Clausen
@ 2013-09-21 12:12   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:12 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/ad_sigma_delta.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
> index 78d276f..2b59112 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -368,10 +368,6 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
>  
>  	memset(data, 0x00, 16);
>  
> -	/* Guaranteed to be aligned with 8 byte boundary */
> -	if (indio_dev->scan_timestamp)
> -		((s64 *)data)[1] = pf->timestamp;
> -
>  	reg_size = indio_dev->channels[0].scan_type.realbits +
>  			indio_dev->channels[0].scan_type.shift;
>  	reg_size = DIV_ROUND_UP(reg_size, 8);
> @@ -391,7 +387,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
>  		break;
>  	}
>  
> -	iio_push_to_buffers(indio_dev, data);
> +	iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp);
>  
>  	iio_trigger_notify_done(indio_dev->trig);
>  	sigma_delta->irq_dis = false;
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 09/24] iio:at91_adc: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 09/24] iio:at91_adc: " Lars-Peter Clausen
@ 2013-09-21 12:12   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:12 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Josh Wu

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Josh Wu <josh.wu@atmel.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/at91_adc.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 6da5ebb..ee5f51ca 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -83,13 +83,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
>  		j++;
>  	}
>  
> -	if (idev->scan_timestamp) {
> -		s64 *timestamp = (s64 *)((u8 *)st->buffer +
> -					ALIGN(j, sizeof(s64)));
> -		*timestamp = pf->timestamp;
> -	}
> -
> -	iio_push_to_buffers(idev, st->buffer);
> +	iio_push_to_buffers_with_timestamp(idev, st->buffer, pf->timestamp);
>  
>  	iio_trigger_notify_done(idev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 10/24] iio:max1363: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 10/24] iio:max1363: " Lars-Peter Clausen
@ 2013-09-21 12:13   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:13 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/adc/max1363.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index 1e7160d..b4bc166 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -1436,7 +1436,6 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct max1363_state *st = iio_priv(indio_dev);
> -	s64 time_ns;
>  	__u8 *rxbuf;
>  	int b_sent;
>  	size_t d_size;
> @@ -1470,11 +1469,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
>  	if (b_sent < 0)
>  		goto done_free;
>  
> -	time_ns = iio_get_time_ns();
> -
> -	if (indio_dev->scan_timestamp)
> -		memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
> -	iio_push_to_buffers(indio_dev, rxbuf);
> +	iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, iio_get_time_ns());
>  
>  done_free:
>  	kfree(rxbuf);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 11/24] iio:st_sensors: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 11/24] iio:st_sensors: " Lars-Peter Clausen
@ 2013-09-21 12:13   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:13 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Denis Ciocca

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Denis Ciocca <denis.ciocca@gmail.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/common/st_sensors/st_sensors_buffer.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> index 71a2c5f..1665c8e 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> @@ -113,11 +113,8 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
>  	if (len < 0)
>  		goto st_sensors_get_buffer_element_error;
>  
> -	if (indio_dev->scan_timestamp)
> -		*(s64 *)((u8 *)sdata->buffer_data +
> -				ALIGN(len, sizeof(s64))) = pf->timestamp;
> -
> -	iio_push_to_buffers(indio_dev, sdata->buffer_data);
> +	iio_push_to_buffers_with_timestamp(indio_dev, sdata->buffer_data,
> +		pf->timestamp);
>  
>  st_sensors_get_buffer_element_error:
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 12/24] iio:itg3200: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 12/24] iio:itg3200: " Lars-Peter Clausen
@ 2013-09-21 12:14   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:14 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Manuel Stahl

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/gyro/itg3200_buffer.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
> index 6b3c301..e3b3c50 100644
> --- a/drivers/iio/gyro/itg3200_buffer.c
> +++ b/drivers/iio/gyro/itg3200_buffer.c
> @@ -55,11 +55,8 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
>  	if (ret < 0)
>  		goto error_ret;
>  
> -	if (indio_dev->scan_timestamp)
> -		memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
> -				&pf->timestamp, sizeof(pf->timestamp));
> +	iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp);
>  
> -	iio_push_to_buffers(indio_dev, buf);
>  	iio_trigger_notify_done(indio_dev->trig);
>  
>  error_ret:
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 13/24] iio:adis16400: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 13/24] iio:adis16400: " Lars-Peter Clausen
@ 2013-09-21 12:15   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:15 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/imu/adis16400_buffer.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
> index 054c01d..f2cf829 100644
> --- a/drivers/iio/imu/adis16400_buffer.c
> +++ b/drivers/iio/imu/adis16400_buffer.c
> @@ -82,13 +82,8 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
>  		spi_setup(st->adis.spi);
>  	}
>  
> -	/* Guaranteed to be aligned with 8 byte boundary */
> -	if (indio_dev->scan_timestamp) {
> -		void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64);
> -		*(s64 *)b = pf->timestamp;
> -	}
> -
> -	iio_push_to_buffers(indio_dev, adis->buffer);
> +	iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
> +		pf->timestamp);
>  
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 14/24] iio:adis_lib: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 14/24] iio:adis_lib: " Lars-Peter Clausen
@ 2013-09-21 12:15   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:15 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/imu/adis_buffer.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
> index 99d8e0b..cb32b59 100644
> --- a/drivers/iio/imu/adis_buffer.c
> +++ b/drivers/iio/imu/adis_buffer.c
> @@ -102,13 +102,8 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
>  		mutex_unlock(&adis->txrx_lock);
>  	}
>  
> -	/* Guaranteed to be aligned with 8 byte boundary */
> -	if (indio_dev->scan_timestamp) {
> -		void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64);
> -		*(s64 *)b = pf->timestamp;
> -	}
> -
> -	iio_push_to_buffers(indio_dev, adis->buffer);
> +	iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
> +		pf->timestamp);
>  
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 15/24] iio:mpu6050: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 15/24] iio:mpu6050: " Lars-Peter Clausen
@ 2013-09-21 12:16   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:16 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Ge Gao

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Ge Gao <ggao@invensense.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> index 7da0832..4295171 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> @@ -124,7 +124,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
>  	u8 data[INV_MPU6050_OUTPUT_DATA_SIZE];
>  	u16 fifo_count;
>  	s64 timestamp;
> -	u64 *tmp;
>  
>  	mutex_lock(&indio_dev->mlock);
>  	if (!(st->chip_config.accl_fifo_enable |
> @@ -170,9 +169,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
>  		if (0 == result)
>  			timestamp = 0;
>  
> -		tmp = (u64 *)data;
> -		tmp[DIV_ROUND_UP(bytes_per_datum, 8)] = timestamp;
> -		result = iio_push_to_buffers(indio_dev, data);
> +		result = iio_push_to_buffers_with_timestamp(indio_dev, data,
> +			timestamp);
>  		if (result)
>  			goto flush_fifo;
>  		fifo_count -= bytes_per_datum;
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 16/24] iio:adjd_s311: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 16/24] iio:adjd_s311: " Lars-Peter Clausen
@ 2013-09-21 12:16   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:16 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Peter Meerwald

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/light/adjd_s311.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
> index c9c8b00..39f6392 100644
> --- a/drivers/iio/light/adjd_s311.c
> +++ b/drivers/iio/light/adjd_s311.c
> @@ -138,10 +138,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
>  		len += 2;
>  	}
>  
> -	if (indio_dev->scan_timestamp)
> -		*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
> -			= time_ns;
> -	iio_push_to_buffers(indio_dev, data->buffer);
> +	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, time_ns);
>  
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 17/24] iio:tcs3472: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 17/24] iio:tcs3472: " Lars-Peter Clausen
@ 2013-09-21 12:17   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:17 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Peter Meerwald

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/light/tcs3472.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
> index 7bf2969..0bc15cf 100644
> --- a/drivers/iio/light/tcs3472.c
> +++ b/drivers/iio/light/tcs3472.c
> @@ -192,10 +192,8 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
>  		len += 2;
>  	}
>  
> -	if (indio_dev->scan_timestamp)
> -		*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
> -			= iio_get_time_ns();
> -	iio_push_to_buffers(indio_dev, data->buffer);
> +	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +		iio_get_time_ns());
>  
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 18/24] iio:gp2ap020a00f: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 18/24] iio:gp2ap020a00f: " Lars-Peter Clausen
@ 2013-09-21 12:17   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:17 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Jacek Anaszewski

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/iio/light/gp2ap020a00f.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
> index 62809b5..b1e4615 100644
> --- a/drivers/iio/light/gp2ap020a00f.c
> +++ b/drivers/iio/light/gp2ap020a00f.c
> @@ -988,13 +988,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data)
>  		}
>  	}
>  
> -	if (indio_dev->scan_timestamp) {
> -		s64 *timestamp = (s64 *)((u8 *)priv->buffer +
> -						ALIGN(d_size, sizeof(s64)));
> -		*timestamp = pf->timestamp;
> -	}
> -
> -	iio_push_to_buffers(indio_dev, priv->buffer);
> +	iio_push_to_buffers_with_timestamp(indio_dev, priv->buffer,
> +		pf->timestamp);
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 19/24] staging:iio:lis3l02dq: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 19/24] staging:iio:lis3l02dq: " Lars-Peter Clausen
@ 2013-09-21 12:18   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:18 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied ot the togreg branch of iio.git

> ---
>  drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
> index 36dcc7e..aae86dd 100644
> --- a/drivers/staging/iio/accel/lis3l02dq_ring.c
> +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
> @@ -146,11 +146,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
>  	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
>  		len = lis3l02dq_get_buffer_element(indio_dev, data);
>  
> -	  /* Guaranteed to be aligned with 8 byte boundary */
> -	if (indio_dev->scan_timestamp)
> -		*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
> -			= pf->timestamp;
> -	iio_push_to_buffers(indio_dev, data);
> +	iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp);
>  
>  	kfree(data);
>  done:
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 20/24] staging:iio:ad7606: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 20/24] staging:iio:ad7606: " Lars-Peter Clausen
@ 2013-09-21 12:18   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:18 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

> ---
>  drivers/staging/iio/adc/ad7606_ring.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
> index 2b25cb0..3bf174c 100644
> --- a/drivers/staging/iio/adc/ad7606_ring.c
> +++ b/drivers/staging/iio/adc/ad7606_ring.c
> @@ -46,7 +46,6 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
>  	struct ad7606_state *st = container_of(work_s, struct ad7606_state,
>  						poll_work);
>  	struct iio_dev *indio_dev = iio_priv_to_dev(st);
> -	s64 time_ns;
>  	__u8 *buf;
>  	int ret;
>  
> @@ -78,12 +77,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
>  			goto done;
>  	}
>  
> -	time_ns = iio_get_time_ns();
> -
> -	if (indio_dev->scan_timestamp)
> -		*((s64 *)(buf + indio_dev->scan_bytes - sizeof(s64))) = time_ns;
> -
> -	iio_push_to_buffers(indio_dev, buf);
> +	iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns());
>  done:
>  	gpio_set_value(st->pdata->gpio_convst, 0);
>  	iio_trigger_notify_done(indio_dev->trig);
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 21/24] staging:iio:ad799x: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 21/24] staging:iio:ad799x: " Lars-Peter Clausen
@ 2013-09-21 12:19   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:19 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/staging/iio/adc/ad799x_ring.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c
> index c2ebae1..0ff6c03 100644
> --- a/drivers/staging/iio/adc/ad799x_ring.c
> +++ b/drivers/staging/iio/adc/ad799x_ring.c
> @@ -35,7 +35,6 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad799x_state *st = iio_priv(indio_dev);
> -	s64 time_ns;
>  	int b_sent;
>  	u8 cmd;
>  
> @@ -65,13 +64,8 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
>  	if (b_sent < 0)
>  		goto out;
>  
> -	time_ns = iio_get_time_ns();
> -
> -	if (indio_dev->scan_timestamp)
> -		memcpy(st->rx_buf + indio_dev->scan_bytes - sizeof(s64),
> -			&time_ns, sizeof(time_ns));
> -
> -	iio_push_to_buffers(indio_dev, st->rx_buf);
> +	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
> +			iio_get_time_ns());
>  out:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 22/24] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 12:59 ` [PATCH 22/24] staging:iio:mxs-lradc: " Lars-Peter Clausen
@ 2013-09-21 12:19   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:19 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Fabio Estevam

On 09/19/13 13:59, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
Applied to the togreg branch of iio.git

> ---
>  drivers/staging/iio/adc/mxs-lradc.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index 7401230..9da64bf 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -625,13 +625,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p)
>  		j++;
>  	}
>  
> -	if (iio->scan_timestamp) {
> -		s64 *timestamp = (s64 *)((u8 *)lradc->buffer +
> -					ALIGN(j, sizeof(s64)));
> -		*timestamp = pf->timestamp;
> -	}
> -
> -	iio_push_to_buffers(iio, lradc->buffer);
> +	iio_push_to_buffers_with_timestamp(iio, lradc->buffer, pf->timestamp);
>  
>  	iio_trigger_notify_done(iio->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 23/24] staging:iio:dummy: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 13:00 ` [PATCH 23/24] staging:iio:dummy: " Lars-Peter Clausen
@ 2013-09-21 12:19   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:19 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 14:00, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/staging/iio/iio_simple_dummy_buffer.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c
> index 3921865..09c93ac 100644
> --- a/drivers/staging/iio/iio_simple_dummy_buffer.c
> +++ b/drivers/staging/iio/iio_simple_dummy_buffer.c
> @@ -82,11 +82,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
>  			len += 2;
>  		}
>  	}
> -	/* Store the timestamp at an 8 byte aligned offset */
> -	if (indio_dev->scan_timestamp)
> -		*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
> -			= iio_get_time_ns();
> -	iio_push_to_buffers(indio_dev, data);
> +
> +	iio_push_to_buffers_with_timestamp(indio_dev, data, iio_get_time_ns());
>  
>  	kfree(data);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 24/24] staging:iio:ade7758: Use iio_push_to_buffers_with_timestamp()
  2013-09-19 13:00 ` [PATCH 24/24] staging:iio:ade7758: " Lars-Peter Clausen
@ 2013-09-21 12:20   ` Jonathan Cameron
  0 siblings, 0 replies; 48+ messages in thread
From: Jonathan Cameron @ 2013-09-21 12:20 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 09/19/13 14:00, Lars-Peter Clausen wrote:
> Makes the code a bit shorter and less ugly.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/staging/iio/meter/ade7758_ring.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
> index 3d8bc2d..4080995 100644
> --- a/drivers/staging/iio/meter/ade7758_ring.c
> +++ b/drivers/staging/iio/meter/ade7758_ring.c
> @@ -69,11 +69,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
>  		if (ade7758_spi_read_burst(indio_dev) >= 0)
>  			*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
>  
> -	/* Guaranteed to be aligned with 8 byte boundary */
> -	if (indio_dev->scan_timestamp)
> -		dat64[1] = pf->timestamp;
> -
> -	iio_push_to_buffers(indio_dev, dat64);
> +	iio_push_to_buffers_with_timestamp(indio_dev, dat64, pf->timestamp);
>  
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2013-09-21 11:20 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19 12:59 [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
2013-09-19 12:59 ` [PATCH 02/24] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
2013-09-21 12:08   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 03/24] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
2013-09-21 12:10   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 04/24] iio:ad7298: " Lars-Peter Clausen
2013-09-21 12:11   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 05/24] iio:ad7476: " Lars-Peter Clausen
2013-09-21 12:11   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 06/24] iio:ad7887: " Lars-Peter Clausen
2013-09-21 12:11   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 07/24] iio:ad7923: " Lars-Peter Clausen
2013-09-21 12:12   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 08/24] iio:ad_sigma_delta: " Lars-Peter Clausen
2013-09-21 12:12   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 09/24] iio:at91_adc: " Lars-Peter Clausen
2013-09-21 12:12   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 10/24] iio:max1363: " Lars-Peter Clausen
2013-09-21 12:13   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 11/24] iio:st_sensors: " Lars-Peter Clausen
2013-09-21 12:13   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 12/24] iio:itg3200: " Lars-Peter Clausen
2013-09-21 12:14   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 13/24] iio:adis16400: " Lars-Peter Clausen
2013-09-21 12:15   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 14/24] iio:adis_lib: " Lars-Peter Clausen
2013-09-21 12:15   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 15/24] iio:mpu6050: " Lars-Peter Clausen
2013-09-21 12:16   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 16/24] iio:adjd_s311: " Lars-Peter Clausen
2013-09-21 12:16   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 17/24] iio:tcs3472: " Lars-Peter Clausen
2013-09-21 12:17   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 18/24] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-09-21 12:17   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 19/24] staging:iio:lis3l02dq: " Lars-Peter Clausen
2013-09-21 12:18   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 20/24] staging:iio:ad7606: " Lars-Peter Clausen
2013-09-21 12:18   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 21/24] staging:iio:ad799x: " Lars-Peter Clausen
2013-09-21 12:19   ` Jonathan Cameron
2013-09-19 12:59 ` [PATCH 22/24] staging:iio:mxs-lradc: " Lars-Peter Clausen
2013-09-21 12:19   ` Jonathan Cameron
2013-09-19 13:00 ` [PATCH 23/24] staging:iio:dummy: " Lars-Peter Clausen
2013-09-21 12:19   ` Jonathan Cameron
2013-09-19 13:00 ` [PATCH 24/24] staging:iio:ade7758: " Lars-Peter Clausen
2013-09-21 12:20   ` Jonathan Cameron
2013-09-21 12:08 ` [PATCH 01/24] iio: Add iio_push_buffers_with_timestamp() helper Jonathan Cameron

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).