summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaadi Maalem <saadi.maalem@intel.com>2015-06-04 16:42:27 +0800
committerZhengyin Qian <qianzy@google.com>2015-08-13 19:37:30 -0700
commit90158e87ed2bd35ff6e07a0eb6a281600d03a9f8 (patch)
tree88b4777b16b4bb3255699cc51588825f5dd9092b
parent5957f5fa2716264d227e493af657e13d24c0dae3 (diff)
downloadsensors-90158e87ed2bd35ff6e07a0eb6a281600d03a9f8.tar.gz
Sensor: Correct flush function for different types of sensors
JIRA: MARVIN-239 Fix bug in flush function for sensors: 1. for One-Shot sensor, return -EINVAL; 2. for sensors not using FIFO, return flush complete event; 3. for sensors using FIFO, flush data in FIFO. Change-Id: I3e35a9be39150d2ca2be0166b516a722df8fefda Signed-off-by: Fei Li <feix.f.li@intel.com> Reviewed-on: https://android.intel.com/376695 Reviewed-by: Pujol, Benjamin <benjamin.pujol@intel.com>
-rw-r--r--libsensors_iio/src/HWSensorBase.cpp14
-rw-r--r--libsensors_iio/src/SensorHAL.cpp4
2 files changed, 12 insertions, 6 deletions
diff --git a/libsensors_iio/src/HWSensorBase.cpp b/libsensors_iio/src/HWSensorBase.cpp
index ea7078b..24ed9f2 100644
--- a/libsensors_iio/src/HWSensorBase.cpp
+++ b/libsensors_iio/src/HWSensorBase.cpp
@@ -303,12 +303,14 @@ int HWSensorBase::FlushData()
{
int err;
- if (GetStatus() && (current_fifo_len > HW_SENSOR_BASE_DEFAULT_IIO_BUFFER_LEN)) {
- err = write_sysfs_int((char *)FILENAME_FLUSH, common_data.iio_sysfs_path, 1);
- if (err < 0) {
- ALOGE("%s: Failed to write flush file \"%s/%s\".",
- common_data.device_name, common_data.iio_sysfs_path, FILENAME_FLUSH);
- return -EINVAL;
+ if (GetStatus()) {
+ if (current_fifo_len > HW_SENSOR_BASE_DEFAULT_IIO_BUFFER_LEN) {
+ err = write_sysfs_int((char *)FILENAME_FLUSH, common_data.iio_sysfs_path, 1);
+ if (err < 0) {
+ ALOGE("%s: Failed to write flush file \"%s/%s\".",
+ common_data.device_name, common_data.iio_sysfs_path, FILENAME_FLUSH);
+ return -EINVAL;
+ }
}
} else
return -EINVAL;
diff --git a/libsensors_iio/src/SensorHAL.cpp b/libsensors_iio/src/SensorHAL.cpp
index e25771f..213cb85 100644
--- a/libsensors_iio/src/SensorHAL.cpp
+++ b/libsensors_iio/src/SensorHAL.cpp
@@ -584,6 +584,10 @@ st_hal_load_free_iio_sysfs_path:
static int st_hal_dev_flush(struct sensors_poll_device_1 *dev, int handle)
{
STSensorHAL_data *hal_data = (STSensorHAL_data *)dev;
+ ALOGD("st_hal_dev_flush type=%d", ((struct sensor_t) hal_data->sensor_t_list[handle]).type);
+ /* One-shot sensor must return -EINVAL and not generate any flush complete metadata event */
+ if (SENSOR_TYPE_SIGNIFICANT_MOTION == ((struct sensor_t) hal_data->sensor_t_list[handle]).type)
+ return -EINVAL;
return hal_data->sensor_classes[handle]->FlushData();
}