Skip to content

Commit cfe0217

Browse files
committed
Modify and improve the beaglescope_driver_cb() callback implementation
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.
1 parent 8f6efca commit cfe0217

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

driver/beaglescope_driver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
336336
{
337337
struct beaglescope_state *st;
338338
struct iio_dev *indio_dev;
339+
u16 *dataw = data;
339340
int count;
340341

341342
indio_dev = dev_get_drvdata(&rpdev->dev);
@@ -347,8 +348,8 @@ static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
347348
st->got_raw = 1;
348349
wake_up_interruptible(&st->wait_list);
349350
}else{
350-
for (count =0; count < len; count++) {
351-
iio_push_to_buffers(indio_dev, &((u8 *)data)[count]);
351+
for (count =0; count < len/2; count++) {
352+
iio_push_to_buffers(indio_dev, dataw + count);
352353
}
353354
}
354355
}

0 commit comments

Comments
 (0)