* Optional correction scale read from a property such as iio.accel.x.scale, allowing late compensation of
* problems such as misconfigured axes ; set to 1 by default. Applied at the end of the scaling process.
*/
+ int raw_path_present; /* Flag signalling the presence of in_<sens>_<axis>_raw file */
+ int input_path_present; /* Flag signalling the presence of in_<sens>_input file */
}
channel_info_t;
for (c = 1; c < num_channels; c++)
sensor[s].channel[c].opt_scale = 1;
+ for (c = 0; c < num_channels; c++) {
+ /* Check the presence of the channel's input_path */
+ sprintf(sysfs_path, BASE_PATH "%s", dev_num,
+ sensor_catalog[catalog_index].channel[c].input_path);
+ sensor[s].channel[c].input_path_present = (access(sysfs_path, R_OK) != -1);
+ /* Check the presence of the channel's raw_path */
+ sprintf(sysfs_path, BASE_PATH "%s", dev_num,
+ sensor_catalog[catalog_index].channel[c].raw_path);
+ sensor[s].channel[c].raw_path_present = (access(sysfs_path, R_OK) != -1);
+ }
+
/* Read ACPI _PLD attributes for this sensor, if there are any */
decode_placement_information(dev_num, num_channels, s);
/* Acquire a sample value for sensor s / channel c through sysfs */
- if (input_path[0]) {
+ if (sensor[s].channel[c].input_path_present) {
sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
ret = sysfs_read_float(sysfs_path, &val);
if (!ret)
return val * correction;
- };
+ }
- if (!raw_path[0])
+ if (!sensor[s].channel[c].raw_path_present)
return 0;
sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);
/* Acquire a sample value for sensor s / channel c through sysfs */
- if (input_path[0]) {
+ if (sensor[s].channel[c].input_path_present) {
sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
ret = sysfs_read_uint64(sysfs_path, &val);
return val * correction;
};
- if (!raw_path[0])
+ if (!sensor[s].channel[c].raw_path_present)
return 0;
sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);