2 * Copyright (C) 2014-2015 Intel Corporation.
9 #include <hardware/sensors.h>
13 void discover_sensors(int dev_num, char *sysfs_base_path, char map[catalog_size],
14 void (*discover_sensor)(int, char*, char*))
16 char sysfs_dir[PATH_MAX];
21 memset(map, 0, catalog_size);
23 snprintf(sysfs_dir, sizeof(sysfs_dir), sysfs_base_path, dev_num);
25 dir = opendir(sysfs_dir);
30 /* Enumerate entries in this iio device's base folder */
32 while ((d = readdir(dir))) {
33 if (!strncmp(d->d_name, ".", sizeof(".")) || !strncmp(d->d_name, "..", sizeof("..")))
36 /* If the name matches a catalog entry, flag it */
37 for (i = 0; i < catalog_size; i++) {
39 /* No discovery for virtual sensors */
40 if (sensor_catalog[i].is_virtual)
42 discover_sensor(i, d->d_name, map);
49 void check_event_sensors(int i, char *sysfs_file, char map[catalog_size])
53 for (j = 0; j < sensor_catalog[i].num_channels; j++)
54 for (k = 0; k < sensor_catalog[i].channel[j].num_events; k++) {
55 if (!strcmp(sysfs_file, sensor_catalog[i].channel[j].event[k].ev_en_path)) {
62 void check_poll_sensors (int i, char *sysfs_file, char map[catalog_size])
66 for (c = 0; c < sensor_catalog[i].num_channels; c++)
67 if (!strcmp(sysfs_file, sensor_catalog[i].channel[c].raw_path) ||
68 !strcmp(sysfs_file, sensor_catalog[i].channel[c].input_path)) {
74 void check_trig_sensors (int i, char *sysfs_file, char map[catalog_size])
77 if (!strcmp(sysfs_file, sensor_catalog[i].channel[0].en_path)) {