* [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void *
@ 2013-09-15 16:50 Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers() Lars-Peter Clausen
` (26 more replies)
0 siblings, 27 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Change the type of the 'data' parameter for iio_push_to_buffers() from 'u8 *' to
'const void *'. Drivers typically use the correct type (e.g. __be16 *) for their
data buffer. When passing the buffer to iio_push_to_buffers() it needs to be
cast to 'u8 *' for the compiler to not complain (and also having to add __force
if we want to keep sparse happy as well). Since the buffer implementation should
not care about the data layout (except the size of one sample) using a void
pointer is the correct thing to do. Also make it const as the buffer
implementations are not supposed to modify it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/buffer_cb.c | 6 +++---
drivers/iio/industrialio-buffer.c | 10 +++++-----
drivers/iio/kfifo_buf.c | 2 +-
include/linux/iio/buffer.h | 6 +++---
include/linux/iio/consumer.h | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c
index 9d19ba7..5f40b3a 100644
--- a/drivers/iio/buffer_cb.c
+++ b/drivers/iio/buffer_cb.c
@@ -7,12 +7,12 @@
struct iio_cb_buffer {
struct iio_buffer buffer;
- int (*cb)(u8 *data, void *private);
+ int (*cb)(const void *data, void *private);
void *private;
struct iio_channel *channels;
};
-static int iio_buffer_cb_store_to(struct iio_buffer *buffer, u8 *data)
+static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data)
{
struct iio_cb_buffer *cb_buff = container_of(buffer,
struct iio_cb_buffer,
@@ -26,7 +26,7 @@ static struct iio_buffer_access_funcs iio_cb_access = {
};
struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
- int (*cb)(u8 *data,
+ int (*cb)(const void *data,
void *private),
void *private)
{
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 7ea2edb..a7ac4b5 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -769,8 +769,8 @@ struct iio_demux_table {
struct list_head l;
};
-static unsigned char *iio_demux(struct iio_buffer *buffer,
- unsigned char *datain)
+static const void *iio_demux(struct iio_buffer *buffer,
+ const void *datain)
{
struct iio_demux_table *t;
@@ -783,9 +783,9 @@ static unsigned char *iio_demux(struct iio_buffer *buffer,
return buffer->demux_bounce;
}
-static int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data)
+static int iio_push_to_buffer(struct iio_buffer *buffer, const void *data)
{
- unsigned char *dataout = iio_demux(buffer, data);
+ const void *dataout = iio_demux(buffer, data);
return buffer->access->store_to(buffer, dataout);
}
@@ -800,7 +800,7 @@ static void iio_buffer_demux_free(struct iio_buffer *buffer)
}
-int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data)
+int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
{
int ret;
struct iio_buffer *buf;
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 1bea41b..538d461 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -95,7 +95,7 @@ static int iio_set_length_kfifo(struct iio_buffer *r, int length)
}
static int iio_store_to_kfifo(struct iio_buffer *r,
- u8 *data)
+ const void *data)
{
int ret;
struct iio_kfifo *kf = iio_to_kfifo(r);
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 2bac0eb..e5507e9 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -36,7 +36,7 @@ struct iio_buffer;
* any of them not existing.
**/
struct iio_buffer_access_funcs {
- int (*store_to)(struct iio_buffer *buffer, u8 *data);
+ int (*store_to)(struct iio_buffer *buffer, const void *data);
int (*read_first_n)(struct iio_buffer *buffer,
size_t n,
char __user *buf);
@@ -81,7 +81,7 @@ struct iio_buffer {
bool stufftoread;
const struct attribute_group *attrs;
struct list_head demux_list;
- unsigned char *demux_bounce;
+ void *demux_bounce;
struct list_head buffer_list;
};
@@ -120,7 +120,7 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
* @indio_dev: iio_dev structure for device.
* @data: Full scan.
*/
-int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data);
+int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
int iio_update_demux(struct iio_dev *indio_dev);
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 833926c..2752b1f 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -77,7 +77,7 @@ struct iio_cb_buffer;
* fail.
*/
struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
- int (*cb)(u8 *data,
+ int (*cb)(const void *data,
void *private),
void *private);
/**
--
1.8.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
@ 2013-09-15 16:50 ` Lars-Peter Clausen
2013-09-15 18:05 ` Jonathan Cameron
2013-09-15 16:50 ` [PATCH 03/27] staging:iio: " Lars-Peter Clausen
` (25 subsequent siblings)
26 siblings, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Now that iio_push_to_buffers() takes a void pointer for the data parameter we
can remove those casts to u8*.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/accel/bma180.c | 2 +-
drivers/iio/accel/hid-sensor-accel-3d.c | 7 ++++---
drivers/iio/adc/ad7266.c | 2 +-
drivers/iio/adc/ad7298.c | 2 +-
drivers/iio/adc/ad7923.c | 2 +-
drivers/iio/adc/ad_sigma_delta.c | 2 +-
drivers/iio/adc/at91_adc.c | 2 +-
drivers/iio/gyro/hid-sensor-gyro-3d.c | 7 ++++---
drivers/iio/gyro/itg3200_buffer.c | 2 +-
drivers/iio/light/adjd_s311.c | 2 +-
drivers/iio/light/hid-sensor-als.c | 7 ++++---
drivers/iio/light/tcs3472.c | 2 +-
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 7 ++++---
13 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 12e32e6..3eff246 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -490,7 +490,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
}
mutex_unlock(&data->mutex);
- iio_push_to_buffers(indio_dev, (u8 *)data->buff);
+ iio_push_to_buffers(indio_dev, data->buff);
err:
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 46d22f3..dcda173 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -182,10 +182,11 @@ static const struct iio_info accel_3d_info = {
};
/* Function to push data to buffer */
-static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
+ int len)
{
dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
}
/* Callback handler to send event after all samples are received and captured */
@@ -200,7 +201,7 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
accel_state->common_attributes.data_ready);
if (accel_state->common_attributes.data_ready)
hid_sensor_push_data(indio_dev,
- (u8 *)accel_state->accel_val,
+ accel_state->accel_val,
sizeof(accel_state->accel_val));
return 0;
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 371731d..5bfed23 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -98,7 +98,7 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
if (ret == 0) {
if (indio_dev->scan_timestamp)
((s64 *)st->data)[1] = pf->timestamp;
- iio_push_to_buffers(indio_dev, (u8 *)st->data);
+ iio_push_to_buffers(indio_dev, st->data);
}
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 85d1481..0812556 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -172,7 +172,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
&time_ns, sizeof(time_ns));
}
- iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
+ iio_push_to_buffers(indio_dev, st->rx_buf);
done:
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 4108dbb..7eb4cb5 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -187,7 +187,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
&time_ns, sizeof(time_ns));
}
- iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
+ iio_push_to_buffers(indio_dev, st->rx_buf);
done:
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index f0d6335..78d276f 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -391,7 +391,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
break;
}
- iio_push_to_buffers(indio_dev, (uint8_t *)data);
+ iio_push_to_buffers(indio_dev, data);
iio_trigger_notify_done(indio_dev->trig);
sigma_delta->irq_dis = false;
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 84be63b..6da5ebb 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -89,7 +89,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
*timestamp = pf->timestamp;
}
- iio_push_to_buffers(idev, (u8 *)st->buffer);
+ iio_push_to_buffers(idev, st->buffer);
iio_trigger_notify_done(idev->trig);
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c688d97..ea01c6bc 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -182,10 +182,11 @@ static const struct iio_info gyro_3d_info = {
};
/* Function to push data to buffer */
-static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
+ int len)
{
dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
}
/* Callback handler to send event after all samples are received and captured */
@@ -200,7 +201,7 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev,
gyro_state->common_attributes.data_ready);
if (gyro_state->common_attributes.data_ready)
hid_sensor_push_data(indio_dev,
- (u8 *)gyro_state->gyro_val,
+ gyro_state->gyro_val,
sizeof(gyro_state->gyro_val));
return 0;
diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
index 6c43af9..6b3c301 100644
--- a/drivers/iio/gyro/itg3200_buffer.c
+++ b/drivers/iio/gyro/itg3200_buffer.c
@@ -59,7 +59,7 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
&pf->timestamp, sizeof(pf->timestamp));
- iio_push_to_buffers(indio_dev, (u8 *)buf);
+ iio_push_to_buffers(indio_dev, buf);
iio_trigger_notify_done(indio_dev->trig);
error_ret:
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
index c0da351..c9c8b00 100644
--- a/drivers/iio/light/adjd_s311.c
+++ b/drivers/iio/light/adjd_s311.c
@@ -141,7 +141,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
if (indio_dev->scan_timestamp)
*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
= time_ns;
- iio_push_to_buffers(indio_dev, (u8 *)data->buffer);
+ iio_push_to_buffers(indio_dev, data->buffer);
done:
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index e59d00c..fa6ae8c 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -161,10 +161,11 @@ static const struct iio_info als_info = {
};
/* Function to push data to buffer */
-static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
+ int len)
{
dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
}
/* Callback handler to send event after all samples are received and captured */
@@ -179,7 +180,7 @@ static int als_proc_event(struct hid_sensor_hub_device *hsdev,
als_state->common_attributes.data_ready);
if (als_state->common_attributes.data_ready)
hid_sensor_push_data(indio_dev,
- (u8 *)&als_state->illum,
+ &als_state->illum,
sizeof(als_state->illum));
return 0;
diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index dc7d823..7bf2969 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -195,7 +195,7 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
if (indio_dev->scan_timestamp)
*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
= iio_get_time_ns();
- iio_push_to_buffers(indio_dev, (u8 *)data->buffer);
+ iio_push_to_buffers(indio_dev, data->buffer);
done:
iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index a98460b..2634920 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -183,10 +183,11 @@ static const struct iio_info magn_3d_info = {
};
/* Function to push data to buffer */
-static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
+ int len)
{
dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
}
/* Callback handler to send event after all samples are received and captured */
@@ -201,7 +202,7 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
magn_state->common_attributes.data_ready);
if (magn_state->common_attributes.data_ready)
hid_sensor_push_data(indio_dev,
- (u8 *)magn_state->magn_val,
+ magn_state->magn_val,
sizeof(magn_state->magn_val));
return 0;
--
1.8.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 03/27] staging:iio: Remove unnecessary casts for iio_push_to_buffers()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers() Lars-Peter Clausen
@ 2013-09-15 16:50 ` Lars-Peter Clausen
2013-09-15 18:06 ` Jonathan Cameron
2013-09-15 16:50 ` [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
` (24 subsequent siblings)
26 siblings, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Now that iio_push_to_buffers() takes a void pointer for the data parameter we
can remove those casts to u8*.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/accel/lis3l02dq_ring.c | 2 +-
drivers/staging/iio/adc/mxs-lradc.c | 2 +-
drivers/staging/iio/iio_simple_dummy_buffer.c | 2 +-
drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +-
drivers/staging/iio/meter/ade7758_ring.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index 5b8f0f6..36dcc7e 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -150,7 +150,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
if (indio_dev->scan_timestamp)
*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
= pf->timestamp;
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
kfree(data);
done:
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index f36cde5..7401230 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -631,7 +631,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p)
*timestamp = pf->timestamp;
}
- iio_push_to_buffers(iio, (u8 *)lradc->buffer);
+ iio_push_to_buffers(iio, lradc->buffer);
iio_trigger_notify_done(iio->trig);
diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c
index 72f400c..3921865 100644
--- a/drivers/staging/iio/iio_simple_dummy_buffer.c
+++ b/drivers/staging/iio/iio_simple_dummy_buffer.c
@@ -86,7 +86,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
if (indio_dev->scan_timestamp)
*(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
= iio_get_time_ns();
- iio_push_to_buffers(indio_dev, (u8 *)data);
+ iio_push_to_buffers(indio_dev, data);
kfree(data);
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 00f7067..712f3c2 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -676,7 +676,7 @@ static void ad5933_work(struct work_struct *work)
} else {
buf[0] = be16_to_cpu(buf[0]);
}
- iio_push_to_buffers(indio_dev, (u8 *)buf);
+ iio_push_to_buffers(indio_dev, buf);
} else {
/* no data available - try again later */
schedule_delayed_work(&st->work, st->poll_time_jiffies);
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
index 7d5db71..3d8bc2d 100644
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ b/drivers/staging/iio/meter/ade7758_ring.c
@@ -73,7 +73,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
if (indio_dev->scan_timestamp)
dat64[1] = pf->timestamp;
- iio_push_to_buffers(indio_dev, (u8 *)dat64);
+ iio_push_to_buffers(indio_dev, dat64);
iio_trigger_notify_done(indio_dev->trig);
--
1.8.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers() Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 03/27] staging:iio: " Lars-Peter Clausen
@ 2013-09-15 16:50 ` Lars-Peter Clausen
2013-09-15 17:44 ` Peter Meerwald
2013-09-16 7:52 ` Jonathan Cameron
2013-09-15 16:50 ` [PATCH 05/27] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
` (23 subsequent siblings)
26 siblings, 2 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 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: 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 | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index e5507e9..1ebc382 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -116,12 +116,37 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
struct iio_buffer *buffer, int bit);
/**
- * iio_push_to_buffers() - push to a registered buffer.
+ * iio_push_to_buffers_with_timestamp() - push to a registered buffer.
* @indio_dev: iio_dev structure for device.
* @data: Full scan.
*/
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] 41+ messages in thread
* [PATCH 05/27] iio:bma180: Use iio_push_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (2 preceding siblings ...)
2013-09-15 16:50 ` [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
@ 2013-09-15 16:50 ` Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 06/27] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
` (22 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 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] 41+ messages in thread
* [PATCH 06/27] iio:ad7266: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (3 preceding siblings ...)
2013-09-15 16:50 ` [PATCH 05/27] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-15 16:50 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 07/27] iio:ad7298: " Lars-Peter Clausen
` (21 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:50 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 5bfed23..e94ea65 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] 41+ messages in thread
* [PATCH 07/27] iio:ad7298: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (4 preceding siblings ...)
2013-09-15 16:50 ` [PATCH 06/27] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 08/27] iio:ad7476: " Lars-Peter Clausen
` (20 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 08/27] iio:ad7476: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (5 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 07/27] iio:ad7298: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 09/27] iio:ad7887: " Lars-Peter Clausen
` (19 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 09/27] iio:ad7887: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (6 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 08/27] iio:ad7476: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 10/27] iio:ad7923: " Lars-Peter Clausen
` (18 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 10/27] iio:ad7923: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (7 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 09/27] iio:ad7887: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 11/27] iio:ad_sigma_delta: " Lars-Peter Clausen
` (17 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 11/27] iio:ad_sigma_delta: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (8 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 10/27] iio:ad7923: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 12/27] iio:at91_adc: " Lars-Peter Clausen
` (16 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 12/27] iio:at91_adc: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (9 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 11/27] iio:ad_sigma_delta: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 13/27] iio:max1363: " Lars-Peter Clausen
` (15 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 13/27] iio:max1363: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (10 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 12/27] iio:at91_adc: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 14/27] iio:st_sensors: " Lars-Peter Clausen
` (14 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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 4fb35d1..531a57b 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] 41+ messages in thread
* [PATCH 14/27] iio:st_sensors: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (11 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 13/27] iio:max1363: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 15/27] iio:itg3200: " Lars-Peter Clausen
` (13 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 15/27] iio:itg3200: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (12 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 14/27] iio:st_sensors: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 16/27] iio:adis16400: " Lars-Peter Clausen
` (12 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 16/27] iio:adis16400: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (13 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 15/27] iio:itg3200: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 17/27] iio:adis_lib: " Lars-Peter Clausen
` (11 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 17/27] iio:adis_lib: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (14 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 16/27] iio:adis16400: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 18/27] iio:mpu6050: " Lars-Peter Clausen
` (10 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 18/27] iio:mpu6050: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (15 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 17/27] iio:adis_lib: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 19/27] iio:adjd_s311: " Lars-Peter Clausen
` (9 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 19/27] iio:adjd_s311: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (16 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 18/27] iio:mpu6050: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 20/27] iio:tcs3472: " Lars-Peter Clausen
` (8 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 20/27] iio:tcs3472: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (17 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 19/27] iio:adjd_s311: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 21/27] iio:gp2ap020a00f: " Lars-Peter Clausen
` (7 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 21/27] iio:gp2ap020a00f: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (18 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 20/27] iio:tcs3472: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 22/27] staging:iio:lis3l02dq: " Lars-Peter Clausen
` (6 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 22/27] staging:iio:lis3l02dq: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (19 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 21/27] iio:gp2ap020a00f: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 23/27] staging:iio:ad7606: " Lars-Peter Clausen
` (5 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 23/27] staging:iio:ad7606: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (20 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 22/27] staging:iio:lis3l02dq: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 24/27] staging:iio:ad799x: " Lars-Peter Clausen
` (4 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 24/27] staging:iio:ad799x: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (21 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 23/27] staging:iio:ad7606: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 25/27] staging:iio:mxs-lradc: " Lars-Peter Clausen
` (3 subsequent siblings)
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (22 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 24/27] staging:iio:ad799x: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-16 13:53 ` Marek Vasut
2013-09-15 16:51 ` [PATCH 26/27] staging:iio:dummy: " Lars-Peter Clausen
` (2 subsequent siblings)
26 siblings, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Lars-Peter Clausen, Fabio Estevam, Marek Vasut
Makes the code a bit shorter and less ugly.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Marek Vasut <marex@denx.de>
---
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] 41+ messages in thread
* [PATCH 26/27] staging:iio:dummy: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (23 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 25/27] staging:iio:mxs-lradc: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 27/27] staging:iio:ade7758: " Lars-Peter Clausen
2013-09-15 18:04 ` [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Jonathan Cameron
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* [PATCH 27/27] staging:iio:ade7758: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (24 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 26/27] staging:iio:dummy: " Lars-Peter Clausen
@ 2013-09-15 16:51 ` Lars-Peter Clausen
2013-09-15 18:04 ` [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Jonathan Cameron
26 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-15 16:51 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] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-15 16:50 ` [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
@ 2013-09-15 17:44 ` Peter Meerwald
2013-09-16 7:52 ` Jonathan Cameron
1 sibling, 0 replies; 41+ messages in thread
From: Peter Meerwald @ 2013-09-15 17:44 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Jonathan Cameron, linux-iio, Oleksandr Kravchenko, Josh Wu,
Denis Ciocca, Manuel Stahl, Ge Gao, Jacek Anaszewski,
Fabio Estevam, Marek Vasut
I like!
> 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().
computation of the buffer size is the remaining piece of ugliness;
indio_dev->scan_bytes in not available at probe time
> 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: Peter Meerwald <pmeerw@pmeerw.net>
twice, so honoured :)
nitpick below
> diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
> index e5507e9..1ebc382 100644
> --- a/include/linux/iio/buffer.h
> +++ b/include/linux/iio/buffer.h
> @@ -116,12 +116,37 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
> struct iio_buffer *buffer, int bit);
>
> /**
> - * iio_push_to_buffers() - push to a registered buffer.
> + * iio_push_to_buffers_with_timestamp() - push to a registered buffer.
should still be iio_push_to_buffers() here
> * @indio_dev: iio_dev structure for device.
> * @data: Full scan.
> */
> 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);
>
> /**
>
--
Peter Meerwald
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void *
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
` (25 preceding siblings ...)
2013-09-15 16:51 ` [PATCH 27/27] staging:iio:ade7758: " Lars-Peter Clausen
@ 2013-09-15 18:04 ` Jonathan Cameron
26 siblings, 0 replies; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-15 18:04 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 09/15/13 17:50, Lars-Peter Clausen wrote:
> Change the type of the 'data' parameter for iio_push_to_buffers() from 'u8 *' to
> 'const void *'. Drivers typically use the correct type (e.g. __be16 *) for their
> data buffer. When passing the buffer to iio_push_to_buffers() it needs to be
> cast to 'u8 *' for the compiler to not complain (and also having to add __force
> if we want to keep sparse happy as well). Since the buffer implementation should
> not care about the data layout (except the size of one sample) using a void
> pointer is the correct thing to do. Also make it const as the buffer
> implementations are not supposed to modify it.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Nice little cleanup. I can't for the life of me remember how
we ended up with that being u8 *. Probably something to do with the
original sw_ring buffer implementation.
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/iio/buffer_cb.c | 6 +++---
> drivers/iio/industrialio-buffer.c | 10 +++++-----
> drivers/iio/kfifo_buf.c | 2 +-
> include/linux/iio/buffer.h | 6 +++---
> include/linux/iio/consumer.h | 2 +-
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c
> index 9d19ba7..5f40b3a 100644
> --- a/drivers/iio/buffer_cb.c
> +++ b/drivers/iio/buffer_cb.c
> @@ -7,12 +7,12 @@
>
> struct iio_cb_buffer {
> struct iio_buffer buffer;
> - int (*cb)(u8 *data, void *private);
> + int (*cb)(const void *data, void *private);
> void *private;
> struct iio_channel *channels;
> };
>
> -static int iio_buffer_cb_store_to(struct iio_buffer *buffer, u8 *data)
> +static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data)
> {
> struct iio_cb_buffer *cb_buff = container_of(buffer,
> struct iio_cb_buffer,
> @@ -26,7 +26,7 @@ static struct iio_buffer_access_funcs iio_cb_access = {
> };
>
> struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
> - int (*cb)(u8 *data,
> + int (*cb)(const void *data,
> void *private),
> void *private)
> {
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 7ea2edb..a7ac4b5 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -769,8 +769,8 @@ struct iio_demux_table {
> struct list_head l;
> };
>
> -static unsigned char *iio_demux(struct iio_buffer *buffer,
> - unsigned char *datain)
> +static const void *iio_demux(struct iio_buffer *buffer,
> + const void *datain)
> {
> struct iio_demux_table *t;
>
> @@ -783,9 +783,9 @@ static unsigned char *iio_demux(struct iio_buffer *buffer,
> return buffer->demux_bounce;
> }
>
> -static int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data)
> +static int iio_push_to_buffer(struct iio_buffer *buffer, const void *data)
> {
> - unsigned char *dataout = iio_demux(buffer, data);
> + const void *dataout = iio_demux(buffer, data);
>
> return buffer->access->store_to(buffer, dataout);
> }
> @@ -800,7 +800,7 @@ static void iio_buffer_demux_free(struct iio_buffer *buffer)
> }
>
>
> -int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data)
> +int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
> {
> int ret;
> struct iio_buffer *buf;
> diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
> index 1bea41b..538d461 100644
> --- a/drivers/iio/kfifo_buf.c
> +++ b/drivers/iio/kfifo_buf.c
> @@ -95,7 +95,7 @@ static int iio_set_length_kfifo(struct iio_buffer *r, int length)
> }
>
> static int iio_store_to_kfifo(struct iio_buffer *r,
> - u8 *data)
> + const void *data)
> {
> int ret;
> struct iio_kfifo *kf = iio_to_kfifo(r);
> diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
> index 2bac0eb..e5507e9 100644
> --- a/include/linux/iio/buffer.h
> +++ b/include/linux/iio/buffer.h
> @@ -36,7 +36,7 @@ struct iio_buffer;
> * any of them not existing.
> **/
> struct iio_buffer_access_funcs {
> - int (*store_to)(struct iio_buffer *buffer, u8 *data);
> + int (*store_to)(struct iio_buffer *buffer, const void *data);
> int (*read_first_n)(struct iio_buffer *buffer,
> size_t n,
> char __user *buf);
> @@ -81,7 +81,7 @@ struct iio_buffer {
> bool stufftoread;
> const struct attribute_group *attrs;
> struct list_head demux_list;
> - unsigned char *demux_bounce;
> + void *demux_bounce;
> struct list_head buffer_list;
> };
>
> @@ -120,7 +120,7 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
> * @indio_dev: iio_dev structure for device.
> * @data: Full scan.
> */
> -int iio_push_to_buffers(struct iio_dev *indio_dev, unsigned char *data);
> +int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
>
> int iio_update_demux(struct iio_dev *indio_dev);
>
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 833926c..2752b1f 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -77,7 +77,7 @@ struct iio_cb_buffer;
> * fail.
> */
> struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
> - int (*cb)(u8 *data,
> + int (*cb)(const void *data,
> void *private),
> void *private);
> /**
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers()
2013-09-15 16:50 ` [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers() Lars-Peter Clausen
@ 2013-09-15 18:05 ` Jonathan Cameron
0 siblings, 0 replies; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-15 18:05 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 09/15/13 17:50, Lars-Peter Clausen wrote:
> Now that iio_push_to_buffers() takes a void pointer for the data parameter we
> can remove those casts to u8*.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
applied.
> ---
> drivers/iio/accel/bma180.c | 2 +-
> drivers/iio/accel/hid-sensor-accel-3d.c | 7 ++++---
> drivers/iio/adc/ad7266.c | 2 +-
> drivers/iio/adc/ad7298.c | 2 +-
> drivers/iio/adc/ad7923.c | 2 +-
> drivers/iio/adc/ad_sigma_delta.c | 2 +-
> drivers/iio/adc/at91_adc.c | 2 +-
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 7 ++++---
> drivers/iio/gyro/itg3200_buffer.c | 2 +-
> drivers/iio/light/adjd_s311.c | 2 +-
> drivers/iio/light/hid-sensor-als.c | 7 ++++---
> drivers/iio/light/tcs3472.c | 2 +-
> drivers/iio/magnetometer/hid-sensor-magn-3d.c | 7 ++++---
> 13 files changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 12e32e6..3eff246 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -490,7 +490,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
> }
> mutex_unlock(&data->mutex);
>
> - iio_push_to_buffers(indio_dev, (u8 *)data->buff);
> + iio_push_to_buffers(indio_dev, data->buff);
> err:
> iio_trigger_notify_done(indio_dev->trig);
>
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 46d22f3..dcda173 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -182,10 +182,11 @@ static const struct iio_info accel_3d_info = {
> };
>
> /* Function to push data to buffer */
> -static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
> +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
> + int len)
> {
> dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
> }
>
> /* Callback handler to send event after all samples are received and captured */
> @@ -200,7 +201,7 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
> accel_state->common_attributes.data_ready);
> if (accel_state->common_attributes.data_ready)
> hid_sensor_push_data(indio_dev,
> - (u8 *)accel_state->accel_val,
> + accel_state->accel_val,
> sizeof(accel_state->accel_val));
>
> return 0;
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index 371731d..5bfed23 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -98,7 +98,7 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
> if (ret == 0) {
> if (indio_dev->scan_timestamp)
> ((s64 *)st->data)[1] = pf->timestamp;
> - iio_push_to_buffers(indio_dev, (u8 *)st->data);
> + iio_push_to_buffers(indio_dev, st->data);
> }
>
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
> index 85d1481..0812556 100644
> --- a/drivers/iio/adc/ad7298.c
> +++ b/drivers/iio/adc/ad7298.c
> @@ -172,7 +172,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
> &time_ns, sizeof(time_ns));
> }
>
> - iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
> + iio_push_to_buffers(indio_dev, st->rx_buf);
>
> done:
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index 4108dbb..7eb4cb5 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -187,7 +187,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
> &time_ns, sizeof(time_ns));
> }
>
> - iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf);
> + iio_push_to_buffers(indio_dev, st->rx_buf);
>
> done:
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
> index f0d6335..78d276f 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -391,7 +391,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
> break;
> }
>
> - iio_push_to_buffers(indio_dev, (uint8_t *)data);
> + iio_push_to_buffers(indio_dev, data);
>
> iio_trigger_notify_done(indio_dev->trig);
> sigma_delta->irq_dis = false;
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 84be63b..6da5ebb 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -89,7 +89,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
> *timestamp = pf->timestamp;
> }
>
> - iio_push_to_buffers(idev, (u8 *)st->buffer);
> + iio_push_to_buffers(idev, st->buffer);
>
> iio_trigger_notify_done(idev->trig);
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index c688d97..ea01c6bc 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -182,10 +182,11 @@ static const struct iio_info gyro_3d_info = {
> };
>
> /* Function to push data to buffer */
> -static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
> +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
> + int len)
> {
> dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
> }
>
> /* Callback handler to send event after all samples are received and captured */
> @@ -200,7 +201,7 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev,
> gyro_state->common_attributes.data_ready);
> if (gyro_state->common_attributes.data_ready)
> hid_sensor_push_data(indio_dev,
> - (u8 *)gyro_state->gyro_val,
> + gyro_state->gyro_val,
> sizeof(gyro_state->gyro_val));
>
> return 0;
> diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
> index 6c43af9..6b3c301 100644
> --- a/drivers/iio/gyro/itg3200_buffer.c
> +++ b/drivers/iio/gyro/itg3200_buffer.c
> @@ -59,7 +59,7 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
> memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
> &pf->timestamp, sizeof(pf->timestamp));
>
> - iio_push_to_buffers(indio_dev, (u8 *)buf);
> + iio_push_to_buffers(indio_dev, buf);
> iio_trigger_notify_done(indio_dev->trig);
>
> error_ret:
> diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
> index c0da351..c9c8b00 100644
> --- a/drivers/iio/light/adjd_s311.c
> +++ b/drivers/iio/light/adjd_s311.c
> @@ -141,7 +141,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
> if (indio_dev->scan_timestamp)
> *(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
> = time_ns;
> - iio_push_to_buffers(indio_dev, (u8 *)data->buffer);
> + iio_push_to_buffers(indio_dev, data->buffer);
>
> done:
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index e59d00c..fa6ae8c 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -161,10 +161,11 @@ static const struct iio_info als_info = {
> };
>
> /* Function to push data to buffer */
> -static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
> +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
> + int len)
> {
> dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
> }
>
> /* Callback handler to send event after all samples are received and captured */
> @@ -179,7 +180,7 @@ static int als_proc_event(struct hid_sensor_hub_device *hsdev,
> als_state->common_attributes.data_ready);
> if (als_state->common_attributes.data_ready)
> hid_sensor_push_data(indio_dev,
> - (u8 *)&als_state->illum,
> + &als_state->illum,
> sizeof(als_state->illum));
>
> return 0;
> diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
> index dc7d823..7bf2969 100644
> --- a/drivers/iio/light/tcs3472.c
> +++ b/drivers/iio/light/tcs3472.c
> @@ -195,7 +195,7 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
> if (indio_dev->scan_timestamp)
> *(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
> = iio_get_time_ns();
> - iio_push_to_buffers(indio_dev, (u8 *)data->buffer);
> + iio_push_to_buffers(indio_dev, data->buffer);
>
> done:
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index a98460b..2634920 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> @@ -183,10 +183,11 @@ static const struct iio_info magn_3d_info = {
> };
>
> /* Function to push data to buffer */
> -static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
> +static void hid_sensor_push_data(struct iio_dev *indio_dev, const void *data,
> + int len)
> {
> dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
> }
>
> /* Callback handler to send event after all samples are received and captured */
> @@ -201,7 +202,7 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
> magn_state->common_attributes.data_ready);
> if (magn_state->common_attributes.data_ready)
> hid_sensor_push_data(indio_dev,
> - (u8 *)magn_state->magn_val,
> + magn_state->magn_val,
> sizeof(magn_state->magn_val));
>
> return 0;
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 03/27] staging:iio: Remove unnecessary casts for iio_push_to_buffers()
2013-09-15 16:50 ` [PATCH 03/27] staging:iio: " Lars-Peter Clausen
@ 2013-09-15 18:06 ` Jonathan Cameron
0 siblings, 0 replies; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-15 18:06 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 09/15/13 17:50, Lars-Peter Clausen wrote:
> Now that iio_push_to_buffers() takes a void pointer for the data parameter we
> can remove those casts to u8*.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks. I'll get to the rest of series another time.
> ---
> drivers/staging/iio/accel/lis3l02dq_ring.c | 2 +-
> drivers/staging/iio/adc/mxs-lradc.c | 2 +-
> drivers/staging/iio/iio_simple_dummy_buffer.c | 2 +-
> drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +-
> drivers/staging/iio/meter/ade7758_ring.c | 2 +-
> 5 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
> index 5b8f0f6..36dcc7e 100644
> --- a/drivers/staging/iio/accel/lis3l02dq_ring.c
> +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
> @@ -150,7 +150,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
> if (indio_dev->scan_timestamp)
> *(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
> = pf->timestamp;
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
>
> kfree(data);
> done:
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index f36cde5..7401230 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -631,7 +631,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p)
> *timestamp = pf->timestamp;
> }
>
> - iio_push_to_buffers(iio, (u8 *)lradc->buffer);
> + iio_push_to_buffers(iio, lradc->buffer);
>
> iio_trigger_notify_done(iio->trig);
>
> diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c
> index 72f400c..3921865 100644
> --- a/drivers/staging/iio/iio_simple_dummy_buffer.c
> +++ b/drivers/staging/iio/iio_simple_dummy_buffer.c
> @@ -86,7 +86,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
> if (indio_dev->scan_timestamp)
> *(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
> = iio_get_time_ns();
> - iio_push_to_buffers(indio_dev, (u8 *)data);
> + iio_push_to_buffers(indio_dev, data);
>
> kfree(data);
>
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 00f7067..712f3c2 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -676,7 +676,7 @@ static void ad5933_work(struct work_struct *work)
> } else {
> buf[0] = be16_to_cpu(buf[0]);
> }
> - iio_push_to_buffers(indio_dev, (u8 *)buf);
> + iio_push_to_buffers(indio_dev, buf);
> } else {
> /* no data available - try again later */
> schedule_delayed_work(&st->work, st->poll_time_jiffies);
> diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
> index 7d5db71..3d8bc2d 100644
> --- a/drivers/staging/iio/meter/ade7758_ring.c
> +++ b/drivers/staging/iio/meter/ade7758_ring.c
> @@ -73,7 +73,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
> if (indio_dev->scan_timestamp)
> dat64[1] = pf->timestamp;
>
> - iio_push_to_buffers(indio_dev, (u8 *)dat64);
> + iio_push_to_buffers(indio_dev, dat64);
>
> iio_trigger_notify_done(indio_dev->trig);
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-15 16:50 ` [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
2013-09-15 17:44 ` Peter Meerwald
@ 2013-09-16 7:52 ` Jonathan Cameron
2013-09-16 7:58 ` Peter Meerwald
2013-09-16 8:19 ` Lars-Peter Clausen
1 sibling, 2 replies; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-16 7:52 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 15/09/13 17:50, 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: 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>
Interesting. Whilst this obviously results in the removal of a lot of
repeated code, I am nervous about introducing the 'hidden' requirement
that the data buffer passed in must be bigger than is 'apparently' used
in the code calling this. I'm not sure what the right answer is though.
> ---
> include/linux/iio/buffer.h | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
> index e5507e9..1ebc382 100644
> --- a/include/linux/iio/buffer.h
> +++ b/include/linux/iio/buffer.h
> @@ -116,12 +116,37 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
> struct iio_buffer *buffer, int bit);
>
> /**
> - * iio_push_to_buffers() - push to a registered buffer.
> + * iio_push_to_buffers_with_timestamp() - push to a registered buffer.
> * @indio_dev: iio_dev structure for device.
> * @data: Full scan.
> */
> 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] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 7:52 ` Jonathan Cameron
@ 2013-09-16 7:58 ` Peter Meerwald
2013-09-16 8:19 ` Lars-Peter Clausen
2013-09-16 8:19 ` Lars-Peter Clausen
1 sibling, 1 reply; 41+ messages in thread
From: Peter Meerwald @ 2013-09-16 7:58 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: Lars-Peter Clausen, linux-iio
> Interesting. Whilst this obviously results in the removal of a lot of
> repeated code, I am nervous about introducing the 'hidden' requirement
> that the data buffer passed in must be bigger than is 'apparently' used
> in the code calling this. I'm not sure what the right answer is though.
maybe add some iio magic that always allocs the buffer dynamically based
on the channel definition/scan_bytes
regards, p.
--
Peter Meerwald
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 7:58 ` Peter Meerwald
@ 2013-09-16 8:19 ` Lars-Peter Clausen
2013-09-16 18:35 ` Jonathan Cameron
0 siblings, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-16 8:19 UTC (permalink / raw)
To: Peter Meerwald; +Cc: Jonathan Cameron, linux-iio
On 09/16/2013 09:58 AM, Peter Meerwald wrote:
>
>> Interesting. Whilst this obviouslby results in the removal of a lot of
>> repeated code, I am nervous about introducing the 'hidden' requirement
>> that the data buffer passed in must be bigger than is 'apparently' used
>> in the code calling this. I'm not sure what the right answer is though.
>
> maybe add some iio magic that always allocs the buffer dynamically based
> on the channel definition/scan_bytes
A lot of drivers already do something like priv_data->buffer =
kzalloc(indio_dev->scan_bytes, ...) in their update_scan_mode callback.
Maybe we can add a transfer_buffer field to the iio_dev struct and have a
function that can be used as a default update_scan_mode callback that
allocates the buffer.
- Lars
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 7:52 ` Jonathan Cameron
2013-09-16 7:58 ` Peter Meerwald
@ 2013-09-16 8:19 ` Lars-Peter Clausen
2013-09-16 18:37 ` Jonathan Cameron
1 sibling, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-16 8:19 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Oleksandr Kravchenko, Josh Wu, Denis Ciocca,
Manuel Stahl, Ge Gao, Peter Meerwald, Jacek Anaszewski,
Fabio Estevam, Marek Vasut
On 09/16/2013 09:52 AM, Jonathan Cameron wrote:
[...]
> Interesting. Whilst this obviously results in the removal of a lot of
> repeated code, I am nervous about introducing the 'hidden' requirement
> that the data buffer passed in must be bigger than is 'apparently' used
> in the code calling this. I'm not sure what the right answer is though.
Well it's not that hidden, it is clearly documented that the function is
going to store the timestamp in the buffer. My first idea was to make
storing timestamp a separate function. E.g. like
iio_store_timestamp(indio_dev, buf, ts);
iio_push_to_buffers(indio_dev, buf);
This makes it a bit more explicit that the buffer needs to be large enough
to hold the timestamp. But since that function would always be followed by
iio_push_to_buffers() I choose to add a function that does both, store the
timestamp and push the buffer out.
- Las
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
2013-09-15 16:51 ` [PATCH 25/27] staging:iio:mxs-lradc: " Lars-Peter Clausen
@ 2013-09-16 13:53 ` Marek Vasut
2013-09-16 16:54 ` Lars-Peter Clausen
0 siblings, 1 reply; 41+ messages in thread
From: Marek Vasut @ 2013-09-16 13:53 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, Fabio Estevam
Dear Lars-Peter Clausen,
> Makes the code a bit shorter and less ugly.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
> 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);
Indeed, this stuff was duplicated all around.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
2013-09-16 13:53 ` Marek Vasut
@ 2013-09-16 16:54 ` Lars-Peter Clausen
2013-09-16 17:08 ` Marek Vasut
0 siblings, 1 reply; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-16 16:54 UTC (permalink / raw)
To: Marek Vasut; +Cc: Jonathan Cameron, linux-iio, Fabio Estevam
On 09/16/2013 03:53 PM, Marek Vasut wrote:
> Dear Lars-Peter Clausen,
>
>> Makes the code a bit shorter and less ugly.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> Cc: Fabio Estevam <fabio.estevam@freescale.com>
>> Cc: Marek Vasut <marex@denx.de>
>> ---
>> 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);
>
> Indeed, this stuff was duplicated all around.
>
Is that a acked-by? :)
- Lars
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
2013-09-16 16:54 ` Lars-Peter Clausen
@ 2013-09-16 17:08 ` Marek Vasut
0 siblings, 0 replies; 41+ messages in thread
From: Marek Vasut @ 2013-09-16 17:08 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, Fabio Estevam
Dear Lars-Peter Clausen,
> On 09/16/2013 03:53 PM, Marek Vasut wrote:
> > Dear Lars-Peter Clausen,
> >
> >> Makes the code a bit shorter and less ugly.
> >>
> >> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> >> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> >> Cc: Marek Vasut <marex@denx.de>
> >> ---
> >>
> >> 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);
> >
> > Indeed, this stuff was duplicated all around.
>
> Is that a acked-by? :)
Reviewed-by: Marek Vasut <marex@denx.de>
instead. I'm not on too firm ground here, so I don't feel like ack is
appropriate from me on this matter ;-)
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 8:19 ` Lars-Peter Clausen
@ 2013-09-16 18:35 ` Jonathan Cameron
0 siblings, 0 replies; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-16 18:35 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Peter Meerwald, linux-iio
On 09/16/13 09:19, Lars-Peter Clausen wrote:
> On 09/16/2013 09:58 AM, Peter Meerwald wrote:
>>
>>> Interesting. Whilst this obviouslby results in the removal of a lot of
>>> repeated code, I am nervous about introducing the 'hidden' requirement
>>> that the data buffer passed in must be bigger than is 'apparently' used
>>> in the code calling this. I'm not sure what the right answer is though.
>>
>> maybe add some iio magic that always allocs the buffer dynamically based
>> on the channel definition/scan_bytes
>
> A lot of drivers already do something like priv_data->buffer =
> kzalloc(indio_dev->scan_bytes, ...) in their update_scan_mode callback.
> Maybe we can add a transfer_buffer field to the iio_dev struct and have a
> function that can be used as a default update_scan_mode callback that
> allocates the buffer.
That would probably make sense and remove quite a lot of my concern about these.
Can happen as a later patch set though.
Jonathan
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 8:19 ` Lars-Peter Clausen
@ 2013-09-16 18:37 ` Jonathan Cameron
2013-09-16 20:42 ` Lars-Peter Clausen
0 siblings, 1 reply; 41+ messages in thread
From: Jonathan Cameron @ 2013-09-16 18:37 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/16/13 09:19, Lars-Peter Clausen wrote:
> On 09/16/2013 09:52 AM, Jonathan Cameron wrote:
> [...]
>> Interesting. Whilst this obviously results in the removal of a lot of
>> repeated code, I am nervous about introducing the 'hidden' requirement
>> that the data buffer passed in must be bigger than is 'apparently' used
>> in the code calling this. I'm not sure what the right answer is though.
>
> Well it's not that hidden, it is clearly documented that the function is
> going to store the timestamp in the buffer.
But who reads the docs? :)
>My first idea was to make
> storing timestamp a separate function. E.g. like
>
> iio_store_timestamp(indio_dev, buf, ts);
> iio_push_to_buffers(indio_dev, buf);
That was my first thought as well.
>
> This makes it a bit more explicit that the buffer needs to be large enough
> to hold the timestamp. But since that function would always be followed by
> iio_push_to_buffers() I choose to add a function that does both, store the
> timestamp and push the buffer out.
Hmm. I'm more or less convinced though I think moving the buffer allocation
into the core (or nearly the core) would be a good way of avoiding any
confusion in the long run.
>
> - Las
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
2013-09-16 18:37 ` Jonathan Cameron
@ 2013-09-16 20:42 ` Lars-Peter Clausen
0 siblings, 0 replies; 41+ messages in thread
From: Lars-Peter Clausen @ 2013-09-16 20:42 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Oleksandr Kravchenko, Josh Wu, Denis Ciocca,
Manuel Stahl, Ge Gao, Peter Meerwald, Jacek Anaszewski,
Fabio Estevam, Marek Vasut
On 09/16/2013 08:37 PM, Jonathan Cameron wrote:
> On 09/16/13 09:19, Lars-Peter Clausen wrote:
>> On 09/16/2013 09:52 AM, Jonathan Cameron wrote:
>> [...]
>>> Interesting. Whilst this obviously results in the removal of a lot of
>>> repeated code, I am nervous about introducing the 'hidden' requirement
>>> that the data buffer passed in must be bigger than is 'apparently' used
>>> in the code calling this. I'm not sure what the right answer is though.
>>
>> Well it's not that hidden, it is clearly documented that the function is
>> going to store the timestamp in the buffer.
> But who reads the docs? :)
Hopefully everybody ;)
>> My first idea was to make
>> storing timestamp a separate function. E.g. like
>>
>> iio_store_timestamp(indio_dev, buf, ts);
>> iio_push_to_buffers(indio_dev, buf);
> That was my first thought as well.
>>
>> This makes it a bit more explicit that the buffer needs to be large enough
>> to hold the timestamp. But since that function would always be followed by
>> iio_push_to_buffers() I choose to add a function that does both, store the
>> timestamp and push the buffer out.
> Hmm. I'm more or less convinced though I think moving the buffer allocation
> into the core (or nearly the core) would be a good way of avoiding any
> confusion in the long run.
Things will go bad anyway if your buffer is smaller than scan_bytes as
iio_push_to_buffers expects this.
We could do something like this, but it is rather ugly:
#define iio_push_to_buffers(indio_dev, buffer) \
({ \
BUG_ON(sizeof(buffer) > sizeof(void*) && \
sizeof(buffer) < indio_dev->scan_bytes); \
iio_push_to_buffers(indio_dev, buffers); \
})
- Lars
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2013-09-16 20:42 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-15 16:50 [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers() Lars-Peter Clausen
2013-09-15 18:05 ` Jonathan Cameron
2013-09-15 16:50 ` [PATCH 03/27] staging:iio: " Lars-Peter Clausen
2013-09-15 18:06 ` Jonathan Cameron
2013-09-15 16:50 ` [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper Lars-Peter Clausen
2013-09-15 17:44 ` Peter Meerwald
2013-09-16 7:52 ` Jonathan Cameron
2013-09-16 7:58 ` Peter Meerwald
2013-09-16 8:19 ` Lars-Peter Clausen
2013-09-16 18:35 ` Jonathan Cameron
2013-09-16 8:19 ` Lars-Peter Clausen
2013-09-16 18:37 ` Jonathan Cameron
2013-09-16 20:42 ` Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 05/27] iio:bma180: Use iio_push_buffers_with_timestamp() Lars-Peter Clausen
2013-09-15 16:50 ` [PATCH 06/27] iio:ad7266: Use iio_push_to_buffers_with_timestamp() Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 07/27] iio:ad7298: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 08/27] iio:ad7476: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 09/27] iio:ad7887: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 10/27] iio:ad7923: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 11/27] iio:ad_sigma_delta: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 12/27] iio:at91_adc: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 13/27] iio:max1363: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 14/27] iio:st_sensors: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 15/27] iio:itg3200: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 16/27] iio:adis16400: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 17/27] iio:adis_lib: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 18/27] iio:mpu6050: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 19/27] iio:adjd_s311: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 20/27] iio:tcs3472: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 21/27] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 22/27] staging:iio:lis3l02dq: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 23/27] staging:iio:ad7606: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 24/27] staging:iio:ad799x: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 25/27] staging:iio:mxs-lradc: " Lars-Peter Clausen
2013-09-16 13:53 ` Marek Vasut
2013-09-16 16:54 ` Lars-Peter Clausen
2013-09-16 17:08 ` Marek Vasut
2013-09-15 16:51 ` [PATCH 26/27] staging:iio:dummy: " Lars-Peter Clausen
2013-09-15 16:51 ` [PATCH 27/27] staging:iio:ade7758: " Lars-Peter Clausen
2013-09-15 18:04 ` [PATCH 01/27] iio: iio_push_to_buffers(): Change type of 'data' to const void * 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).