iio: iio_push_to_buffers(): Change type of 'data' to const void *
Subsystems (10)
PATCH 1/27 iio: iio_push_to_buffers(): Change type of 'data' to const void *
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.
--- 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(-)
drivers/iio/buffer_cb.c +3 -3
@@ -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) {
drivers/iio/industrialio-buffer.c +5 -5
@@ -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;
drivers/iio/kfifo_buf.c +1 -1
@@ -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);
include/linux/iio/buffer.h +3 -3
@@ -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);
include/linux/iio/consumer.h +1 -1
@@ -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);/**
Signature · 1 line
1.8.0
PATCH 2/27 iio: Remove unnecessary casts for iio_push_to_buffers()
Now that iio_push_to_buffers() takes a void pointer for the data parameter we can remove those casts to u8*.
--- 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(-)
drivers/iio/accel/bma180.c +1 -1
@@ -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);
drivers/iio/accel/hid-sensor-accel-3d.c +4 -3
@@ -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 ;
drivers/iio/adc/ad7266.c +1 -1
@@ -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);
drivers/iio/adc/ad7298.c +1 -1
@@ -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);
drivers/iio/adc/ad7923.c +1 -1
@@ -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);
drivers/iio/adc/ad_sigma_delta.c +1 -1
@@ -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;
drivers/iio/adc/at91_adc.c +1 -1
@@ -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);
drivers/iio/gyro/hid-sensor-gyro-3d.c +4 -3
@@ -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 ;
drivers/iio/gyro/itg3200_buffer.c +1 -1
@@ -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:
drivers/iio/light/adjd_s311.c +1 -1
@@ -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);
drivers/iio/light/hid-sensor-als.c +4 -3
@@ -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 ;
drivers/iio/light/tcs3472.c +1 -1
@@ -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);
drivers/iio/magnetometer/hid-sensor-magn-3d.c +4 -3
@@ -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 ;
Signature · 1 line
1.8.0
Re: [PATCH 02/27] iio: Remove unnecessary casts for iio_push_to_buffers()
Quoted 4 lines · 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 <[email protected]>
applied.
Quoted 242 lines
--- 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(-)drivers/iio/accel/bma180.c +1
-1@@ -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);drivers/iio/accel/hid-sensor-accel-3d.c +4
-3@@ -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 ;drivers/iio/adc/ad7266.c +1
-1@@ -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);drivers/iio/adc/ad7298.c +1
-1@@ -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);drivers/iio/adc/ad7923.c +1
-1@@ -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);drivers/iio/adc/ad_sigma_delta.c +1
-1@@ -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;drivers/iio/adc/at91_adc.c +1
-1@@ -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);drivers/iio/gyro/hid-sensor-gyro-3d.c +4
-3@@ -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 ;drivers/iio/gyro/itg3200_buffer.c +1
-1@@ -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:drivers/iio/light/adjd_s311.c +1
-1@@ -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);drivers/iio/light/hid-sensor-als.c +4
-3@@ -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 ;drivers/iio/light/tcs3472.c +1
-1@@ -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);drivers/iio/magnetometer/hid-sensor-magn-3d.c +4
-3@@ -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 ;
PATCH 3/27 staging:iio: Remove unnecessary casts for iio_push_to_buffers()
In reply to Lars-Peter ClausenNow that iio_push_to_buffers() takes a void pointer for the data parameter we can remove those casts to u8*.
--- 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(-)
drivers/staging/iio/accel/lis3l02dq_ring.c +1 -1
@@ -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:
drivers/staging/iio/adc/mxs-lradc.c +1 -1
@@ -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);
drivers/staging/iio/iio_simple_dummy_buffer.c +1 -1
@@ -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);
drivers/staging/iio/impedance-analyzer/ad5933.c +1 -1
@@ -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);
drivers/staging/iio/meter/ade7758_ring.c +1 -1
@@ -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);
Signature · 1 line
1.8.0
Re: [PATCH 03/27] staging:iio: Remove unnecessary casts for iio_push_to_buffers()
Quoted 4 lines · 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 <[email protected]>
Applied to the togreg branch of iio.git
Thanks. I'll get to the rest of series another time.
Quoted 74 lines
--- 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(-)drivers/staging/iio/accel/lis3l02dq_ring.c +1
-1@@ -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:drivers/staging/iio/adc/mxs-lradc.c +1
-1@@ -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);drivers/staging/iio/iio_simple_dummy_buffer.c +1
-1@@ -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);drivers/staging/iio/impedance-analyzer/ad5933.c +1
-1@@ -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);drivers/staging/iio/meter/ade7758_ring.c +1
-1@@ -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);
PATCH 4/27 iio: Add iio_push_buffers_with_timestamp() helper
In reply to Lars-Peter ClausenDrivers 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().
--- include/linux/iio/buffer.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
include/linux/iio/buffer.h +26 -1
@@ -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);/**
Signature · 1 line
1.8.0
Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
I like!
Quoted 3 lines
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 disablediio_push_buffers_with_timestamp()will behave just likeiio_push_buffers().
computation of the buffer size is the remaining piece of ugliness; indio_dev->scan_bytes in not available at probe time
Quoted 8 lines
Signed-off-by Lars-Peter Clausen <[email protected]>Cc Oleksandr Kravchenko <[email protected]>Cc Josh Wu <[email protected]>Cc Denis Ciocca <[email protected]>Cc Manuel Stahl <[email protected]>Cc Ge Gao <[email protected]>Cc Peter Meerwald <[email protected]>Cc Peter Meerwald <[email protected]>
twice, so honoured :)
nitpick below
include/linux/iio/buffer.h int iio_scan_mask_set(struct iio_dev *indio_dev, · line 119
Quoted 10 lines
include/linux/iio/buffer.h +1
-1@@ -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
Quoted 34 lines
include/linux/iio/buffer.h +25
-0* @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);/**
Signature · 2 lines
Peter Meerwald +43-664-2444418 (mobile)
Jonathan Cameron
maintainerRe: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
In reply to Lars-Peter ClausenQuoted 12 lines · Lars-Peter Clausen
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 callediio_push_buffers_with_timestamp()which is similar toiio_push_to_buffersbut 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 deviceiio_push_buffers_with_timestamp()will store the timestamp as the last element in buffer, before passing the buffer on toiio_push_buffers(). The buffer needs large enough to hold the timestamp in this case. If timestamps are disablediio_push_buffers_with_timestamp()will behave just likeiio_push_buffers().
Quoted 11 lines
Signed-off-by Lars-Peter Clausen <[email protected]>Cc Oleksandr Kravchenko <[email protected]>Cc Josh Wu <[email protected]>Cc Denis Ciocca <[email protected]>Cc Manuel Stahl <[email protected]>Cc Ge Gao <[email protected]>Cc Peter Meerwald <[email protected]>Cc Peter Meerwald <[email protected]>Cc Jacek Anaszewski <[email protected]>Cc Fabio Estevam <[email protected]>Cc Marek Vasut <[email protected]>
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.
Quoted 48 lines
--- include/linux/iio/buffer.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)include/linux/iio/buffer.h +26
-1@@ -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);/**
Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
Quoted 5 lines
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.
Signature · 2 lines
Peter Meerwald +43-664-2444418 (mobile)
Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
Quoted 8 lines · Peter Meerwald
Quoted 5 lines
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
Jonathan Cameron
maintainerRe: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
Quoted 7 lines · Lars-Peter Clausen
Quoted 6 lines · Peter Meerwald
Quoted 5 lines
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.
Quoted 8 lines
Quoted 2 lines
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 theirupdate_scan_modecallback. Maybe we can add atransfer_bufferfield to theiio_devstruct and have a function that can be used as a defaultupdate_scan_modecallback 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
Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
In reply to Jonathan CameronOn 09/16/2013 09:52 AM, Jonathan Cameron wrote:
[...]
Quoted 4 lines
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
Jonathan Cameron
maintainerRe: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
Quoted 9 lines · Lars-Peter Clausen
On 09/16/2013 09:52 AM, Jonathan Cameron wrote:
[...]Quoted 4 lines
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? :)
Quoted 5 lines
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.
Quoted 5 lines
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.
Quoted 7 lines
- Las
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/27] iio: Add iio_push_buffers_with_timestamp() helper
Quoted 11 lines · Jonathan Cameron
Quoted 9 lines · Lars-Peter Clausen
On 09/16/2013 09:52 AM, Jonathan Cameron wrote:
[...]Quoted 4 lines
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 ;)
Quoted 7 lines
Quoted 5 lines
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.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
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
PATCH 5/27 iio:bma180: Use iio_push_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code shorter and a bit less ugly.
--- drivers/iio/accel/bma180.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/accel/bma180.c +2 -5
@@ -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);
Signature · 1 line
1.8.0
PATCH 6/27 iio:ad7266: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad7266.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/adc/ad7266.c +2 -3
@@ -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);
Signature · 1 line
1.8.0
PATCH 7/27 iio:ad7298: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad7298.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/ad7298.c +2 -8
@@ -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);
Signature · 1 line
1.8.0
PATCH 8/27 iio:ad7476: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad7476.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iio/adc/ad7476.c +2 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 9/27 iio:ad7887: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad7887.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/ad7887.c +2 -8
@@ -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);
Signature · 1 line
1.8.0
PATCH 10/27 iio:ad7923: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad7923.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/ad7923.c +2 -8
@@ -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);
Signature · 1 line
1.8.0
PATCH 11/27 iio:ad_sigma_delta: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/ad_sigma_delta.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/iio/adc/ad_sigma_delta.c +1 -5
@@ -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;
Signature · 1 line
1.8.0
PATCH 12/27 iio:at91_adc: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/at91_adc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/iio/adc/at91_adc.c +1 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 13/27 iio:max1363: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/adc/max1363.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/iio/adc/max1363.c +1 -6
@@ -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);
Signature · 1 line
1.8.0
PATCH 14/27 iio:st_sensors: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/common/st_sensors/st_sensors_buffer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/common/st_sensors/st_sensors_buffer.c +2 -5
@@ -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);
Signature · 1 line
1.8.0
PATCH 15/27 iio:itg3200: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/gyro/itg3200_buffer.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/gyro/itg3200_buffer.c +1 -4
@@ -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:
Signature · 1 line
1.8.0
PATCH 16/27 iio:adis16400: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/imu/adis16400_buffer.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iio/imu/adis16400_buffer.c +2 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 17/27 iio:adis_lib: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/imu/adis_buffer.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iio/imu/adis_buffer.c +2 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 18/27 iio:mpu6050: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -4
@@ -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;
Signature · 1 line
1.8.0
PATCH 19/27 iio:adjd_s311: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/light/adjd_s311.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/light/adjd_s311.c +1 -4
@@ -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);
Signature · 1 line
1.8.0
PATCH 20/27 iio:tcs3472: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/light/tcs3472.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/light/tcs3472.c +2 -4
@@ -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);
Signature · 1 line
1.8.0
PATCH 21/27 iio:gp2ap020a00f: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/iio/light/gp2ap020a00f.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iio/light/gp2ap020a00f.c +2 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 22/27 staging:iio:lis3l02dq: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/iio/accel/lis3l02dq_ring.c +1 -5
@@ -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:
Signature · 1 line
1.8.0
PATCH 23/27 staging:iio:ad7606: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/adc/ad7606_ring.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/staging/iio/adc/ad7606_ring.c +1 -7
@@ -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);
Signature · 1 line
1.8.0
PATCH 24/27 staging:iio:ad799x: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/adc/ad799x_ring.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/staging/iio/adc/ad799x_ring.c +2 -8
@@ -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);
Signature · 1 line
1.8.0
PATCH 25/27 staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/adc/mxs-lradc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +1 -7
@@ -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);
Signature · 1 line
1.8.0
Re: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
Dear Lars-Peter Clausen,
Quoted 17 lines
Makes the code a bit shorter and less ugly.
Signed-off-by Lars-Peter Clausen <[email protected]>Cc Fabio Estevam <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/staging/iio/adc/mxs-lradc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/staging/iio/adc/mxs-lradc.cindex 7401230..9da64bf 100644drivers/staging/iio/adc/mxs-lradc.c +0
-0@@ -625,13 +625,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) j++; }
drivers/staging/iio/adc/mxs-lradc.c static irqreturn_t mxs_lradc_trigger_handler(int irq, · line 630
Quoted 10 lines
drivers/staging/iio/adc/mxs-lradc.c +1
-7-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
Re: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
Quoted 28 lines · Marek Vasut
Dear Lars-Peter Clausen,
Quoted 26 lines
Makes the code a bit shorter and less ugly.
Signed-off-by Lars-Peter Clausen <[email protected]>Cc Fabio Estevam <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/staging/iio/adc/mxs-lradc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/staging/iio/adc/mxs-lradc.cindex 7401230..9da64bf 100644drivers/staging/iio/adc/mxs-lradc.c +1
-7@@ -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);
Quoted 4 lines
drivers/staging/iio/adc/mxs-lradc.c static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) · line 630
Quoted 1 line
drivers/staging/iio/adc/mxs-lradc.c +0
-0iio_trigger_notify_done (iio->trig);Indeed, this stuff was duplicated all around.
Is that a acked-by? :)
- Lars
Marek Vasut
Reviewed-byRe: [PATCH 25/27] staging:iio:mxs-lradc: Use iio_push_to_buffers_with_timestamp()
Dear Lars-Peter Clausen,
Quoted 31 lines · Marek Vasut
Quoted 30 lines
Dear Lars-Peter Clausen,
Quoted 28 lines
Makes the code a bit shorter and less ugly.
Signed-off-by Lars-Peter Clausen <[email protected]>Cc Fabio Estevam <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/staging/iio/adc/mxs-lradc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/staging/iio/adc/mxs-lradc.cindex 7401230..9da64bf 100644drivers/staging/iio/adc/mxs-lradc.c +1
-7@@ -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);
Quoted 5 lines
Quoted 3 lines
drivers/staging/iio/adc/mxs-lradc.c static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) · line 630
Quoted 1 line
drivers/staging/iio/adc/mxs-lradc.c +0
-0iio_trigger_notify_done (iio->trig);Indeed, this stuff was duplicated all around.
Is that a acked-by? :)
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
PATCH 26/27 staging:iio:dummy: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/iio_simple_dummy_buffer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/iio/iio_simple_dummy_buffer.c +2 -5
@@ -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);
Signature · 1 line
1.8.0
PATCH 27/27 staging:iio:ade7758: Use iio_push_to_buffers_with_timestamp()
In reply to Lars-Peter ClausenMakes the code a bit shorter and less ugly.
--- drivers/staging/iio/meter/ade7758_ring.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/iio/meter/ade7758_ring.c +1 -5
@@ -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);
Signature · 1 line
1.8.0
Quoted 10 lines · 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 toiio_push_to_buffers()it needs to be cast to 'u8 *' for the compiler to not complain (and also having to add__forceif 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 <[email protected]>
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,
Quoted 130 lines
--- 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(-)drivers/iio/buffer_cb.c +3
-3@@ -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) {drivers/iio/industrialio-buffer.c +5
-5@@ -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;drivers/iio/kfifo_buf.c +1
-1@@ -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);include/linux/iio/buffer.h +3
-3@@ -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);include/linux/iio/consumer.h +1
-1@@ -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);/**