Skip to content

Commit

Permalink
staging:iio: Add support for multiple buffers
Browse files Browse the repository at this point in the history
Route all buffer writes through the demux.
Addition or removal of a buffer results in tear down and
setup of all the buffers for a given device.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
  • Loading branch information
Jonathan Cameron committed Nov 10, 2012
1 parent 4eb3ccf commit 84b36ce
Show file tree
Hide file tree
Showing 30 changed files with 313 additions and 210 deletions.
15 changes: 1 addition & 14 deletions drivers/iio/accel/hid-sensor-accel-3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,8 @@ 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)
{
struct iio_buffer *buffer = indio_dev->buffer;
int datum_sz;

dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
if (!buffer) {
dev_err(&indio_dev->dev, "Buffer == NULL\n");
return;
}
datum_sz = buffer->access->get_bytes_per_datum(buffer);
if (len > datum_sz) {
dev_err(&indio_dev->dev, "Datum size mismatch %d:%d\n", len,
datum_sz);
return;
}
iio_push_to_buffer(buffer, (u8 *)data);
iio_push_to_buffers(indio_dev, (u8 *)data);
}

/* Callback handler to send event after all samples are received and captured */
Expand Down
3 changes: 1 addition & 2 deletions drivers/iio/adc/ad7266.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->indio_dev;
struct iio_buffer *buffer = indio_dev->buffer;
struct ad7266_state *st = iio_priv(indio_dev);
int ret;

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_buffer(buffer, (u8 *)st->data);
iio_push_to_buffers(indio_dev, (u8 *)st->data);
}

iio_trigger_notify_done(indio_dev->trig);
Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/adc/ad7476.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
if (indio_dev->scan_timestamp)
((s64 *)st->data)[1] = time_ns;

iio_push_to_buffer(indio_dev->buffer, st->data);
iio_push_to_buffers(indio_dev, st->data);
done:
iio_trigger_notify_done(indio_dev->trig);

Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/adc/ad7887.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
memcpy(st->data + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));

iio_push_to_buffer(indio_dev->buffer, st->data);
iio_push_to_buffers(indio_dev, st->data);
done:
iio_trigger_notify_done(indio_dev->trig);

Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/adc/ad_sigma_delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
break;
}

iio_push_to_buffer(indio_dev->buffer, (uint8_t *)data);
iio_push_to_buffers(indio_dev, (uint8_t *)data);

iio_trigger_notify_done(indio_dev->trig);
sigma_delta->irq_dis = false;
Expand Down
3 changes: 1 addition & 2 deletions drivers/iio/adc/at91_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
struct iio_poll_func *pf = p;
struct iio_dev *idev = pf->indio_dev;
struct at91_adc_state *st = iio_priv(idev);
struct iio_buffer *buffer = idev->buffer;
int i, j = 0;

for (i = 0; i < idev->masklength; i++) {
Expand All @@ -81,7 +80,7 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
*timestamp = pf->timestamp;
}

iio_push_to_buffer(buffer, st->buffer);
iio_push_to_buffers(indio_dev, (u8 *)st->buffer);

iio_trigger_notify_done(idev->trig);

Expand Down
15 changes: 1 addition & 14 deletions drivers/iio/gyro/hid-sensor-gyro-3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,8 @@ 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)
{
struct iio_buffer *buffer = indio_dev->buffer;
int datum_sz;

dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
if (!buffer) {
dev_err(&indio_dev->dev, "Buffer == NULL\n");
return;
}
datum_sz = buffer->access->get_bytes_per_datum(buffer);
if (len > datum_sz) {
dev_err(&indio_dev->dev, "Datum size mismatch %d:%d\n", len,
datum_sz);
return;
}
iio_push_to_buffer(buffer, (u8 *)data);
iio_push_to_buffers(indio_dev, (u8 *)data);
}

/* Callback handler to send event after all samples are received and captured */
Expand Down
Loading

0 comments on commit 84b36ce

Please sign in to comment.