From cfe0217ad3e89d59c4d7dff8f137740313760398 Mon Sep 17 00:00:00 2001 From: ZeekHuge Date: Tue, 2 Aug 2016 02:21:45 +0000 Subject: [PATCH] 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. --- driver/beaglescope_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/driver/beaglescope_driver.c b/driver/beaglescope_driver.c index dd66f4e..ba39782 100644 --- a/driver/beaglescope_driver.c +++ b/driver/beaglescope_driver.c @@ -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); @@ -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); } } }