From: Alex Tereschenko Date: Tue, 6 Oct 2015 21:14:08 +0000 (+0200) Subject: iio: fixed IIO device counting X-Git-Tag: v0.9.0~51 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fmraa.git;a=commitdiff_plain;h=7fa4990d81de3e49b074eb85c5d87824f1f1cb37 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 Signed-off-by: Brendan Le Foll --- diff --git a/src/mraa.c b/src/mraa.c index 8c26cf1..720a7cc 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -46,6 +46,7 @@ #include "version.h" #define MAX_PLATFORM_NAME_LENGTH 128 +#define IIO_DEVICE_WILDCARD "iio:device*" mraa_board_t* plat = NULL; mraa_iio_info_t* plat_iio = NULL; @@ -75,10 +76,9 @@ mraa_set_log_level(int level) static int mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb) { - switch (sb->st_mode & S_IFMT) { - case S_IFLNK: - num_iio_devices++; - break; + // we are only interested in files with specific names + if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) { + num_iio_devices++; } return 0; }