* [PATCH] staging:iio:scan element types: introduce endian description to the data format.
@ 2011-07-29 17:28 Jonathan Cameron
2011-08-12 16:23 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2011-07-29 17:28 UTC (permalink / raw)
To: linux-iio; +Cc: michael.hennerich, manuel.stahl, Jonathan Cameron
If not set in chan_spec, cpu endianness used.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
Result of discussion in [PATCH 0/2] blue part 6: IIO abi rework.
Michael highlighted that we need to specify the endianness of buffer
contents. This patch does that. The IIO_CPU option exists so that
existing drivers which do conversion to cpu endian should work
without change.
Based on all sorts of fun I haven't pushed, so if you really want to
play with this see the iio-blue.git tree.
Jonathan
drivers/staging/iio/iio.h | 8 ++++++++
drivers/staging/iio/industrialio-ring.c | 15 ++++++++++++++-
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
index bde8b87..d09f84b 100644
--- a/drivers/staging/iio/iio.h
+++ b/drivers/staging/iio/iio.h
@@ -86,6 +86,12 @@ enum iio_chan_info_enum {
IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE,
};
+enum iio_endian {
+ IIO_CPU,
+ IIO_BE,
+ IIO_LE,
+};
+
/**
* struct iio_chan_spec - specification of a single channel
* @type: What type of measurement is the channel making.
@@ -101,6 +107,7 @@ enum iio_chan_info_enum {
* storage_bits: Realbits + padding
* shift: Shift right by this before masking out
* realbits.
+ * endianness: little or big endian
* @info_mask: What information is to be exported about this channel.
* This includes calibbias, scale etc.
* @event_mask: What events can this channel produce.
@@ -129,6 +136,7 @@ struct iio_chan_spec {
u8 realbits;
u8 storagebits;
u8 shift;
+ enum iio_endian endianness;
} scan_type;
const long info_mask;
const long event_mask;
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index 5edc6d8..aa1748b 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -24,6 +24,10 @@
#include "iio_core.h"
#include "ring_generic.h"
+const static char *iio_endian_prefix[] = {
+ [IIO_BE] = "be",
+ [IIO_LE] = "le",
+};
/**
* iio_ring_read_first_n_outer() - chrdev read for ring buffer access
@@ -95,7 +99,16 @@ static ssize_t iio_show_fixed_type(struct device *dev,
char *buf)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- return sprintf(buf, "%c%d/%d>>%u\n",
+ u8 type = this_attr->c->scan_type.endianness;
+
+ if (type == IIO_CPU) {
+ if (__LITTLE_ENDIAN)
+ type = IIO_LE;
+ else
+ type = IIO_BE;
+ }
+ return sprintf(buf, "%s:%c%d/%d>>%u\n",
+ iio_endian_prefix[type],
this_attr->c->scan_type.sign,
this_attr->c->scan_type.realbits,
this_attr->c->scan_type.storagebits,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] staging:iio:scan element types: introduce endian description to the data format.
2011-07-29 17:28 [PATCH] staging:iio:scan element types: introduce endian description to the data format Jonathan Cameron
@ 2011-08-12 16:23 ` Jonathan Cameron
2011-08-15 7:40 ` ManuelStahl
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2011-08-12 16:23 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, michael.hennerich, manuel.stahl
On 07/29/11 18:28, Jonathan Cameron wrote:
> If not set in chan_spec, cpu endianness used.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
> Result of discussion in [PATCH 0/2] blue part 6: IIO abi rework.
> Michael highlighted that we need to specify the endianness of buffer
> contents. This patch does that. The IIO_CPU option exists so that
> existing drivers which do conversion to cpu endian should work
> without change.
>
> Based on all sorts of fun I haven't pushed, so if you really want to
> play with this see the iio-blue.git tree.
Michael, Manuel
Is this patch fine with you two?
Thanks,
Jonathan
>
> Jonathan
>
> drivers/staging/iio/iio.h | 8 ++++++++
> drivers/staging/iio/industrialio-ring.c | 15 ++++++++++++++-
> 2 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
> index bde8b87..d09f84b 100644
> --- a/drivers/staging/iio/iio.h
> +++ b/drivers/staging/iio/iio.h
> @@ -86,6 +86,12 @@ enum iio_chan_info_enum {
> IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE,
> };
>
> +enum iio_endian {
> + IIO_CPU,
> + IIO_BE,
> + IIO_LE,
> +};
> +
> /**
> * struct iio_chan_spec - specification of a single channel
> * @type: What type of measurement is the channel making.
> @@ -101,6 +107,7 @@ enum iio_chan_info_enum {
> * storage_bits: Realbits + padding
> * shift: Shift right by this before masking out
> * realbits.
> + * endianness: little or big endian
> * @info_mask: What information is to be exported about this channel.
> * This includes calibbias, scale etc.
> * @event_mask: What events can this channel produce.
> @@ -129,6 +136,7 @@ struct iio_chan_spec {
> u8 realbits;
> u8 storagebits;
> u8 shift;
> + enum iio_endian endianness;
> } scan_type;
> const long info_mask;
> const long event_mask;
> diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
> index 5edc6d8..aa1748b 100644
> --- a/drivers/staging/iio/industrialio-ring.c
> +++ b/drivers/staging/iio/industrialio-ring.c
> @@ -24,6 +24,10 @@
> #include "iio_core.h"
> #include "ring_generic.h"
>
> +const static char *iio_endian_prefix[] = {
> + [IIO_BE] = "be",
> + [IIO_LE] = "le",
> +};
>
> /**
> * iio_ring_read_first_n_outer() - chrdev read for ring buffer access
> @@ -95,7 +99,16 @@ static ssize_t iio_show_fixed_type(struct device *dev,
> char *buf)
> {
> struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> - return sprintf(buf, "%c%d/%d>>%u\n",
> + u8 type = this_attr->c->scan_type.endianness;
> +
> + if (type == IIO_CPU) {
> + if (__LITTLE_ENDIAN)
> + type = IIO_LE;
> + else
> + type = IIO_BE;
> + }
> + return sprintf(buf, "%s:%c%d/%d>>%u\n",
> + iio_endian_prefix[type],
> this_attr->c->scan_type.sign,
> this_attr->c->scan_type.realbits,
> this_attr->c->scan_type.storagebits,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging:iio:scan element types: introduce endian description to the data format.
2011-08-12 16:23 ` Jonathan Cameron
@ 2011-08-15 7:40 ` ManuelStahl
2011-08-15 9:06 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: ManuelStahl @ 2011-08-15 7:40 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, michael.hennerich
Hi Jonathan,
I'm not sure if we need the IIO_CPU, but as long as we only have BE and
LE in the sysfs API it's fine for me.
Regards,
Manuel
Am 12.08.2011 18:23, schrieb Jonathan Cameron:
> On 07/29/11 18:28, Jonathan Cameron wrote:
>> If not set in chan_spec, cpu endianness used.
>>
>> Signed-off-by: Jonathan Cameron<jic23@cam.ac.uk>
>> ---
>> Result of discussion in [PATCH 0/2] blue part 6: IIO abi rework.
>> Michael highlighted that we need to specify the endianness of buffer
>> contents. This patch does that. The IIO_CPU option exists so that
>> existing drivers which do conversion to cpu endian should work
>> without change.
>>
>> Based on all sorts of fun I haven't pushed, so if you really want to
>> play with this see the iio-blue.git tree.
> Michael, Manuel
>
> Is this patch fine with you two?
>
> Thanks,
>
> Jonathan
>> Jonathan
>>
>> drivers/staging/iio/iio.h | 8 ++++++++
>> drivers/staging/iio/industrialio-ring.c | 15 ++++++++++++++-
>> 2 files changed, 22 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
>> index bde8b87..d09f84b 100644
>> --- a/drivers/staging/iio/iio.h
>> +++ b/drivers/staging/iio/iio.h
>> @@ -86,6 +86,12 @@ enum iio_chan_info_enum {
>> IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE,
>> };
>>
>> +enum iio_endian {
>> + IIO_CPU,
>> + IIO_BE,
>> + IIO_LE,
>> +};
>> +
>> /**
>> * struct iio_chan_spec - specification of a single channel
>> * @type: What type of measurement is the channel making.
>> @@ -101,6 +107,7 @@ enum iio_chan_info_enum {
>> * storage_bits: Realbits + padding
>> * shift: Shift right by this before masking out
>> * realbits.
>> + * endianness: little or big endian
>> * @info_mask: What information is to be exported about this channel.
>> * This includes calibbias, scale etc.
>> * @event_mask: What events can this channel produce.
>> @@ -129,6 +136,7 @@ struct iio_chan_spec {
>> u8 realbits;
>> u8 storagebits;
>> u8 shift;
>> + enum iio_endian endianness;
>> } scan_type;
>> const long info_mask;
>> const long event_mask;
>> diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
>> index 5edc6d8..aa1748b 100644
>> --- a/drivers/staging/iio/industrialio-ring.c
>> +++ b/drivers/staging/iio/industrialio-ring.c
>> @@ -24,6 +24,10 @@
>> #include "iio_core.h"
>> #include "ring_generic.h"
>>
>> +const static char *iio_endian_prefix[] = {
>> + [IIO_BE] = "be",
>> + [IIO_LE] = "le",
>> +};
>>
>> /**
>> * iio_ring_read_first_n_outer() - chrdev read for ring buffer access
>> @@ -95,7 +99,16 @@ static ssize_t iio_show_fixed_type(struct device *dev,
>> char *buf)
>> {
>> struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
>> - return sprintf(buf, "%c%d/%d>>%u\n",
>> + u8 type = this_attr->c->scan_type.endianness;
>> +
>> + if (type == IIO_CPU) {
>> + if (__LITTLE_ENDIAN)
>> + type = IIO_LE;
>> + else
>> + type = IIO_BE;
>> + }
>> + return sprintf(buf, "%s:%c%d/%d>>%u\n",
>> + iio_endian_prefix[type],
>> this_attr->c->scan_type.sign,
>> this_attr->c->scan_type.realbits,
>> this_attr->c->scan_type.storagebits,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging:iio:scan element types: introduce endian description to the data format.
2011-08-15 7:40 ` ManuelStahl
@ 2011-08-15 9:06 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2011-08-15 9:06 UTC (permalink / raw)
To: ManuelStahl; +Cc: linux-iio, michael.hennerich
On 08/15/11 08:40, ManuelStahl wrote:
> Hi Jonathan,
>
> I'm not sure if we need the IIO_CPU, but as long as we only have BE and LE in the sysfs API it's fine for me.
IIO_CPU is purely for merging reasons (as it doesn't require us to update all drivers
in one big patch set). We'll drop it when moving out of staging or whenever every
driver is specifying what it is providing.
>
> Regards,
> Manuel
>
> Am 12.08.2011 18:23, schrieb Jonathan Cameron:
>> On 07/29/11 18:28, Jonathan Cameron wrote:
>>> If not set in chan_spec, cpu endianness used.
>>>
>>> Signed-off-by: Jonathan Cameron<jic23@cam.ac.uk>
>>> ---
>>> Result of discussion in [PATCH 0/2] blue part 6: IIO abi rework.
>>> Michael highlighted that we need to specify the endianness of buffer
>>> contents. This patch does that. The IIO_CPU option exists so that
>>> existing drivers which do conversion to cpu endian should work
>>> without change.
>>>
>>> Based on all sorts of fun I haven't pushed, so if you really want to
>>> play with this see the iio-blue.git tree.
>> Michael, Manuel
>>
>> Is this patch fine with you two?
>>
>> Thanks,
>>
>> Jonathan
>>> Jonathan
>>>
>>> drivers/staging/iio/iio.h | 8 ++++++++
>>> drivers/staging/iio/industrialio-ring.c | 15 ++++++++++++++-
>>> 2 files changed, 22 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
>>> index bde8b87..d09f84b 100644
>>> --- a/drivers/staging/iio/iio.h
>>> +++ b/drivers/staging/iio/iio.h
>>> @@ -86,6 +86,12 @@ enum iio_chan_info_enum {
>>> IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE,
>>> };
>>>
>>> +enum iio_endian {
>>> + IIO_CPU,
>>> + IIO_BE,
>>> + IIO_LE,
>>> +};
>>> +
>>> /**
>>> * struct iio_chan_spec - specification of a single channel
>>> * @type: What type of measurement is the channel making.
>>> @@ -101,6 +107,7 @@ enum iio_chan_info_enum {
>>> * storage_bits: Realbits + padding
>>> * shift: Shift right by this before masking out
>>> * realbits.
>>> + * endianness: little or big endian
>>> * @info_mask: What information is to be exported about this channel.
>>> * This includes calibbias, scale etc.
>>> * @event_mask: What events can this channel produce.
>>> @@ -129,6 +136,7 @@ struct iio_chan_spec {
>>> u8 realbits;
>>> u8 storagebits;
>>> u8 shift;
>>> + enum iio_endian endianness;
>>> } scan_type;
>>> const long info_mask;
>>> const long event_mask;
>>> diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
>>> index 5edc6d8..aa1748b 100644
>>> --- a/drivers/staging/iio/industrialio-ring.c
>>> +++ b/drivers/staging/iio/industrialio-ring.c
>>> @@ -24,6 +24,10 @@
>>> #include "iio_core.h"
>>> #include "ring_generic.h"
>>>
>>> +const static char *iio_endian_prefix[] = {
>>> + [IIO_BE] = "be",
>>> + [IIO_LE] = "le",
>>> +};
>>>
>>> /**
>>> * iio_ring_read_first_n_outer() - chrdev read for ring buffer access
>>> @@ -95,7 +99,16 @@ static ssize_t iio_show_fixed_type(struct device *dev,
>>> char *buf)
>>> {
>>> struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
>>> - return sprintf(buf, "%c%d/%d>>%u\n",
>>> + u8 type = this_attr->c->scan_type.endianness;
>>> +
>>> + if (type == IIO_CPU) {
>>> + if (__LITTLE_ENDIAN)
>>> + type = IIO_LE;
>>> + else
>>> + type = IIO_BE;
>>> + }
>>> + return sprintf(buf, "%s:%c%d/%d>>%u\n",
>>> + iio_endian_prefix[type],
>>> this_attr->c->scan_type.sign,
>>> this_attr->c->scan_type.realbits,
>>> this_attr->c->scan_type.storagebits,
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-15 8:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-29 17:28 [PATCH] staging:iio:scan element types: introduce endian description to the data format Jonathan Cameron
2011-08-12 16:23 ` Jonathan Cameron
2011-08-15 7:40 ` ManuelStahl
2011-08-15 9:06 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).