Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: common: ssp_sensors: drop conditional optimization for simplicity

Drop conditional in favor of always calculating the timestamp value.
This simplifies the code and allows to drop usage of internal private
variable "scan_timestamp" of the struct iio_dev.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241214191421.94172-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Vasileios Amoiridis and committed by
Jonathan Cameron
6d0981f9 45e3146d

+5 -7
+5 -7
drivers/iio/common/ssp_sensors/ssp_iio.c
··· 8 8 #include <linux/iio/kfifo_buf.h> 9 9 #include <linux/module.h> 10 10 #include <linux/slab.h> 11 + #include <linux/unaligned.h> 12 + #include <linux/units.h> 11 13 #include "ssp_iio_sensor.h" 12 14 13 15 /** ··· 72 70 int ssp_common_process_data(struct iio_dev *indio_dev, void *buf, 73 71 unsigned int len, int64_t timestamp) 74 72 { 75 - __le32 time; 76 - int64_t calculated_time = 0; 73 + int64_t calculated_time; 77 74 struct ssp_sensor_data *spd = iio_priv(indio_dev); 78 75 79 76 if (indio_dev->scan_bytes == 0) ··· 83 82 */ 84 83 memcpy(spd->buffer, buf, len); 85 84 86 - if (indio_dev->scan_timestamp) { 87 - memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE); 88 - calculated_time = 89 - timestamp + (int64_t)le32_to_cpu(time) * 1000000; 90 - } 85 + calculated_time = timestamp + 86 + (int64_t)get_unaligned_le32(buf + len) * MEGA; 91 87 92 88 return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer, 93 89 calculated_time);