iio: fixed IIO device counting
We now take into account only "iio:device*" files to filter out fake devices like triggers. Closes #299. Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
3b55cc70bf
commit
7fa4990d81
@@ -46,6 +46,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#define MAX_PLATFORM_NAME_LENGTH 128
|
#define MAX_PLATFORM_NAME_LENGTH 128
|
||||||
|
#define IIO_DEVICE_WILDCARD "iio:device*"
|
||||||
mraa_board_t* plat = NULL;
|
mraa_board_t* plat = NULL;
|
||||||
mraa_iio_info_t* plat_iio = NULL;
|
mraa_iio_info_t* plat_iio = NULL;
|
||||||
|
|
||||||
@@ -75,10 +76,9 @@ mraa_set_log_level(int level)
|
|||||||
static int
|
static int
|
||||||
mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb)
|
mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb)
|
||||||
{
|
{
|
||||||
switch (sb->st_mode & S_IFMT) {
|
// we are only interested in files with specific names
|
||||||
case S_IFLNK:
|
if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) {
|
||||||
num_iio_devices++;
|
num_iio_devices++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user