iio: Always set the scale

When calling process_scan_1(), make sure to always set the scale to 1.0
so it always has a default value.
This commit is contained in:
Bastien Nocera
2018-10-06 10:43:36 +02:00
committed by hadess
parent af44746c96
commit d7725e8b3a
2 changed files with 4 additions and 5 deletions

View File

@@ -56,9 +56,7 @@ process_scan (IIOSensorData data, DrvData *or_data)
process_scan_1(data.data + or_data->buffer_data->scan_size*i, or_data->buffer_data, "in_intensity_both", &level, &scale, &present_level);
g_debug ("Light read from IIO on '%s': %d (scale %lf) = %lf", or_data->name, level, scale, level * scale);
readings.level = level;
if (scale)
readings.level *= scale;
readings.level = level * scale;
/* Even though the IIO kernel API declares in_intensity* values as unitless,
* we use Microsoft's hid-sensors-usages.docx which mentions that Windows 8

View File

@@ -533,6 +533,9 @@ process_scan_1 (char *data,
gboolean *ch_present)
{
int k;
*ch_scale = 1.0;
for (k = 0; k < buffer_data->channels_count; k++) {
if (strcmp (buffer_data->channels[k]->name, ch_name) != 0)
continue;
@@ -559,8 +562,6 @@ process_scan_1 (char *data,
*ch_val = (int) val;
if (buffer_data->channels[k]->scale)
*ch_scale = buffer_data->channels[k]->scale;
else
*ch_scale = 1.0;
*ch_present = TRUE;
}
break;