Paul Cercueil / libiio

Dependencies:   libserialport libxml2

Files at this revision

API Documentation at this revision

Comitter:
pcercuei
Date:
Mon Jun 26 14:30:10 2017 +0000
Parent:
3:d147beabba0e
Commit message:
Update to upstream version v0.10

Changed in this revision

channel.c Show annotated file Show diff for this revision Revisions of this file
context.c Show annotated file Show diff for this revision Revisions of this file
debug.h Show annotated file Show diff for this revision Revisions of this file
device.c Show annotated file Show diff for this revision Revisions of this file
iio-config.h Show annotated file Show diff for this revision Revisions of this file
iio-private.h Show annotated file Show diff for this revision Revisions of this file
utilities.c Show annotated file Show diff for this revision Revisions of this file
--- a/channel.c	Mon Jan 30 13:00:39 2017 +0000
+++ b/channel.c	Mon Jun 26 14:30:10 2017 +0000
@@ -395,19 +395,19 @@
 bool iio_channel_is_enabled(const struct iio_channel *chn)
 {
 	return chn->index >= 0 && chn->dev->mask &&
-		TEST_BIT(chn->dev->mask, chn->index);
+		TEST_BIT(chn->dev->mask, chn->number);
 }
 
 void iio_channel_enable(struct iio_channel *chn)
 {
 	if (chn->is_scan_element && chn->index >= 0 && chn->dev->mask)
-		SET_BIT(chn->dev->mask, chn->index);
+		SET_BIT(chn->dev->mask, chn->number);
 }
 
 void iio_channel_disable(struct iio_channel *chn)
 {
 	if (chn->index >= 0 && chn->dev->mask)
-		CLEAR_BIT(chn->dev->mask, chn->index);
+		CLEAR_BIT(chn->dev->mask, chn->number);
 }
 
 void free_channel(struct iio_channel *chn)
--- a/context.c	Mon Jan 30 13:00:39 2017 +0000
+++ b/context.c	Mon Jun 26 14:30:10 2017 +0000
@@ -71,7 +71,7 @@
 			return NULL;
 		}
 
-		devices = malloc(ctx->nb_devices * sizeof(*devices));
+		devices = calloc(ctx->nb_devices, sizeof(*devices));
 		if (!devices)
 			goto err_free_devices_len;
 
@@ -119,7 +119,7 @@
 	return str;
 
 err_free_devices:
-	while (i--)
+	for (i = 0; i < ctx->nb_devices; i++)
 		free(devices[i]);
 	free(devices);
 err_free_devices_len:
@@ -223,6 +223,9 @@
 			}
 		}
 	} while (found);
+
+	for (i = 0; i < dev->nb_channels; i++)
+		dev->channels[i]->number = i;
 }
 
 int iio_context_init(struct iio_context *ctx)
--- a/debug.h	Mon Jan 30 13:00:39 2017 +0000
+++ b/debug.h	Mon Jun 26 14:30:10 2017 +0000
@@ -33,7 +33,7 @@
 
 #ifdef WITH_COLOR_DEBUG
 #ifndef COLOR_DEBUG
-#define COLOR_DEBUG   "\e[0;34m"
+#define COLOR_DEBUG   "\e[0;32m"
 #endif
 #ifndef COLOR_WARNING
 #define COLOR_WARNING "\e[01;35m"
--- a/device.c	Mon Jan 30 13:00:39 2017 +0000
+++ b/device.c	Mon Jun 26 14:30:10 2017 +0000
@@ -427,6 +427,7 @@
 {
 	ssize_t size = 0;
 	unsigned int i;
+	const struct iio_channel *prev = NULL;
 
 	if (words != (dev->nb_channels + 31) / 32)
 		return -EINVAL;
@@ -438,15 +439,20 @@
 
 		if (chn->index < 0)
 			break;
-		if (!TEST_BIT(mask, chn->index))
+		if (!TEST_BIT(mask, chn->number))
 			continue;
-		if (i > 0 && chn->index == dev->channels[i - 1]->index)
+
+		if (prev && chn->index == prev->index) {
+			prev = chn;
 			continue;
+		}
 
 		if (size % length)
 			size += 2 * length - (size % length);
 		else
 			size += length;
+
+		prev = chn;
 	}
 	return size;
 }
--- a/iio-config.h	Mon Jan 30 13:00:39 2017 +0000
+++ b/iio-config.h	Mon Jun 26 14:30:10 2017 +0000
@@ -4,8 +4,8 @@
 #include "iio-errno.h"
 
 #define LIBIIO_VERSION_MAJOR	0
-#define LIBIIO_VERSION_MINOR	9
-#define LIBIIO_VERSION_GIT	"v0.9"
+#define LIBIIO_VERSION_MINOR	10
+#define LIBIIO_VERSION_GIT	"v0.10"
 
 #define LOG_LEVEL Info_L
 
--- a/iio-private.h	Mon Jan 30 13:00:39 2017 +0000
+++ b/iio-private.h	Mon Jun 26 14:30:10 2017 +0000
@@ -173,6 +173,8 @@
 
 	struct iio_channel_attr *attrs;
 	unsigned int nb_attrs;
+
+	unsigned int number;
 };
 
 struct iio_device {
--- a/utilities.c	Mon Jan 30 13:00:39 2017 +0000
+++ b/utilities.c	Mon Jun 26 14:30:10 2017 +0000
@@ -34,7 +34,7 @@
 #endif
 
 #ifdef LOCALE_SUPPORT
-#if defined(__MINGW32__)
+#if defined(__MINGW32__) || (!defined(_WIN32) && !defined(HAS_NEWLOCALE))
 static int read_double_locale(const char *str, double *val)
 {
 	char *end, *old_locale;