* [PATCH 0/2] Fixes ot the generic_buffer example
@ 2011-11-27 11:46 Jonathan Cameron
2011-11-27 11:46 ` [PATCH 1/2] staging:iio:Documentation: cleanup properly in buffer handling code Jonathan Cameron
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jonathan Cameron @ 2011-11-27 11:46 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
Hi All,
These do what they say on the tin.
Jonathan
Jonathan Cameron (2):
staging:iio:Documentation: cleanup properly in buffer handling code
staging:iio:generic_buffer example - handle endian differences
drivers/staging/iio/Documentation/generic_buffer.c | 8 ++++++
drivers/staging/iio/Documentation/iio_utils.h | 25 ++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
--
1.7.7.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] staging:iio:Documentation: cleanup properly in buffer handling code
2011-11-27 11:46 [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
@ 2011-11-27 11:46 ` Jonathan Cameron
2011-11-27 11:46 ` [PATCH 2/2] staging:iio:generic_buffer example - handle endian differences Jonathan Cameron
2011-12-04 19:11 ` [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2011-11-27 11:46 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
From: Jonathan Cameron <jic23@cam.ac.uk>
Eating the endian description for now.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/Documentation/iio_utils.h | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index dbbad8a..986889b 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -145,9 +145,17 @@ inline int iioutils_get_type(unsigned *is_signed,
ret = -errno;
goto error_free_filename;
}
- fscanf(sysfsfp,
- "%c%u/%u>>%u", &signchar, bits_used,
- &padint, shift);
+
+ ret = fscanf(sysfsfp,
+ "%ce:%c%u/%u>>%u",
+ &endianchar,
+ &signchar,
+ bits_used,
+ &padint, shift);
+ if (ret < 0) {
+ printf("failed to pass scan type description\n");
+ return ret;
+ }
*bytes = padint / 8;
if (*bits_used == 64)
*mask = ~0;
@@ -157,6 +165,10 @@ inline int iioutils_get_type(unsigned *is_signed,
*is_signed = 1;
else
*is_signed = 0;
+ fclose(sysfsfp);
+ free(filename);
+
+ filename = 0;
}
error_free_filename:
if (filename)
--
1.7.7.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] staging:iio:generic_buffer example - handle endian differences
2011-11-27 11:46 [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
2011-11-27 11:46 ` [PATCH 1/2] staging:iio:Documentation: cleanup properly in buffer handling code Jonathan Cameron
@ 2011-11-27 11:46 ` Jonathan Cameron
2011-12-04 19:11 ` [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2011-11-27 11:46 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
From: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/Documentation/generic_buffer.c | 8 ++++++++
drivers/staging/iio/Documentation/iio_utils.h | 7 ++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
index d580953..69a05b9 100644
--- a/drivers/staging/iio/Documentation/generic_buffer.c
+++ b/drivers/staging/iio/Documentation/generic_buffer.c
@@ -28,6 +28,7 @@
#include <linux/types.h>
#include <string.h>
#include <poll.h>
+#include <endian.h>
#include "iio_utils.h"
/**
@@ -56,6 +57,13 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
void print2byte(int input, struct iio_channel_info *info)
{
+ /* First swap if incorrect endian */
+
+ if (info->be)
+ input = be16toh((uint_16t)input);
+ else
+ input = le16toh((uint_16t)input);
+
/* shift before conversion to avoid sign extension
of left aligned data */
input = input >> info->shift;
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 986889b..6f3a392 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -74,6 +74,7 @@ struct iio_channel_info {
unsigned bits_used;
unsigned shift;
uint64_t mask;
+ unsigned be;
unsigned is_signed;
unsigned enabled;
unsigned location;
@@ -84,6 +85,7 @@ struct iio_channel_info {
* @is_signed: output whether channel is signed
* @bytes: output how many bytes the channel storage occupies
* @mask: output a bit mask for the raw data
+ * @be: big endian
* @device_dir: the iio device directory
* @name: the channel name
* @generic_name: the channel type name
@@ -93,6 +95,7 @@ inline int iioutils_get_type(unsigned *is_signed,
unsigned *bits_used,
unsigned *shift,
uint64_t *mask,
+ unsigned *be,
const char *device_dir,
const char *name,
const char *generic_name)
@@ -101,7 +104,7 @@ inline int iioutils_get_type(unsigned *is_signed,
int ret;
DIR *dp;
char *scan_el_dir, *builtname, *builtname_generic, *filename = 0;
- char signchar;
+ char signchar, endianchar;
unsigned padint;
const struct dirent *ent;
@@ -156,6 +159,7 @@ inline int iioutils_get_type(unsigned *is_signed,
printf("failed to pass scan type description\n");
return ret;
}
+ *be = (endianchar == 'b');
*bytes = padint / 8;
if (*bits_used == 64)
*mask = ~0;
@@ -399,6 +403,7 @@ inline int build_channel_array(const char *device_dir,
¤t->bits_used,
¤t->shift,
¤t->mask,
+ ¤t->be,
device_dir,
current->name,
current->generic_name);
--
1.7.7.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Fixes ot the generic_buffer example
2011-11-27 11:46 [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
2011-11-27 11:46 ` [PATCH 1/2] staging:iio:Documentation: cleanup properly in buffer handling code Jonathan Cameron
2011-11-27 11:46 ` [PATCH 2/2] staging:iio:generic_buffer example - handle endian differences Jonathan Cameron
@ 2011-12-04 19:11 ` Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2011-12-04 19:11 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 11/27/2011 11:46 AM, Jonathan Cameron wrote:
> Hi All,
>
> These do what they say on the tin.
>
> Jonathan
Gone to Greg.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-04 19:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-27 11:46 [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
2011-11-27 11:46 ` [PATCH 1/2] staging:iio:Documentation: cleanup properly in buffer handling code Jonathan Cameron
2011-11-27 11:46 ` [PATCH 2/2] staging:iio:generic_buffer example - handle endian differences Jonathan Cameron
2011-12-04 19:11 ` [PATCH 0/2] Fixes ot the generic_buffer example Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.