Skip to content

Commit

Permalink
Modify and improve the beaglescope_driver_cb() callback implementation
Browse files Browse the repository at this point in the history
The beaglescope_driver_cb() is actually associated with the rpmsg
device created by this driver and is used to dispatch the data to
the right place as soon as it arrives.

The data that arrives, about 440 bytes, needs to be pushed to the
iio buffer. But IIO only has APIs to push one data reading into the
buffer, at one time, and therefore a loop in the
beaglescope_driver_cb() was used to transfer the 440 bytes of data to
the iio buffer.

Now,
Each data reading that is transfered to the buffer has some
characteristics that are defined in the '.scan_types' field of the
iio_chan_spec data structure. For this driver, the one of the
characteristics defined is that the data will be 16 bit long.

In the earlier implementations of the beaglescope_driver_cb() the data
transfer from rpmsg given buffer to the iio buffer was being done
badly, as it was being transfered using a pointer to u8 data type.
It was bad because the scan_types specify the data to be 16 bit wide
and therefore should have used a pointer to u16 data type. This was
somehow the reason behind #2

It was also the reason why the use of pru_rpmsg_send_large_buffer()
was not working at first while testing the setup.

This commit modifies and improves the implementation of
beaglescope_driver_cb() by using a pointer to u16 to transfer data
from rpmsg given buffer, to the iio buffer.
This thus also resolves #2.
  • Loading branch information
zeekhuge committed Aug 2, 2016
1 parent 8f6efca commit cfe0217
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions driver/beaglescope_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
{
struct beaglescope_state *st;
struct iio_dev *indio_dev;
u16 *dataw = data;
int count;

indio_dev = dev_get_drvdata(&rpdev->dev);
Expand All @@ -347,8 +348,8 @@ static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
st->got_raw = 1;
wake_up_interruptible(&st->wait_list);
}else{
for (count =0; count < len; count++) {
iio_push_to_buffers(indio_dev, &((u8 *)data)[count]);
for (count =0; count < len/2; count++) {
iio_push_to_buffers(indio_dev, dataw + count);
}
}
}
Expand Down

0 comments on commit cfe0217

Please sign in to comment.