* [PATCH 02/10] staging:iio:ad7476: Remove duplicated chip info entries
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode Lars-Peter Clausen
` (8 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
Some of the parts supported by this driver are software compatible. The
difference between them is only in the operating voltage range. So we do not
need extra chip info entries for them.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7476.h | 4 ----
drivers/staging/iio/adc/ad7476_core.c | 30 +++++++-----------------------
2 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
index b1dd931..6085fad 100644
--- a/drivers/staging/iio/adc/ad7476.h
+++ b/drivers/staging/iio/adc/ad7476.h
@@ -41,10 +41,6 @@ enum ad7476_supported_device_ids {
ID_AD7466,
ID_AD7467,
ID_AD7468,
- ID_AD7475,
- ID_AD7476,
- ID_AD7477,
- ID_AD7478,
ID_AD7495
};
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index 33435ed..c97300b 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -93,22 +93,6 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
.channel[0] = AD7476_CHAN(8),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
- [ID_AD7475] = {
- .channel[0] = AD7476_CHAN(12),
- .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- },
- [ID_AD7476] = {
- .channel[0] = AD7476_CHAN(12),
- .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- },
- [ID_AD7477] = {
- .channel[0] = AD7476_CHAN(10),
- .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- },
- [ID_AD7478] = {
- .channel[0] = AD7476_CHAN(8),
- .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- },
[ID_AD7495] = {
.channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
@@ -216,13 +200,13 @@ static const struct spi_device_id ad7476_id[] = {
{"ad7466", ID_AD7466},
{"ad7467", ID_AD7467},
{"ad7468", ID_AD7468},
- {"ad7475", ID_AD7475},
- {"ad7476", ID_AD7476},
- {"ad7476a", ID_AD7476},
- {"ad7477", ID_AD7477},
- {"ad7477a", ID_AD7477},
- {"ad7478", ID_AD7478},
- {"ad7478a", ID_AD7478},
+ {"ad7475", ID_AD7466},
+ {"ad7476", ID_AD7466},
+ {"ad7476a", ID_AD7466},
+ {"ad7477", ID_AD7467},
+ {"ad7477a", ID_AD7467},
+ {"ad7478", ID_AD7468},
+ {"ad7478a", ID_AD7468},
{"ad7495", ID_AD7495},
{}
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 02/10] staging:iio:ad7476: Remove duplicated chip info entries Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 16:37 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling Lars-Peter Clausen
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
the buffer size is the size of one sample plus the size of the timestamp.
Preallocate a buffer large enough to hold this to avoid having to allocate and
free a new buffer for each sample being captured.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7476.h | 5 ++++-
drivers/staging/iio/adc/ad7476_ring.c | 13 +++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
index 6085fad..c4f1150 100644
--- a/drivers/staging/iio/adc/ad7476.h
+++ b/drivers/staging/iio/adc/ad7476.h
@@ -33,8 +33,11 @@ struct ad7476_state {
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
+ * Make the buffer large enough for one 16 bit sample and one 64 bit
+ * aligned 64 bit timestamp.
*/
- unsigned char data[2] ____cacheline_aligned;
+ unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
+ ____cacheline_aligned;
};
enum ad7476_supported_device_ids {
diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
index 940681f..185cfde 100644
--- a/drivers/staging/iio/adc/ad7476_ring.c
+++ b/drivers/staging/iio/adc/ad7476_ring.c
@@ -26,14 +26,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev;
struct ad7476_state *st = iio_priv(indio_dev);
s64 time_ns;
- __u8 *rxbuf;
int b_sent;
- rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
- if (rxbuf == NULL)
- goto done;
-
- b_sent = spi_read(st->spi, rxbuf,
+ b_sent = spi_read(st->spi, st->data,
st->chip_info->channel[0].scan_type.storagebits / 8);
if (b_sent < 0)
goto done;
@@ -41,13 +36,11 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
time_ns = iio_get_time_ns();
if (indio_dev->scan_timestamp)
- memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64),
- &time_ns, sizeof(time_ns));
+ ((s64 *)st->data)[1] = time_ns;
- iio_push_to_buffer(indio_dev->buffer, rxbuf);
+ iio_push_to_buffer(indio_dev->buffer, st->data);
done:
iio_trigger_notify_done(indio_dev->trig);
- kfree(rxbuf);
return IRQ_HANDLED;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
2012-09-07 12:44 ` [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode Lars-Peter Clausen
@ 2012-09-07 16:37 ` Lars-Peter Clausen
2012-09-08 9:40 ` Jonathan Cameron
0 siblings, 1 reply; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 16:37 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 02:44 PM, Lars-Peter Clausen wrote:
> The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
> the buffer size is the size of one sample plus the size of the timestamp.
> Preallocate a buffer large enough to hold this to avoid having to allocate and
> free a new buffer for each sample being captured.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/adc/ad7476.h | 5 ++++-
> drivers/staging/iio/adc/ad7476_ring.c | 13 +++----------
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
> index 6085fad..c4f1150 100644
> --- a/drivers/staging/iio/adc/ad7476.h
> +++ b/drivers/staging/iio/adc/ad7476.h
> @@ -33,8 +33,11 @@ struct ad7476_state {
> /*
> * DMA (thus cache coherency maintenance) requires the
> * transfer buffers to live in their own cache lines.
> + * Make the buffer large enough for one 16 bit sample and one 64 bit
> + * aligned 64 bit timestamp.
> */
> - unsigned char data[2] ____cacheline_aligned;
> + unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
> + ____cacheline_aligned;
> };
>
> enum ad7476_supported_device_ids {
> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
> index 940681f..185cfde 100644
> --- a/drivers/staging/iio/adc/ad7476_ring.c
> +++ b/drivers/staging/iio/adc/ad7476_ring.c
> @@ -26,14 +26,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> struct iio_dev *indio_dev = pf->indio_dev;
> struct ad7476_state *st = iio_priv(indio_dev);
> s64 time_ns;
> - __u8 *rxbuf;
> int b_sent;
>
> - rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
> - if (rxbuf == NULL)
> - goto done;
> -
> - b_sent = spi_read(st->spi, rxbuf,
> + b_sent = spi_read(st->spi, st->data,
> st->chip_info->channel[0].scan_type.storagebits / 8);
I just noticed this can even more be simplified by using the prepared SPI
message. Unfortunately this will require regeneration of a few more patches.
I'll resend the whole series next week, after it had some exposure to review.
> if (b_sent < 0)
> goto done;
> @@ -41,13 +36,11 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> time_ns = iio_get_time_ns();
>
> if (indio_dev->scan_timestamp)
> - memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64),
> - &time_ns, sizeof(time_ns));
> + ((s64 *)st->data)[1] = time_ns;
>
> - iio_push_to_buffer(indio_dev->buffer, rxbuf);
> + iio_push_to_buffer(indio_dev->buffer, st->data);
> done:
> iio_trigger_notify_done(indio_dev->trig);
> - kfree(rxbuf);
>
> return IRQ_HANDLED;
> }
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
2012-09-07 16:37 ` Lars-Peter Clausen
@ 2012-09-08 9:40 ` Jonathan Cameron
2012-09-08 17:20 ` Lars-Peter Clausen
0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:40 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 05:37 PM, Lars-Peter Clausen wrote:
> On 09/07/2012 02:44 PM, Lars-Peter Clausen wrote:
>> The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
>> the buffer size is the size of one sample plus the size of the timestamp.
>> Preallocate a buffer large enough to hold this to avoid having to allocate and
>> free a new buffer for each sample being captured.
Sensible move...
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>> drivers/staging/iio/adc/ad7476.h | 5 ++++-
>> drivers/staging/iio/adc/ad7476_ring.c | 13 +++----------
>> 2 files changed, 7 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
>> index 6085fad..c4f1150 100644
>> --- a/drivers/staging/iio/adc/ad7476.h
>> +++ b/drivers/staging/iio/adc/ad7476.h
>> @@ -33,8 +33,11 @@ struct ad7476_state {
>> /*
>> * DMA (thus cache coherency maintenance) requires the
>> * transfer buffers to live in their own cache lines.
>> + * Make the buffer large enough for one 16 bit sample and one 64 bit
>> + * aligned 64 bit timestamp.
>> */
>> - unsigned char data[2] ____cacheline_aligned;
>> + unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
>> + ____cacheline_aligned;
>> };
>>
>> enum ad7476_supported_device_ids {
>> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
>> index 940681f..185cfde 100644
>> --- a/drivers/staging/iio/adc/ad7476_ring.c
>> +++ b/drivers/staging/iio/adc/ad7476_ring.c
>> @@ -26,14 +26,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
>> struct iio_dev *indio_dev = pf->indio_dev;
>> struct ad7476_state *st = iio_priv(indio_dev);
>> s64 time_ns;
>> - __u8 *rxbuf;
>> int b_sent;
>>
>> - rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
>> - if (rxbuf == NULL)
>> - goto done;
>> -
>> - b_sent = spi_read(st->spi, rxbuf,
>> + b_sent = spi_read(st->spi, st->data,
>> st->chip_info->channel[0].scan_type.storagebits / 8);
>
> I just noticed this can even more be simplified by using the prepared SPI
> message. Unfortunately this will require regeneration of a few more patches.
> I'll resend the whole series next week, after it had some exposure to review.
Hmm. Guess that would be a marginal improvement. Actually from code
readability I'd be tempted to drop the prepared SPI message and
just do the spi_read as you have it here where that message is currently used.
Obviously it'll have some overhead though so up to you which way you go.
>
>> if (b_sent < 0)
>> goto done;
>> @@ -41,13 +36,11 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
>> time_ns = iio_get_time_ns();
>>
>> if (indio_dev->scan_timestamp)
>> - memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64),
>> - &time_ns, sizeof(time_ns));
>> + ((s64 *)st->data)[1] = time_ns;
>>
>> - iio_push_to_buffer(indio_dev->buffer, rxbuf);
>> + iio_push_to_buffer(indio_dev->buffer, st->data);
>> done:
>> iio_trigger_notify_done(indio_dev->trig);
>> - kfree(rxbuf);
>>
>> return IRQ_HANDLED;
>> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
2012-09-08 9:40 ` Jonathan Cameron
@ 2012-09-08 17:20 ` Lars-Peter Clausen
2012-09-08 19:50 ` Jonathan Cameron
0 siblings, 1 reply; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-08 17:20 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/08/2012 11:40 AM, Jonathan Cameron wrote:
> On 09/07/2012 05:37 PM, Lars-Peter Clausen wrote:
>> On 09/07/2012 02:44 PM, Lars-Peter Clausen wrote:
>>> The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
>>> the buffer size is the size of one sample plus the size of the timestamp.
>>> Preallocate a buffer large enough to hold this to avoid having to allocate and
>>> free a new buffer for each sample being captured.
> Sensible move...
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>> ---
>>> drivers/staging/iio/adc/ad7476.h | 5 ++++-
>>> drivers/staging/iio/adc/ad7476_ring.c | 13 +++----------
>>> 2 files changed, 7 insertions(+), 11 deletions(-)
>>>
[...]
>>> enum ad7476_supported_device_ids {
>>> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
>>> index 940681f..185cfde 100644
>>> --- a/drivers/staging/iio/adc/ad7476_ring.c
>>> +++ b/drivers/staging/iio/adc/ad7476_ring.c
>>> @@ -26,14 +26,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
>>> struct iio_dev *indio_dev = pf->indio_dev;
>>> struct ad7476_state *st = iio_priv(indio_dev);
>>> s64 time_ns;
>>> - __u8 *rxbuf;
>>> int b_sent;
>>>
>>> - rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
>>> - if (rxbuf == NULL)
>>> - goto done;
>>> -
>>> - b_sent = spi_read(st->spi, rxbuf,
>>> + b_sent = spi_read(st->spi, st->data,
>>> st->chip_info->channel[0].scan_type.storagebits / 8);
>>
>> I just noticed this can even more be simplified by using the prepared SPI
>> message. Unfortunately this will require regeneration of a few more patches.
>> I'll resend the whole series next week, after it had some exposure to review.
>
> Hmm. Guess that would be a marginal improvement. Actually from code
> readability I'd be tempted to drop the prepared SPI message and
> just do the spi_read as you have it here where that message is currently used.
>
> Obviously it'll have some overhead though so up to you which way you go.
I think the overhead is actually negligible. But there is a pattern that
emerges. For SPI based devices we usually first send the spi message which
fills the transfer buffer, then store the timestamp in the last element of the
transfer buffer and then send the transfer buffer to the iio buffer using
iio_push_to_buffer. What differs for different devices is how exactly the
message looks, but the rest of the pattern is identical. So if we define the
the message outside of the trigger handler, e.g. at device init or the
update_scan_mode callback we get the opportunity to have a common trigger
function between a wide range of different SPI devices. Obviously it wont work
for all, because some need special handling, but it will provide a good default
implementation. So that's one reason why I'd like to use spi_sync here, since
it will make the migration later on more obvious.
- Lars
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
2012-09-08 17:20 ` Lars-Peter Clausen
@ 2012-09-08 19:50 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 19:50 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/08/2012 06:20 PM, Lars-Peter Clausen wrote:
> On 09/08/2012 11:40 AM, Jonathan Cameron wrote:
>> On 09/07/2012 05:37 PM, Lars-Peter Clausen wrote:
>>> On 09/07/2012 02:44 PM, Lars-Peter Clausen wrote:
>>>> The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
>>>> the buffer size is the size of one sample plus the size of the timestamp.
>>>> Preallocate a buffer large enough to hold this to avoid having to allocate and
>>>> free a new buffer for each sample being captured.
>> Sensible move...
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>>> ---
>>>> drivers/staging/iio/adc/ad7476.h | 5 ++++-
>>>> drivers/staging/iio/adc/ad7476_ring.c | 13 +++----------
>>>> 2 files changed, 7 insertions(+), 11 deletions(-)
>>>>
> [...]
>>>> enum ad7476_supported_device_ids {
>>>> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
>>>> index 940681f..185cfde 100644
>>>> --- a/drivers/staging/iio/adc/ad7476_ring.c
>>>> +++ b/drivers/staging/iio/adc/ad7476_ring.c
>>>> @@ -26,14 +26,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
>>>> struct iio_dev *indio_dev = pf->indio_dev;
>>>> struct ad7476_state *st = iio_priv(indio_dev);
>>>> s64 time_ns;
>>>> - __u8 *rxbuf;
>>>> int b_sent;
>>>>
>>>> - rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
>>>> - if (rxbuf == NULL)
>>>> - goto done;
>>>> -
>>>> - b_sent = spi_read(st->spi, rxbuf,
>>>> + b_sent = spi_read(st->spi, st->data,
>>>> st->chip_info->channel[0].scan_type.storagebits / 8);
>>>
>>> I just noticed this can even more be simplified by using the prepared SPI
>>> message. Unfortunately this will require regeneration of a few more patches.
>>> I'll resend the whole series next week, after it had some exposure to review.
>>
>> Hmm. Guess that would be a marginal improvement. Actually from code
>> readability I'd be tempted to drop the prepared SPI message and
>> just do the spi_read as you have it here where that message is currently used.
>>
>> Obviously it'll have some overhead though so up to you which way you go.
>
> I think the overhead is actually negligible. But there is a pattern that
> emerges. For SPI based devices we usually first send the spi message which
> fills the transfer buffer, then store the timestamp in the last element of the
> transfer buffer and then send the transfer buffer to the iio buffer using
> iio_push_to_buffer. What differs for different devices is how exactly the
> message looks, but the rest of the pattern is identical. So if we define the
> the message outside of the trigger handler, e.g. at device init or the
> update_scan_mode callback we get the opportunity to have a common trigger
> function between a wide range of different SPI devices. Obviously it wont work
> for all, because some need special handling, but it will provide a good default
> implementation. So that's one reason why I'd like to use spi_sync here, since
> it will make the migration later on more obvious.
Fair enough.
>
> - Lars
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 02/10] staging:iio:ad7476: Remove duplicated chip info entries Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 14:31 ` [PATCH v2 " Lars-Peter Clausen
2012-09-08 9:45 ` [PATCH " Jonathan Cameron
2012-09-07 12:44 ` [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file Lars-Peter Clausen
` (6 subsequent siblings)
9 siblings, 2 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
Slightly rework the reference voltage handling for the ad7476 driver. Now the only
way to specify a external reference voltage is to use the regulator API,
previously it was possible to use either platform_data or the regulator API. The
new way is more consistent with what other drivers do.
Also do not ignore errors when requesting the regulator, since this will cope
very poorly with e.g. deferred probing.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7476.h | 11 +------
drivers/staging/iio/adc/ad7476_core.c | 56 +++++++++++++++------------------
2 files changed, 26 insertions(+), 41 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
index c4f1150..4ed5494 100644
--- a/drivers/staging/iio/adc/ad7476.h
+++ b/drivers/staging/iio/adc/ad7476.h
@@ -10,16 +10,8 @@
#define RES_MASK(bits) ((1 << (bits)) - 1)
-/*
- * TODO: struct ad7476_platform_data needs to go into include/linux/iio
- */
-
-struct ad7476_platform_data {
- u16 vref_mv;
-};
-
struct ad7476_chip_info {
- u16 int_vref_mv;
+ unsigned int int_vref_uv;
struct iio_chan_spec channel[2];
};
@@ -27,7 +19,6 @@ struct ad7476_state {
struct spi_device *spi;
const struct ad7476_chip_info *chip_info;
struct regulator *reg;
- u16 int_vref_mv;
struct spi_transfer xfer;
struct spi_message msg;
/*
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index c97300b..42523e6 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -40,7 +40,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
{
int ret;
struct ad7476_state *st = iio_priv(indio_dev);
- unsigned int scale_uv;
+ int scale_uv;
switch (m) {
case IIO_CHAN_INFO_RAW:
@@ -57,10 +57,16 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
RES_MASK(st->chip_info->channel[0].scan_type.realbits);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->int_vref_mv * 1000)
- >> st->chip_info->channel[0].scan_type.realbits;
- *val = scale_uv/1000;
- *val2 = (scale_uv%1000)*1000;
+ if (!st->chip_info->int_vref_uv) {
+ scale_uv = regulator_get_voltage(st->reg);
+ if (scale_uv < 0)
+ return scale_uv;
+ } else {
+ scale_uv = st->chip_info->int_vref_uv;
+ }
+ scale_uv >>= chan->scan_type.realbits;
+ *val = scale_uv / 1000;
+ *val2 = (scale_uv % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO;
}
return -EINVAL;
@@ -96,7 +102,7 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
[ID_AD7495] = {
.channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- .int_vref_mv = 2500,
+ .int_vref_uv = 2500000,
},
};
@@ -107,10 +113,9 @@ static const struct iio_info ad7476_info = {
static int __devinit ad7476_probe(struct spi_device *spi)
{
- struct ad7476_platform_data *pdata = spi->dev.platform_data;
struct ad7476_state *st;
struct iio_dev *indio_dev;
- int ret, voltage_uv = 0;
+ int ret;
indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
@@ -118,25 +123,18 @@ static int __devinit ad7476_probe(struct spi_device *spi)
goto error_ret;
}
st = iio_priv(indio_dev);
+ st->chip_info =
+ &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
+
st->reg = regulator_get(&spi->dev, "vcc");
if (!IS_ERR(st->reg)) {
- ret = regulator_enable(st->reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(st->reg);
+ ret = PTR_ERR(st->reg);
+ goto error_ret;
}
- st->chip_info =
- &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
- if (st->chip_info->int_vref_mv)
- st->int_vref_mv = st->chip_info->int_vref_mv;
- else if (pdata && pdata->vref_mv)
- st->int_vref_mv = pdata->vref_mv;
- else if (voltage_uv)
- st->int_vref_mv = voltage_uv / 1000;
- else
- dev_warn(&spi->dev, "reference voltage unspecified\n");
+ ret = regulator_enable(st->reg);
+ if (ret)
+ goto error_put_reg;
spi_set_drvdata(spi, indio_dev);
@@ -169,11 +167,9 @@ static int __devinit ad7476_probe(struct spi_device *spi)
error_ring_unregister:
ad7476_ring_cleanup(indio_dev);
error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
+ regulator_disable(st->reg);
error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
+ regulator_put(st->reg);
iio_device_free(indio_dev);
error_ret:
@@ -187,10 +183,8 @@ static int __devexit ad7476_remove(struct spi_device *spi)
iio_device_unregister(indio_dev);
ad7476_ring_cleanup(indio_dev);
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
+ regulator_disable(st->reg);
+ regulator_put(st->reg);
iio_device_free(indio_dev);
return 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 04/10] staging:iio:ad7476: Rework reference voltage handling
2012-09-07 12:44 ` [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling Lars-Peter Clausen
@ 2012-09-07 14:31 ` Lars-Peter Clausen
2012-09-08 9:45 ` [PATCH " Jonathan Cameron
1 sibling, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 14:31 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
Slightly rework the reference voltage handling for the ad7476 driver. Now the only
way to specify a external reference voltage is to use the regulator API,
previously it was possible to use either platform_data or the regulator API. The
new way is more consistent with what other drivers do.
Also do not ignore errors when requesting the regulator, since this will cope
very poorly with e.g. deferred probing.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
Had a uncommited change... :/
Changes since v1:
* Fix regulator error handling
---
drivers/staging/iio/adc/ad7476.h | 11 +------
drivers/staging/iio/adc/ad7476_core.c | 58 +++++++++++++++------------------
2 files changed, 27 insertions(+), 42 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
index c4f1150..4ed5494 100644
--- a/drivers/staging/iio/adc/ad7476.h
+++ b/drivers/staging/iio/adc/ad7476.h
@@ -10,16 +10,8 @@
#define RES_MASK(bits) ((1 << (bits)) - 1)
-/*
- * TODO: struct ad7476_platform_data needs to go into include/linux/iio
- */
-
-struct ad7476_platform_data {
- u16 vref_mv;
-};
-
struct ad7476_chip_info {
- u16 int_vref_mv;
+ unsigned int int_vref_uv;
struct iio_chan_spec channel[2];
};
@@ -27,7 +19,6 @@ struct ad7476_state {
struct spi_device *spi;
const struct ad7476_chip_info *chip_info;
struct regulator *reg;
- u16 int_vref_mv;
struct spi_transfer xfer;
struct spi_message msg;
/*
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index c97300b..e79a179 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -40,7 +40,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
{
int ret;
struct ad7476_state *st = iio_priv(indio_dev);
- unsigned int scale_uv;
+ int scale_uv;
switch (m) {
case IIO_CHAN_INFO_RAW:
@@ -57,10 +57,16 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
RES_MASK(st->chip_info->channel[0].scan_type.realbits);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->int_vref_mv * 1000)
- >> st->chip_info->channel[0].scan_type.realbits;
- *val = scale_uv/1000;
- *val2 = (scale_uv%1000)*1000;
+ if (!st->chip_info->int_vref_uv) {
+ scale_uv = regulator_get_voltage(st->reg);
+ if (scale_uv < 0)
+ return scale_uv;
+ } else {
+ scale_uv = st->chip_info->int_vref_uv;
+ }
+ scale_uv >>= chan->scan_type.realbits;
+ *val = scale_uv / 1000;
+ *val2 = (scale_uv % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO;
}
return -EINVAL;
@@ -96,7 +102,7 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
[ID_AD7495] = {
.channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- .int_vref_mv = 2500,
+ .int_vref_uv = 2500000,
},
};
@@ -107,10 +113,9 @@ static const struct iio_info ad7476_info = {
static int __devinit ad7476_probe(struct spi_device *spi)
{
- struct ad7476_platform_data *pdata = spi->dev.platform_data;
struct ad7476_state *st;
struct iio_dev *indio_dev;
- int ret, voltage_uv = 0;
+ int ret;
indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
@@ -118,25 +123,18 @@ static int __devinit ad7476_probe(struct spi_device *spi)
goto error_ret;
}
st = iio_priv(indio_dev);
- st->reg = regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(st->reg)) {
- ret = regulator_enable(st->reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(st->reg);
- }
st->chip_info =
&ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
- if (st->chip_info->int_vref_mv)
- st->int_vref_mv = st->chip_info->int_vref_mv;
- else if (pdata && pdata->vref_mv)
- st->int_vref_mv = pdata->vref_mv;
- else if (voltage_uv)
- st->int_vref_mv = voltage_uv / 1000;
- else
- dev_warn(&spi->dev, "reference voltage unspecified\n");
+ st->reg = regulator_get(&spi->dev, "vcc");
+ if (IS_ERR(st->reg)) {
+ ret = PTR_ERR(st->reg);
+ goto error_ret;
+ }
+
+ ret = regulator_enable(st->reg);
+ if (ret)
+ goto error_put_reg;
spi_set_drvdata(spi, indio_dev);
@@ -169,11 +167,9 @@ static int __devinit ad7476_probe(struct spi_device *spi)
error_ring_unregister:
ad7476_ring_cleanup(indio_dev);
error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
+ regulator_disable(st->reg);
error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
+ regulator_put(st->reg);
iio_device_free(indio_dev);
error_ret:
@@ -187,10 +183,8 @@ static int __devexit ad7476_remove(struct spi_device *spi)
iio_device_unregister(indio_dev);
ad7476_ring_cleanup(indio_dev);
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
+ regulator_disable(st->reg);
+ regulator_put(st->reg);
iio_device_free(indio_dev);
return 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling
2012-09-07 12:44 ` [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling Lars-Peter Clausen
2012-09-07 14:31 ` [PATCH v2 " Lars-Peter Clausen
@ 2012-09-08 9:45 ` Jonathan Cameron
1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:45 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 01:44 PM, Lars-Peter Clausen wrote:
> Slightly rework the reference voltage handling for the ad7476 driver. Now the only
> way to specify a external reference voltage is to use the regulator API,
> previously it was possible to use either platform_data or the regulator API. The
> new way is more consistent with what other drivers do.
>
> Also do not ignore errors when requesting the regulator, since this will cope
> very poorly with e.g. deferred probing.
>
The approach of using platform data is an old one from the days when the
regulator framework was relatively new and little used. Now days it probably
makes sense to kill that off in the drivers that use it in favour of insisting
people use a fixed regulator to do the same job...
If anyone wants to pick up the job of clearing this out of the other drivers
that still have it then feel free!
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/adc/ad7476.h | 11 +------
> drivers/staging/iio/adc/ad7476_core.c | 56 +++++++++++++++------------------
> 2 files changed, 26 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
> index c4f1150..4ed5494 100644
> --- a/drivers/staging/iio/adc/ad7476.h
> +++ b/drivers/staging/iio/adc/ad7476.h
> @@ -10,16 +10,8 @@
>
> #define RES_MASK(bits) ((1 << (bits)) - 1)
>
> -/*
> - * TODO: struct ad7476_platform_data needs to go into include/linux/iio
> - */
> -
> -struct ad7476_platform_data {
> - u16 vref_mv;
> -};
> -
> struct ad7476_chip_info {
> - u16 int_vref_mv;
> + unsigned int int_vref_uv;
> struct iio_chan_spec channel[2];
> };
>
> @@ -27,7 +19,6 @@ struct ad7476_state {
> struct spi_device *spi;
> const struct ad7476_chip_info *chip_info;
> struct regulator *reg;
> - u16 int_vref_mv;
> struct spi_transfer xfer;
> struct spi_message msg;
> /*
> diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
> index c97300b..42523e6 100644
> --- a/drivers/staging/iio/adc/ad7476_core.c
> +++ b/drivers/staging/iio/adc/ad7476_core.c
> @@ -40,7 +40,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
> {
> int ret;
> struct ad7476_state *st = iio_priv(indio_dev);
> - unsigned int scale_uv;
> + int scale_uv;
>
> switch (m) {
> case IIO_CHAN_INFO_RAW:
> @@ -57,10 +57,16 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
> RES_MASK(st->chip_info->channel[0].scan_type.realbits);
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_SCALE:
> - scale_uv = (st->int_vref_mv * 1000)
> - >> st->chip_info->channel[0].scan_type.realbits;
> - *val = scale_uv/1000;
> - *val2 = (scale_uv%1000)*1000;
> + if (!st->chip_info->int_vref_uv) {
> + scale_uv = regulator_get_voltage(st->reg);
> + if (scale_uv < 0)
> + return scale_uv;
> + } else {
> + scale_uv = st->chip_info->int_vref_uv;
> + }
> + scale_uv >>= chan->scan_type.realbits;
> + *val = scale_uv / 1000;
> + *val2 = (scale_uv % 1000) * 1000;
> return IIO_VAL_INT_PLUS_MICRO;
> }
> return -EINVAL;
> @@ -96,7 +102,7 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
> [ID_AD7495] = {
> .channel[0] = AD7476_CHAN(12),
> .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
> - .int_vref_mv = 2500,
> + .int_vref_uv = 2500000,
> },
> };
>
> @@ -107,10 +113,9 @@ static const struct iio_info ad7476_info = {
>
> static int __devinit ad7476_probe(struct spi_device *spi)
> {
> - struct ad7476_platform_data *pdata = spi->dev.platform_data;
> struct ad7476_state *st;
> struct iio_dev *indio_dev;
> - int ret, voltage_uv = 0;
> + int ret;
>
> indio_dev = iio_device_alloc(sizeof(*st));
> if (indio_dev == NULL) {
> @@ -118,25 +123,18 @@ static int __devinit ad7476_probe(struct spi_device *spi)
> goto error_ret;
> }
> st = iio_priv(indio_dev);
> + st->chip_info =
> + &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
> +
> st->reg = regulator_get(&spi->dev, "vcc");
> if (!IS_ERR(st->reg)) {
> - ret = regulator_enable(st->reg);
> - if (ret)
> - goto error_put_reg;
> -
> - voltage_uv = regulator_get_voltage(st->reg);
> + ret = PTR_ERR(st->reg);
> + goto error_ret;
> }
> - st->chip_info =
> - &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
>
> - if (st->chip_info->int_vref_mv)
> - st->int_vref_mv = st->chip_info->int_vref_mv;
> - else if (pdata && pdata->vref_mv)
> - st->int_vref_mv = pdata->vref_mv;
> - else if (voltage_uv)
> - st->int_vref_mv = voltage_uv / 1000;
> - else
> - dev_warn(&spi->dev, "reference voltage unspecified\n");
> + ret = regulator_enable(st->reg);
> + if (ret)
> + goto error_put_reg;
>
> spi_set_drvdata(spi, indio_dev);
>
> @@ -169,11 +167,9 @@ static int __devinit ad7476_probe(struct spi_device *spi)
> error_ring_unregister:
> ad7476_ring_cleanup(indio_dev);
> error_disable_reg:
> - if (!IS_ERR(st->reg))
> - regulator_disable(st->reg);
> + regulator_disable(st->reg);
> error_put_reg:
> - if (!IS_ERR(st->reg))
> - regulator_put(st->reg);
> + regulator_put(st->reg);
> iio_device_free(indio_dev);
>
> error_ret:
> @@ -187,10 +183,8 @@ static int __devexit ad7476_remove(struct spi_device *spi)
>
> iio_device_unregister(indio_dev);
> ad7476_ring_cleanup(indio_dev);
> - if (!IS_ERR(st->reg)) {
> - regulator_disable(st->reg);
> - regulator_put(st->reg);
> - }
> + regulator_disable(st->reg);
> + regulator_put(st->reg);
> iio_device_free(indio_dev);
>
> return 0;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file.
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (2 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 04/10] staging:iio:ad7476: Rework reference voltage handling Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-08 9:47 ` Jonathan Cameron
2012-09-08 9:50 ` Jonathan Cameron
2012-09-07 12:44 ` [PATCH 06/10] staging:iio:ad7476: Use be16_to_cpup instead of open-coding it Lars-Peter Clausen
` (5 subsequent siblings)
9 siblings, 2 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
After the recent cleanups the buffer support is just a single 23 line function.
This does not really justify a file on its own, so move it to the main driver
file. And with only one source file left the header file containing the device
state struct becomes superflousious so move the content of the header
file to the main driver source file as well.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/Makefile | 2 -
.../staging/iio/adc/{ad7476_core.c => ad7476.c} | 82 +++++++++++++++++++-
drivers/staging/iio/adc/ad7476.h | 56 -------------
drivers/staging/iio/adc/ad7476_ring.c | 57 --------------
4 files changed, 81 insertions(+), 116 deletions(-)
rename drivers/staging/iio/adc/{ad7476_core.c => ad7476.c} (73%)
delete mode 100644 drivers/staging/iio/adc/ad7476.h
delete mode 100644 drivers/staging/iio/adc/ad7476_ring.c
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index ecac9a0..6b60af0 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -17,8 +17,6 @@ ad799x-y := ad799x_core.o
ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
obj-$(CONFIG_AD799X) += ad799x.o
-ad7476-y := ad7476_core.o
-ad7476-$(CONFIG_IIO_BUFFER) += ad7476_ring.o
obj-$(CONFIG_AD7476) += ad7476.o
ad7887-y := ad7887_core.o
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476.c
similarity index 73%
rename from drivers/staging/iio/adc/ad7476_core.c
rename to drivers/staging/iio/adc/ad7476.c
index 42523e6..13aed0e 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476.c
@@ -18,8 +18,88 @@
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+
+#define RES_MASK(bits) ((1 << (bits)) - 1)
+
+struct ad7476_chip_info {
+ unsigned int int_vref_uv;
+ struct iio_chan_spec channel[2];
+};
+
+struct ad7476_state {
+ struct spi_device *spi;
+ const struct ad7476_chip_info *chip_info;
+ struct regulator *reg;
+ struct spi_transfer xfer;
+ struct spi_message msg;
+ /*
+ * DMA (thus cache coherency maintenance) requires the
+ * transfer buffers to live in their own cache lines.
+ * Make the buffer large enough for one 16 bit sample and one 64 bit
+ * aligned 64 bit timestamp.
+ */
+ unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
+ ____cacheline_aligned;
+};
+
+enum ad7476_supported_device_ids {
+ ID_AD7466,
+ ID_AD7467,
+ ID_AD7468,
+ ID_AD7495
+};
+
+#if IS_ENABLED(CONFIG_IIO_BUFFER)
+
+static irqreturn_t ad7476_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct ad7476_state *st = iio_priv(indio_dev);
+ s64 time_ns;
+ int b_sent;
+
+ b_sent = spi_read(st->spi, st->data,
+ st->chip_info->channel[0].scan_type.storagebits / 8);
+ if (b_sent < 0)
+ goto done;
+
+ time_ns = iio_get_time_ns();
+
+ if (indio_dev->scan_timestamp)
+ ((s64 *)st->data)[1] = time_ns;
+
+ iio_push_to_buffer(indio_dev->buffer, st->data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
+
+ return IRQ_HANDLED;
+}
+
+static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
+{
+ return iio_triggered_buffer_setup(indio_dev, NULL,
+ &ad7476_trigger_handler, NULL);
+}
+
+static void ad7476_ring_cleanup(struct iio_dev *indio_dev)
+{
+ iio_triggered_buffer_cleanup(indio_dev);
+}
+
+#else
+
+static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
+{
+ return 0;
+}
+
+static void ad7476_ring_cleanup(struct iio_dev *indio_dev) {}
+
+#endif
-#include "ad7476.h"
static int ad7476_scan_direct(struct ad7476_state *st)
{
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
deleted file mode 100644
index 4ed5494..0000000
--- a/drivers/staging/iio/adc/ad7476.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * AD7476/5/7/8 (A) SPI ADC driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-#ifndef IIO_ADC_AD7476_H_
-#define IIO_ADC_AD7476_H_
-
-#define RES_MASK(bits) ((1 << (bits)) - 1)
-
-struct ad7476_chip_info {
- unsigned int int_vref_uv;
- struct iio_chan_spec channel[2];
-};
-
-struct ad7476_state {
- struct spi_device *spi;
- const struct ad7476_chip_info *chip_info;
- struct regulator *reg;
- struct spi_transfer xfer;
- struct spi_message msg;
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- * Make the buffer large enough for one 16 bit sample and one 64 bit
- * aligned 64 bit timestamp.
- */
- unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
- ____cacheline_aligned;
-};
-
-enum ad7476_supported_device_ids {
- ID_AD7466,
- ID_AD7467,
- ID_AD7468,
- ID_AD7495
-};
-
-#ifdef CONFIG_IIO_BUFFER
-int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
-void ad7476_ring_cleanup(struct iio_dev *indio_dev);
-#else /* CONFIG_IIO_BUFFER */
-
-static inline int
-ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
-static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
-{
-}
-#endif /* CONFIG_IIO_BUFFER */
-#endif /* IIO_ADC_AD7476_H_ */
diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
deleted file mode 100644
index 185cfde..0000000
--- a/drivers/staging/iio/adc/ad7476_ring.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2010-2012 Analog Devices Inc.
- * Copyright (C) 2008 Jonathan Cameron
- *
- * Licensed under the GPL-2 or later.
- *
- * ad7476_ring.c
- */
-
-#include <linux/interrupt.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/spi/spi.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/trigger_consumer.h>
-#include <linux/iio/triggered_buffer.h>
-
-#include "ad7476.h"
-
-static irqreturn_t ad7476_trigger_handler(int irq, void *p)
-{
- struct iio_poll_func *pf = p;
- struct iio_dev *indio_dev = pf->indio_dev;
- struct ad7476_state *st = iio_priv(indio_dev);
- s64 time_ns;
- int b_sent;
-
- b_sent = spi_read(st->spi, st->data,
- st->chip_info->channel[0].scan_type.storagebits / 8);
- if (b_sent < 0)
- goto done;
-
- time_ns = iio_get_time_ns();
-
- if (indio_dev->scan_timestamp)
- ((s64 *)st->data)[1] = time_ns;
-
- iio_push_to_buffer(indio_dev->buffer, st->data);
-done:
- iio_trigger_notify_done(indio_dev->trig);
-
- return IRQ_HANDLED;
-}
-
-int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
-{
- return iio_triggered_buffer_setup(indio_dev, NULL,
- &ad7476_trigger_handler, NULL);
-}
-
-void ad7476_ring_cleanup(struct iio_dev *indio_dev)
-{
- iio_triggered_buffer_cleanup(indio_dev);
-}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file.
2012-09-07 12:44 ` [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file Lars-Peter Clausen
@ 2012-09-08 9:47 ` Jonathan Cameron
2012-09-08 9:50 ` Jonathan Cameron
1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:47 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 01:44 PM, Lars-Peter Clausen wrote:
> After the recent cleanups the buffer support is just a single 23 line function.
> This does not really justify a file on its own, so move it to the main driver
> file. And with only one source file left the header file containing the device
> state struct becomes superflousious so move the content of the header
> file to the main driver source file as well.
>
A sensible change I think. Normally we do our best to keep all ifdefs in the
header, (and hence need the two files) but here the distinction is well
defined so I agree merging them all makes sense.
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/adc/Makefile | 2 -
> .../staging/iio/adc/{ad7476_core.c => ad7476.c} | 82 +++++++++++++++++++-
> drivers/staging/iio/adc/ad7476.h | 56 -------------
> drivers/staging/iio/adc/ad7476_ring.c | 57 --------------
> 4 files changed, 81 insertions(+), 116 deletions(-)
> rename drivers/staging/iio/adc/{ad7476_core.c => ad7476.c} (73%)
> delete mode 100644 drivers/staging/iio/adc/ad7476.h
> delete mode 100644 drivers/staging/iio/adc/ad7476_ring.c
>
> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
> index ecac9a0..6b60af0 100644
> --- a/drivers/staging/iio/adc/Makefile
> +++ b/drivers/staging/iio/adc/Makefile
> @@ -17,8 +17,6 @@ ad799x-y := ad799x_core.o
> ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
> obj-$(CONFIG_AD799X) += ad799x.o
>
> -ad7476-y := ad7476_core.o
> -ad7476-$(CONFIG_IIO_BUFFER) += ad7476_ring.o
> obj-$(CONFIG_AD7476) += ad7476.o
>
> ad7887-y := ad7887_core.o
> diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476.c
> similarity index 73%
> rename from drivers/staging/iio/adc/ad7476_core.c
> rename to drivers/staging/iio/adc/ad7476.c
> index 42523e6..13aed0e 100644
> --- a/drivers/staging/iio/adc/ad7476_core.c
> +++ b/drivers/staging/iio/adc/ad7476.c
> @@ -18,8 +18,88 @@
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> #include <linux/iio/buffer.h>
> +#include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/triggered_buffer.h>
> +
> +#define RES_MASK(bits) ((1 << (bits)) - 1)
> +
> +struct ad7476_chip_info {
> + unsigned int int_vref_uv;
> + struct iio_chan_spec channel[2];
> +};
> +
> +struct ad7476_state {
> + struct spi_device *spi;
> + const struct ad7476_chip_info *chip_info;
> + struct regulator *reg;
> + struct spi_transfer xfer;
> + struct spi_message msg;
> + /*
> + * DMA (thus cache coherency maintenance) requires the
> + * transfer buffers to live in their own cache lines.
> + * Make the buffer large enough for one 16 bit sample and one 64 bit
> + * aligned 64 bit timestamp.
> + */
> + unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
> + ____cacheline_aligned;
> +};
> +
> +enum ad7476_supported_device_ids {
> + ID_AD7466,
> + ID_AD7467,
> + ID_AD7468,
> + ID_AD7495
> +};
> +
> +#if IS_ENABLED(CONFIG_IIO_BUFFER)
> +
> +static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> +{
> + struct iio_poll_func *pf = p;
> + struct iio_dev *indio_dev = pf->indio_dev;
> + struct ad7476_state *st = iio_priv(indio_dev);
> + s64 time_ns;
> + int b_sent;
> +
> + b_sent = spi_read(st->spi, st->data,
> + st->chip_info->channel[0].scan_type.storagebits / 8);
> + if (b_sent < 0)
> + goto done;
> +
> + time_ns = iio_get_time_ns();
> +
> + if (indio_dev->scan_timestamp)
> + ((s64 *)st->data)[1] = time_ns;
> +
> + iio_push_to_buffer(indio_dev->buffer, st->data);
> +done:
> + iio_trigger_notify_done(indio_dev->trig);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> +{
> + return iio_triggered_buffer_setup(indio_dev, NULL,
> + &ad7476_trigger_handler, NULL);
> +}
> +
> +static void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> +{
> + iio_triggered_buffer_cleanup(indio_dev);
> +}
> +
> +#else
> +
> +static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> +{
> + return 0;
> +}
> +
> +static void ad7476_ring_cleanup(struct iio_dev *indio_dev) {}
> +
> +#endif
>
> -#include "ad7476.h"
>
> static int ad7476_scan_direct(struct ad7476_state *st)
> {
> diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
> deleted file mode 100644
> index 4ed5494..0000000
> --- a/drivers/staging/iio/adc/ad7476.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/*
> - * AD7476/5/7/8 (A) SPI ADC driver
> - *
> - * Copyright 2010 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later.
> - */
> -#ifndef IIO_ADC_AD7476_H_
> -#define IIO_ADC_AD7476_H_
> -
> -#define RES_MASK(bits) ((1 << (bits)) - 1)
> -
> -struct ad7476_chip_info {
> - unsigned int int_vref_uv;
> - struct iio_chan_spec channel[2];
> -};
> -
> -struct ad7476_state {
> - struct spi_device *spi;
> - const struct ad7476_chip_info *chip_info;
> - struct regulator *reg;
> - struct spi_transfer xfer;
> - struct spi_message msg;
> - /*
> - * DMA (thus cache coherency maintenance) requires the
> - * transfer buffers to live in their own cache lines.
> - * Make the buffer large enough for one 16 bit sample and one 64 bit
> - * aligned 64 bit timestamp.
> - */
> - unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
> - ____cacheline_aligned;
> -};
> -
> -enum ad7476_supported_device_ids {
> - ID_AD7466,
> - ID_AD7467,
> - ID_AD7468,
> - ID_AD7495
> -};
> -
> -#ifdef CONFIG_IIO_BUFFER
> -int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
> -void ad7476_ring_cleanup(struct iio_dev *indio_dev);
> -#else /* CONFIG_IIO_BUFFER */
> -
> -static inline int
> -ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> -{
> - return 0;
> -}
> -
> -static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> -{
> -}
> -#endif /* CONFIG_IIO_BUFFER */
> -#endif /* IIO_ADC_AD7476_H_ */
> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
> deleted file mode 100644
> index 185cfde..0000000
> --- a/drivers/staging/iio/adc/ad7476_ring.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/*
> - * Copyright 2010-2012 Analog Devices Inc.
> - * Copyright (C) 2008 Jonathan Cameron
> - *
> - * Licensed under the GPL-2 or later.
> - *
> - * ad7476_ring.c
> - */
> -
> -#include <linux/interrupt.h>
> -#include <linux/device.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -#include <linux/spi/spi.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/buffer.h>
> -#include <linux/iio/trigger_consumer.h>
> -#include <linux/iio/triggered_buffer.h>
> -
> -#include "ad7476.h"
> -
> -static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> -{
> - struct iio_poll_func *pf = p;
> - struct iio_dev *indio_dev = pf->indio_dev;
> - struct ad7476_state *st = iio_priv(indio_dev);
> - s64 time_ns;
> - int b_sent;
> -
> - b_sent = spi_read(st->spi, st->data,
> - st->chip_info->channel[0].scan_type.storagebits / 8);
> - if (b_sent < 0)
> - goto done;
> -
> - time_ns = iio_get_time_ns();
> -
> - if (indio_dev->scan_timestamp)
> - ((s64 *)st->data)[1] = time_ns;
> -
> - iio_push_to_buffer(indio_dev->buffer, st->data);
> -done:
> - iio_trigger_notify_done(indio_dev->trig);
> -
> - return IRQ_HANDLED;
> -}
> -
> -int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> -{
> - return iio_triggered_buffer_setup(indio_dev, NULL,
> - &ad7476_trigger_handler, NULL);
> -}
> -
> -void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> -{
> - iio_triggered_buffer_cleanup(indio_dev);
> -}
>
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file.
2012-09-07 12:44 ` [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file Lars-Peter Clausen
2012-09-08 9:47 ` Jonathan Cameron
@ 2012-09-08 9:50 ` Jonathan Cameron
1 sibling, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:50 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 01:44 PM, Lars-Peter Clausen wrote:
> After the recent cleanups the buffer support is just a single 23 line function.
> This does not really justify a file on its own, so move it to the main driver
> file. And with only one source file left the header file containing the device
> state struct becomes superflousious so move the content of the header
> file to the main driver source file as well.
>
The move out of staging patch meant I looked at the kconfig entry.
This driver selects buffering anyway, so you don't need the ifdef magic..
Hence drop that in your next version making this patch obviously the correct
thing to do!
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/adc/Makefile | 2 -
> .../staging/iio/adc/{ad7476_core.c => ad7476.c} | 82 +++++++++++++++++++-
> drivers/staging/iio/adc/ad7476.h | 56 -------------
> drivers/staging/iio/adc/ad7476_ring.c | 57 --------------
> 4 files changed, 81 insertions(+), 116 deletions(-)
> rename drivers/staging/iio/adc/{ad7476_core.c => ad7476.c} (73%)
> delete mode 100644 drivers/staging/iio/adc/ad7476.h
> delete mode 100644 drivers/staging/iio/adc/ad7476_ring.c
>
> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
> index ecac9a0..6b60af0 100644
> --- a/drivers/staging/iio/adc/Makefile
> +++ b/drivers/staging/iio/adc/Makefile
> @@ -17,8 +17,6 @@ ad799x-y := ad799x_core.o
> ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
> obj-$(CONFIG_AD799X) += ad799x.o
>
> -ad7476-y := ad7476_core.o
> -ad7476-$(CONFIG_IIO_BUFFER) += ad7476_ring.o
> obj-$(CONFIG_AD7476) += ad7476.o
>
> ad7887-y := ad7887_core.o
> diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476.c
> similarity index 73%
> rename from drivers/staging/iio/adc/ad7476_core.c
> rename to drivers/staging/iio/adc/ad7476.c
> index 42523e6..13aed0e 100644
> --- a/drivers/staging/iio/adc/ad7476_core.c
> +++ b/drivers/staging/iio/adc/ad7476.c
> @@ -18,8 +18,88 @@
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> #include <linux/iio/buffer.h>
> +#include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/triggered_buffer.h>
> +
> +#define RES_MASK(bits) ((1 << (bits)) - 1)
> +
> +struct ad7476_chip_info {
> + unsigned int int_vref_uv;
> + struct iio_chan_spec channel[2];
> +};
> +
> +struct ad7476_state {
> + struct spi_device *spi;
> + const struct ad7476_chip_info *chip_info;
> + struct regulator *reg;
> + struct spi_transfer xfer;
> + struct spi_message msg;
> + /*
> + * DMA (thus cache coherency maintenance) requires the
> + * transfer buffers to live in their own cache lines.
> + * Make the buffer large enough for one 16 bit sample and one 64 bit
> + * aligned 64 bit timestamp.
> + */
> + unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
> + ____cacheline_aligned;
> +};
> +
> +enum ad7476_supported_device_ids {
> + ID_AD7466,
> + ID_AD7467,
> + ID_AD7468,
> + ID_AD7495
> +};
> +
> +#if IS_ENABLED(CONFIG_IIO_BUFFER)
> +
> +static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> +{
> + struct iio_poll_func *pf = p;
> + struct iio_dev *indio_dev = pf->indio_dev;
> + struct ad7476_state *st = iio_priv(indio_dev);
> + s64 time_ns;
> + int b_sent;
> +
> + b_sent = spi_read(st->spi, st->data,
> + st->chip_info->channel[0].scan_type.storagebits / 8);
> + if (b_sent < 0)
> + goto done;
> +
> + time_ns = iio_get_time_ns();
> +
> + if (indio_dev->scan_timestamp)
> + ((s64 *)st->data)[1] = time_ns;
> +
> + iio_push_to_buffer(indio_dev->buffer, st->data);
> +done:
> + iio_trigger_notify_done(indio_dev->trig);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> +{
> + return iio_triggered_buffer_setup(indio_dev, NULL,
> + &ad7476_trigger_handler, NULL);
> +}
> +
> +static void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> +{
> + iio_triggered_buffer_cleanup(indio_dev);
> +}
> +
> +#else
> +
> +static int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> +{
> + return 0;
> +}
> +
> +static void ad7476_ring_cleanup(struct iio_dev *indio_dev) {}
> +
> +#endif
>
> -#include "ad7476.h"
>
> static int ad7476_scan_direct(struct ad7476_state *st)
> {
> diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
> deleted file mode 100644
> index 4ed5494..0000000
> --- a/drivers/staging/iio/adc/ad7476.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/*
> - * AD7476/5/7/8 (A) SPI ADC driver
> - *
> - * Copyright 2010 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later.
> - */
> -#ifndef IIO_ADC_AD7476_H_
> -#define IIO_ADC_AD7476_H_
> -
> -#define RES_MASK(bits) ((1 << (bits)) - 1)
> -
> -struct ad7476_chip_info {
> - unsigned int int_vref_uv;
> - struct iio_chan_spec channel[2];
> -};
> -
> -struct ad7476_state {
> - struct spi_device *spi;
> - const struct ad7476_chip_info *chip_info;
> - struct regulator *reg;
> - struct spi_transfer xfer;
> - struct spi_message msg;
> - /*
> - * DMA (thus cache coherency maintenance) requires the
> - * transfer buffers to live in their own cache lines.
> - * Make the buffer large enough for one 16 bit sample and one 64 bit
> - * aligned 64 bit timestamp.
> - */
> - unsigned char data[ALIGN(2, sizeof(s64)) + sizeof(s64)]
> - ____cacheline_aligned;
> -};
> -
> -enum ad7476_supported_device_ids {
> - ID_AD7466,
> - ID_AD7467,
> - ID_AD7468,
> - ID_AD7495
> -};
> -
> -#ifdef CONFIG_IIO_BUFFER
> -int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
> -void ad7476_ring_cleanup(struct iio_dev *indio_dev);
> -#else /* CONFIG_IIO_BUFFER */
> -
> -static inline int
> -ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> -{
> - return 0;
> -}
> -
> -static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> -{
> -}
> -#endif /* CONFIG_IIO_BUFFER */
> -#endif /* IIO_ADC_AD7476_H_ */
> diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
> deleted file mode 100644
> index 185cfde..0000000
> --- a/drivers/staging/iio/adc/ad7476_ring.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/*
> - * Copyright 2010-2012 Analog Devices Inc.
> - * Copyright (C) 2008 Jonathan Cameron
> - *
> - * Licensed under the GPL-2 or later.
> - *
> - * ad7476_ring.c
> - */
> -
> -#include <linux/interrupt.h>
> -#include <linux/device.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -#include <linux/spi/spi.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/buffer.h>
> -#include <linux/iio/trigger_consumer.h>
> -#include <linux/iio/triggered_buffer.h>
> -
> -#include "ad7476.h"
> -
> -static irqreturn_t ad7476_trigger_handler(int irq, void *p)
> -{
> - struct iio_poll_func *pf = p;
> - struct iio_dev *indio_dev = pf->indio_dev;
> - struct ad7476_state *st = iio_priv(indio_dev);
> - s64 time_ns;
> - int b_sent;
> -
> - b_sent = spi_read(st->spi, st->data,
> - st->chip_info->channel[0].scan_type.storagebits / 8);
> - if (b_sent < 0)
> - goto done;
> -
> - time_ns = iio_get_time_ns();
> -
> - if (indio_dev->scan_timestamp)
> - ((s64 *)st->data)[1] = time_ns;
> -
> - iio_push_to_buffer(indio_dev->buffer, st->data);
> -done:
> - iio_trigger_notify_done(indio_dev->trig);
> -
> - return IRQ_HANDLED;
> -}
> -
> -int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
> -{
> - return iio_triggered_buffer_setup(indio_dev, NULL,
> - &ad7476_trigger_handler, NULL);
> -}
> -
> -void ad7476_ring_cleanup(struct iio_dev *indio_dev)
> -{
> - iio_triggered_buffer_cleanup(indio_dev);
> -}
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 06/10] staging:iio:ad7476: Use be16_to_cpup instead of open-coding it
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (3 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 05/10] staging:iio:ad7476: Squash driver into a single file Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 07/10] iio: Move ad7476 driver out of staging Lars-Peter Clausen
` (4 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7476.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/adc/ad7476.c b/drivers/staging/iio/adc/ad7476.c
index 13aed0e..845bd28 100644
--- a/drivers/staging/iio/adc/ad7476.c
+++ b/drivers/staging/iio/adc/ad7476.c
@@ -109,7 +109,7 @@ static int ad7476_scan_direct(struct ad7476_state *st)
if (ret)
return ret;
- return (st->data[0] << 8) | st->data[1];
+ return be16_to_cpup((__be16 *)st->data);
}
static int ad7476_read_raw(struct iio_dev *indio_dev,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 07/10] iio: Move ad7476 driver out of staging
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (4 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 06/10] staging:iio:ad7476: Use be16_to_cpup instead of open-coding it Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 08/10] iio:ad7476: Add ad7910/ad7920 device table entries Lars-Peter Clausen
` (3 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
The ad7476 driver is a driver for simple single channel ADCs. The driver does
not export any experimental or custom ABI files nor do the static code check
tools report any issues, so move the driver out of staging.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/adc/Kconfig | 14 ++++++++++++++
drivers/iio/adc/Makefile | 1 +
drivers/{staging => }/iio/adc/ad7476.c | 0
drivers/staging/iio/adc/Kconfig | 14 --------------
drivers/staging/iio/adc/Makefile | 2 --
5 files changed, 15 insertions(+), 16 deletions(-)
rename drivers/{staging => }/iio/adc/ad7476.c (100%)
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a2c5071..260e20b 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -18,6 +18,20 @@ config AD7266
Say yes here to build support for Analog Devices AD7265 and AD7266
ADCs.
+config AD7476
+ tristate "Analog Devices AD7475/6/7/8 AD7466/7/8 and AD7495 ADC driver"
+ depends on SPI
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ help
+ Say yes here to build support for Analog Devices
+ AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, AD7495
+ SPI analog to digital converters (ADC).
+ If unsure, say N (but it's safe to say "Y").
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad7476.
+
config AT91_ADC
tristate "Atmel AT91 ADC"
depends on ARCH_AT91
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 5989356..17a60a8 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -4,4 +4,5 @@
obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o
obj-$(CONFIG_AD7266) += ad7266.o
+obj-$(CONFIG_AD7476) += ad7476.o
obj-$(CONFIG_AT91_ADC) += at91_adc.o
diff --git a/drivers/staging/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
similarity index 100%
rename from drivers/staging/iio/adc/ad7476.c
rename to drivers/iio/adc/ad7476.c
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index a1fa172..1b4a356 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -68,20 +68,6 @@ config AD799X_RING_BUFFER
Say yes here to include ring buffer support in the AD799X
ADC driver.
-config AD7476
- tristate "Analog Devices AD7475/6/7/8 AD7466/7/8 and AD7495 ADC driver"
- depends on SPI
- select IIO_BUFFER
- select IIO_TRIGGERED_BUFFER
- help
- Say yes here to build support for Analog Devices
- AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, AD7495
- SPI analog to digital converters (ADC).
- If unsure, say N (but it's safe to say "Y").
-
- To compile this driver as a module, choose M here: the
- module will be called ad7476.
-
config AD7887
tristate "Analog Devices AD7887 ADC driver"
depends on SPI
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index 6b60af0..62ee02e 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -17,8 +17,6 @@ ad799x-y := ad799x_core.o
ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
obj-$(CONFIG_AD799X) += ad799x.o
-obj-$(CONFIG_AD7476) += ad7476.o
-
ad7887-y := ad7887_core.o
ad7887-$(CONFIG_IIO_BUFFER) += ad7887_ring.o
obj-$(CONFIG_AD7887) += ad7887.o
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 08/10] iio:ad7476: Add ad7910/ad7920 device table entries
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (5 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 07/10] iio: Move ad7476 driver out of staging Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 09/10] iio:ad7476: Add ad7940 support Lars-Peter Clausen
` (2 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
The ad7910/ad7920 are software compatible to the ad7467/ad7466.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/adc/Kconfig | 9 +++++----
drivers/iio/adc/ad7476.c | 4 +++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 260e20b..364d2d7 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -19,14 +19,15 @@ config AD7266
ADCs.
config AD7476
- tristate "Analog Devices AD7475/6/7/8 AD7466/7/8 and AD7495 ADC driver"
+ tristate "Analog Devices AD7476 and similar 1-channel ADCs driver"
depends on SPI
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
- Say yes here to build support for Analog Devices
- AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, AD7495
- SPI analog to digital converters (ADC).
+ Say yes here to build support for Analog Devices AD7475, AD7476, AD7477,
+ AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920 SPI analog to
+ digital converters (ADC).
+
If unsure, say N (but it's safe to say "Y").
To compile this driver as a module, choose M here: the
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 845bd28..1c7ae6f 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -282,6 +282,8 @@ static const struct spi_device_id ad7476_id[] = {
{"ad7478", ID_AD7468},
{"ad7478a", ID_AD7468},
{"ad7495", ID_AD7495},
+ {"ad7910", ID_AD7467},
+ {"ad7920", ID_AD7466},
{}
};
MODULE_DEVICE_TABLE(spi, ad7476_id);
@@ -298,5 +300,5 @@ static struct spi_driver ad7476_driver = {
module_spi_driver(ad7476_driver);
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD7475/6/7/8(A) AD7466/7/8 ADC");
+MODULE_DESCRIPTION("Analog Devices AD7476 and similar 1-channel ADCs");
MODULE_LICENSE("GPL v2");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 09/10] iio:ad7476: Add ad7940 support
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (6 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 08/10] iio:ad7476: Add ad7910/ad7920 device table entries Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-07 12:44 ` [PATCH 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278 Lars-Peter Clausen
2012-09-08 9:36 ` [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Jonathan Cameron
9 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
The AD7940 is a single channel 14 bit ADC similar to the ADCs already supported
by the ad7476 driver, but it does have a different shift factor.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/adc/Kconfig | 4 ++--
drivers/iio/adc/ad7476.c | 18 ++++++++++++++----
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 364d2d7..7152a49 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -25,8 +25,8 @@ config AD7476
select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices AD7475, AD7476, AD7477,
- AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920 SPI analog to
- digital converters (ADC).
+ AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920, AD7920 SPI analog
+ to digital converters (ADC).
If unsure, say N (but it's safe to say "Y").
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 1c7ae6f..646df45 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -48,7 +48,8 @@ enum ad7476_supported_device_ids {
ID_AD7466,
ID_AD7467,
ID_AD7468,
- ID_AD7495
+ ID_AD7495,
+ ID_AD7940,
};
#if IS_ENABLED(CONFIG_IIO_BUFFER)
@@ -152,7 +153,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}
-#define AD7476_CHAN(bits) \
+#define _AD7476_CHAN(bits, _shift) \
{ \
.type = IIO_VOLTAGE, \
.indexed = 1, \
@@ -160,12 +161,16 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.scan_type = { \
.sign = 'u', \
- .realbits = bits, \
+ .realbits = (bits), \
.storagebits = 16, \
- .shift = 13 - bits, \
+ .shift = (_shift), \
+ .endianness = IIO_BE, \
}, \
}
+#define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits))
+#define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits))
+
static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
[ID_AD7466] = {
.channel[0] = AD7476_CHAN(12),
@@ -184,6 +189,10 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
.int_vref_uv = 2500000,
},
+ [ID_AD7940] = {
+ .channel[0] = AD7940_CHAN(14),
+ .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
+ },
};
static const struct iio_info ad7476_info = {
@@ -284,6 +293,7 @@ static const struct spi_device_id ad7476_id[] = {
{"ad7495", ID_AD7495},
{"ad7910", ID_AD7467},
{"ad7920", ID_AD7466},
+ {"ad7940", ID_AD7940},
{}
};
MODULE_DEVICE_TABLE(spi, ad7476_id);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (7 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 09/10] iio:ad7476: Add ad7940 support Lars-Peter Clausen
@ 2012-09-07 12:44 ` Lars-Peter Clausen
2012-09-08 9:57 ` Jonathan Cameron
2012-09-08 9:36 ` [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Jonathan Cameron
9 siblings, 1 reply; 20+ messages in thread
From: Lars-Peter Clausen @ 2012-09-07 12:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, drivers, Lars-Peter Clausen
The ad7276/ad7277/ad7278 are similar to the ad7476/ad7477/ad7478 but have the
same number of leading zeros as the ad7940. The ad7274/ad7275 have a extra pin
for VREF where as for the ad7276/ad7277/ad7278 VREF is taken from VDD, but
otherwise they are compatible to the ad7276/ad7277.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/adc/Kconfig | 6 +++---
drivers/iio/adc/ad7476.c | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 7152a49..645c052 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -24,9 +24,9 @@ config AD7476
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
- Say yes here to build support for Analog Devices AD7475, AD7476, AD7477,
- AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920, AD7920 SPI analog
- to digital converters (ADC).
+ Say yes here to build support for Analog Devices AD7274, AD7275, AD7276,
+ AD7277, AD7278, AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468,
+ AD7495, AD7910, AD7920, AD7920 SPI analog to digital converters (ADC).
If unsure, say N (but it's safe to say "Y").
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 646df45..8c7e206 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -45,6 +45,9 @@ struct ad7476_state {
};
enum ad7476_supported_device_ids {
+ ID_AD7276,
+ ID_AD7277,
+ ID_AD7278,
ID_AD7466,
ID_AD7467,
ID_AD7468,
@@ -172,6 +175,18 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
#define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits))
static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
+ [ID_AD7276] = {
+ .channel[0] = AD7940_CHAN(12),
+ .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
+ },
+ [ID_AD7277] = {
+ .channel[0] = AD7940_CHAN(10),
+ .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
+ },
+ [ID_AD7278] = {
+ .channel[0] = AD7940_CHAN(8),
+ .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
+ },
[ID_AD7466] = {
.channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
@@ -280,6 +295,11 @@ static int __devexit ad7476_remove(struct spi_device *spi)
}
static const struct spi_device_id ad7476_id[] = {
+ {"ad7274", ID_AD7276},
+ {"ad7275", ID_AD7277},
+ {"ad7276", ID_AD7276},
+ {"ad7277", ID_AD7277},
+ {"ad7278", ID_AD7278},
{"ad7466", ID_AD7466},
{"ad7467", ID_AD7467},
{"ad7468", ID_AD7468},
--
1.7.10.4
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278
2012-09-07 12:44 ` [PATCH 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278 Lars-Peter Clausen
@ 2012-09-08 9:57 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:57 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 01:44 PM, Lars-Peter Clausen wrote:
> The ad7276/ad7277/ad7278 are similar to the ad7476/ad7477/ad7478 but have the
> same number of leading zeros as the ad7940. The ad7274/ad7275 have a extra pin
> for VREF where as for the ad7276/ad7277/ad7278 VREF is taken from VDD, but
> otherwise they are compatible to the ad7276/ad7277.
>
This and all the other patches I haven't commented on look fine to me.
Looking forward to the updated series.
Hehe. You did a much better job of reviewing your own patches than I did ;)
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/iio/adc/Kconfig | 6 +++---
> drivers/iio/adc/ad7476.c | 20 ++++++++++++++++++++
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 7152a49..645c052 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -24,9 +24,9 @@ config AD7476
> select IIO_BUFFER
> select IIO_TRIGGERED_BUFFER
> help
> - Say yes here to build support for Analog Devices AD7475, AD7476, AD7477,
> - AD7478, AD7466, AD7467, AD7468, AD7495, AD7910, AD7920, AD7920 SPI analog
> - to digital converters (ADC).
> + Say yes here to build support for Analog Devices AD7274, AD7275, AD7276,
> + AD7277, AD7278, AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468,
> + AD7495, AD7910, AD7920, AD7920 SPI analog to digital converters (ADC).
>
> If unsure, say N (but it's safe to say "Y").
>
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index 646df45..8c7e206 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -45,6 +45,9 @@ struct ad7476_state {
> };
>
> enum ad7476_supported_device_ids {
> + ID_AD7276,
> + ID_AD7277,
> + ID_AD7278,
> ID_AD7466,
> ID_AD7467,
> ID_AD7468,
> @@ -172,6 +175,18 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
> #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits))
>
> static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
> + [ID_AD7276] = {
> + .channel[0] = AD7940_CHAN(12),
> + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
> + },
> + [ID_AD7277] = {
> + .channel[0] = AD7940_CHAN(10),
> + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
> + },
> + [ID_AD7278] = {
> + .channel[0] = AD7940_CHAN(8),
> + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
> + },
> [ID_AD7466] = {
> .channel[0] = AD7476_CHAN(12),
> .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
> @@ -280,6 +295,11 @@ static int __devexit ad7476_remove(struct spi_device *spi)
> }
>
> static const struct spi_device_id ad7476_id[] = {
> + {"ad7274", ID_AD7276},
> + {"ad7275", ID_AD7277},
> + {"ad7276", ID_AD7276},
> + {"ad7277", ID_AD7277},
> + {"ad7278", ID_AD7278},
> {"ad7466", ID_AD7466},
> {"ad7467", ID_AD7467},
> {"ad7468", ID_AD7468},
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift
2012-09-07 12:44 [PATCH 01/10] staging:iio:ad7476: Fix off by one error for channel shift Lars-Peter Clausen
` (8 preceding siblings ...)
2012-09-07 12:44 ` [PATCH 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278 Lars-Peter Clausen
@ 2012-09-08 9:36 ` Jonathan Cameron
9 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2012-09-08 9:36 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, drivers
On 09/07/2012 01:44 PM, Lars-Peter Clausen wrote:
> The datasheet is a bit confusing about this. It says that a dataword has 4
> leading zeros, but the first zero is already put on the bus when CS is pulled
> low and the second zero is put on the bus on the first leading edge of SCLK, so
> when the first bit is sampled on the first trailing edge it will sample what the
> datasheet refers to as the second leading zero. Subsequently we only see 3
> leading zeros in the 16 bit dataword and the result we get is shifted to the
> left by one bit. Fix this by adjusting the channel shift by 1.
>
I'll take your word for it :)
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/adc/ad7476_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
> index 4f6d59e..33435ed 100644
> --- a/drivers/staging/iio/adc/ad7476_core.c
> +++ b/drivers/staging/iio/adc/ad7476_core.c
> @@ -76,7 +76,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
> .sign = 'u', \
> .realbits = bits, \
> .storagebits = 16, \
> - .shift = 12 - bits, \
> + .shift = 13 - bits, \
> }, \
> }
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread