#include <linux/iio/kfifo_buf.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/unaligned.h>
+#include <linux/units.h>
#include "ssp_iio_sensor.h"
/**
int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
unsigned int len, int64_t timestamp)
{
- __le32 time;
- int64_t calculated_time = 0;
+ int64_t calculated_time;
struct ssp_sensor_data *spd = iio_priv(indio_dev);
if (indio_dev->scan_bytes == 0)
*/
memcpy(spd->buffer, buf, len);
- if (indio_dev->scan_timestamp) {
- memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE);
- calculated_time =
- timestamp + (int64_t)le32_to_cpu(time) * 1000000;
- }
+ calculated_time = timestamp +
+ (int64_t)get_unaligned_le32(buf + len) * MEGA;
return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer,
calculated_time);