summaryrefslogtreecommitdiff
path: root/include/linux/iio/common
diff options
context:
space:
mode:
authorDenis Ciocca <denis.ciocca@st.com>2019-08-05 11:57:11 -0700
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-08-11 09:26:04 +0100
commite031d5f558f1535968df1ecae8d734b84c17f78d (patch)
tree663fb1b5ab579c6486d387e5dabe3ab747535e86 /include/linux/iio/common
parent854da7511a05c9a05a4f28fb2225349380520b96 (diff)
iio:st_sensors: remove buffer allocation at each buffer enable
This patch is removing the buffer allocation at each buffer enable. We just allocate enough memory in the main structure during probe to cover maximum size needed (that anyway is pretty small) [16bytes]. Signed-off-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'include/linux/iio/common')
-rw-r--r--include/linux/iio/common/st_sensors.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 4d0889bf1c6c..686be532f4cb 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -20,8 +20,12 @@
#include <linux/platform_data/st_sensors_pdata.h>
-#define ST_SENSORS_TX_MAX_LENGTH 2
-#define ST_SENSORS_RX_MAX_LENGTH 6
+/*
+ * Buffer size max case: 2bytes per channel, 3 channels in total +
+ * 8bytes timestamp channel (s64)
+ */
+#define ST_SENSORS_MAX_BUFFER_SIZE (ALIGN(2 * 3, sizeof(s64)) + \
+ sizeof(s64))
#define ST_SENSORS_ODR_LIST_MAX 10
#define ST_SENSORS_FULLSCALE_AVL_MAX 10
@@ -215,7 +219,6 @@ struct st_sensor_settings {
* @vdd_io: Pointer to sensor's Vdd-IO power supply
* @regmap: Pointer to specific sensor regmap configuration.
* @enabled: Status of the sensor (false->off, true->on).
- * @buffer_data: Data used by buffer part.
* @odr: Output data rate of the sensor [Hz].
* num_data_channels: Number of data channels used in buffer.
* @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2).
@@ -224,6 +227,7 @@ struct st_sensor_settings {
* @edge_irq: the IRQ triggers on edges and need special handling.
* @hw_irq_trigger: if we're using the hardware interrupt on the sensor.
* @hw_timestamp: Latest timestamp from the interrupt handler, when in use.
+ * @buffer_data: Data used by buffer part.
*/
struct st_sensor_data {
struct device *dev;
@@ -237,8 +241,6 @@ struct st_sensor_data {
bool enabled;
- char *buffer_data;
-
unsigned int odr;
unsigned int num_data_channels;
@@ -249,6 +251,8 @@ struct st_sensor_data {
bool edge_irq;
bool hw_irq_trigger;
s64 hw_timestamp;
+
+ char buffer_data[ST_SENSORS_MAX_BUFFER_SIZE] ____cacheline_aligned;
};
#ifdef CONFIG_IIO_BUFFER