Private
Public Access
2
0

mraa.c: Fix path of iio device in sysfs

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-09-28 16:53:31 +01:00
parent d920d136ea
commit ba9ab4b384

View File

@@ -171,12 +171,14 @@ mraa_init()
for (i=0; i < num_iio_devices; i++) {
device = &plat->iio_devices[i];
device->num = i;
snprintf(filepath, 64, "/sys/bus/iio/devices/iio:device%d", i);
snprintf(filepath, 64, "/sys/bus/iio/devices/iio:device%d/name", i);
fd = open(filepath, O_RDONLY);
if (fd != -1) {
len = read(fd, &name, 64);
device->name = malloc((sizeof(char) * len) + sizeof(char));
strncpy(device->name, name, len);
if (len > 1) {
device->name = malloc((sizeof(char) * len) + sizeof(char));
strncpy(device->name, name, len);
}
}
}