All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] staging:iio:adc cleanups / fixes.
@ 2011-09-23 12:01 Jonathan Cameron
  2011-09-23 12:01 ` [PATCH 01/16] staging:iio:adc:ad799x fix incorrect scan_type descriptions Jonathan Cameron
                   ` (17 more replies)
  0 siblings, 18 replies; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Hi Michael,

Result of doing a careful review of these fundamentally clean
drivers.  A few actual bug fixes and quite a few cases of moving
to prefered means of doing things (not using IIO_CHAN for starters).

Please look over these as I may well have 'cleaned' things into
not working.  Only functional changes beyond bug fixes are that
we now have event _en attributes for the ad799x (read only and always
equal to 1) and what happens with gpio request failures has changed
in the ad7606.

Thanks,

Jonathan

Jonathan Cameron (16):
  staging:iio:adc:ad799x fix incorrect scan_type descriptions.
  staging:iio:adc:ad799x stop using IIO_CHAN macro.
  staging:iio:adc:ad799x fix incorrect setting of configuration
    register on single channel read.
  staging:iio:adc:ad799x trivial: use the convenient chan struct.
  staging:iio:adc:ad799x use a table for frequency values rather than
    big switch.
  staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv
    space.
  staging:iio:adc:ad799x use the core handling for as much of the
    events as possible.
  staging:iio:adc:ad799x set the device name only once.
  staging:iio:adc:ad799x address and scan_index always match so stop
    using address
  staging:iio:adc:ad7606 add local define for chan_spec structures.
  staging:iio:adc:ad7606 trivial code style fix.
  staging:iio:adc:ad7606 make gpio request failures more consistent
  staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local
    equiv
  staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
  staging:iio:adc:ad7606 remove unused chip info elements.
  staging:iio:adc:ad7887 stop using IIO_CHAN macro.

 drivers/staging/iio/adc/ad7606.h      |   12 +-
 drivers/staging/iio/adc/ad7606_core.c |  226 ++++++------
 drivers/staging/iio/adc/ad7606_par.c  |    2 +-
 drivers/staging/iio/adc/ad7606_ring.c |   44 +--
 drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
 drivers/staging/iio/adc/ad7887_core.c |   26 +-
 drivers/staging/iio/adc/ad799x.h      |    4 +-
 drivers/staging/iio/adc/ad799x_core.c |  645 ++++++++++++++++++++-------------
 drivers/staging/iio/adc/ad799x_ring.c |    4 +-
 9 files changed, 546 insertions(+), 419 deletions(-)

-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/16] staging:iio:adc:ad799x fix incorrect scan_type descriptions.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-23 12:01 ` [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro Jonathan Cameron
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

A few of these had the wrong shifts, which would lead to
userspace hacking off the top couple of bits.  Also, one
part had the wrong accuracy.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/staging/iio/adc/ad799x_core.c |   40 ++++++++++++++++----------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index b6662db..58f70aa 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -506,16 +506,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7995] = {
 		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 10, 16, 0), 0),
+				       0, 0, IIO_ST('u', 10, 16, 2), 0),
 		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 10, 16, 0), 0),
+				       1, 1, IIO_ST('u', 10, 16, 2), 0),
 		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 10, 16, 0), 0),
+				       2, 2, IIO_ST('u', 10, 16, 2), 0),
 		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 10, 16, 0), 0),
+				       3, 3, IIO_ST('u', 10, 16, 2), 0),
 		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
 		.num_channels = 5,
 		.int_vref_mv = 1024,
@@ -524,16 +524,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7999] = {
 		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 10, 16, 0), 0),
+				       0, 0, IIO_ST('u', 8, 16, 4), 0),
 		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 10, 16, 0), 0),
+				       1, 1, IIO_ST('u', 8, 16, 4), 0),
 		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 10, 16, 0), 0),
+				       2, 2, IIO_ST('u', 8, 16, 4), 0),
 		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 10, 16, 0), 0),
+				       3, 3, IIO_ST('u', 8, 16, 4), 0),
 		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
 		.num_channels = 5,
 		.int_vref_mv = 1024,
@@ -555,16 +555,16 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7993] = {
 		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 10, 16, 0), 0),
+				       0, 0, IIO_ST('u', 10, 16, 2), 0),
 		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 10, 16, 0), 0),
+				       1, 1, IIO_ST('u', 10, 16, 2), 0),
 		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 10, 16, 0), 0),
+				       2, 2, IIO_ST('u', 10, 16, 2), 0),
 		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
 				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 10, 16, 0), 0),
+				       3, 3, IIO_ST('u', 10, 16, 2), 0),
 		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
 		.num_channels = 5,
 		.int_vref_mv = 1024,
@@ -593,28 +593,28 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7997] = {
 		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  0, 0, IIO_ST('u', 10, 16, 0), 0),
+					  0, 0, IIO_ST('u', 10, 16, 2), 0),
 		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  1, 1, IIO_ST('u', 10, 16, 0), 0),
+					  1, 1, IIO_ST('u', 10, 16, 2), 0),
 		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  2, 2, IIO_ST('u', 10, 16, 0), 0),
+					  2, 2, IIO_ST('u', 10, 16, 2), 0),
 		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  3, 3, IIO_ST('u', 10, 16, 0), 0),
+					  3, 3, IIO_ST('u', 10, 16, 2), 0),
 		.channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  4, 4, IIO_ST('u', 10, 16, 0), 0),
+					  4, 4, IIO_ST('u', 10, 16, 2), 0),
 		.channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  5, 5, IIO_ST('u', 10, 16, 0), 0),
+					  5, 5, IIO_ST('u', 10, 16, 2), 0),
 		.channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  6, 6, IIO_ST('u', 10, 16, 0), 0),
+					  6, 6, IIO_ST('u', 10, 16, 2), 0),
 		.channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
 					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  7, 7, IIO_ST('u', 10, 16, 0), 0),
+					  7, 7, IIO_ST('u', 10, 16, 2), 0),
 		.channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
 		.num_channels = 9,
 		.int_vref_mv = 1024,
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
  2011-09-23 12:01 ` [PATCH 01/16] staging:iio:adc:ad799x fix incorrect scan_type descriptions Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:40   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read Jonathan Cameron
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Preparation for moving driver out of staging.
That macro is a nightmare to maintain so it is going away.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |  452 ++++++++++++++++++++++++---------
 1 files changed, 329 insertions(+), 123 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 58f70aa..975a3f7 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -151,7 +151,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info,
 		mutex_lock(&dev_info->mlock);
 		if (iio_buffer_enabled(dev_info))
 			ret = ad799x_single_channel_from_ring(st,
-							      chan->address);
+							      chan->scan_index);
 		else
 			ret = ad799x_scan_direct(st, chan->address);
 		mutex_unlock(&dev_info->mlock);
@@ -486,167 +486,373 @@ static const struct iio_info ad7993_4_7_8_info = {
 
 static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7991] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 12, 16, 0), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 12, 16, 0), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 12, 16, 0), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 12, 16, 0), 0),
-		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		},
 		.num_channels = 5,
 		.int_vref_mv = 4096,
 		.info = &ad7991_info,
 	},
 	[ad7995] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 10, 16, 2), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 10, 16, 2), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 10, 16, 2), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 10, 16, 2), 0),
-		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		},
 		.num_channels = 5,
 		.int_vref_mv = 1024,
 		.info = &ad7991_info,
 	},
 	[ad7999] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 8, 16, 4), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 8, 16, 4), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 8, 16, 4), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 8, 16, 4), 0),
-		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 8, 16, 4),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 8, 16, 4),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 8, 16, 4),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 8, 16, 4),
+			},
+			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		},
 		.num_channels = 5,
 		.int_vref_mv = 1024,
 		.info = &ad7991_info,
 	},
 	[ad7992] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 12, 16, 0), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 12, 16, 0), 0),
-		.channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
+		},
 		.num_channels = 3,
 		.int_vref_mv = 4096,
 		.default_config = AD7998_ALERT_EN,
 		.info = &ad7992_info,
 	},
 	[ad7993] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 10, 16, 2), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 10, 16, 2), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 10, 16, 2), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 10, 16, 2), 0),
-		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		},
 		.num_channels = 5,
 		.int_vref_mv = 1024,
 		.default_config = AD7998_ALERT_EN,
 		.info = &ad7993_4_7_8_info,
 	},
 	[ad7994] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 12, 16, 0), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 12, 16, 0), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 12, 16, 0), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 12, 16, 0), 0),
-		.channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+		},
 		.num_channels = 5,
 		.int_vref_mv = 4096,
 		.default_config = AD7998_ALERT_EN,
 		.info = &ad7993_4_7_8_info,
 	},
 	[ad7997] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  0, 0, IIO_ST('u', 10, 16, 2), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  1, 1, IIO_ST('u', 10, 16, 2), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  2, 2, IIO_ST('u', 10, 16, 2), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  3, 3, IIO_ST('u', 10, 16, 2), 0),
-		.channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  4, 4, IIO_ST('u', 10, 16, 2), 0),
-		.channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  5, 5, IIO_ST('u', 10, 16, 2), 0),
-		.channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  6, 6, IIO_ST('u', 10, 16, 2), 0),
-		.channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  7, 7, IIO_ST('u', 10, 16, 2), 0),
-		.channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[4] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 4,
+				.address = 4,
+				.scan_index = 4,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[5] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 5,
+				.address = 5,
+				.scan_index = 5,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[6] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 6,
+				.address = 6,
+				.scan_index = 6,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[7] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 7,
+				.address = 7,
+				.scan_index = 7,
+				.scan_type = IIO_ST('u', 10, 16, 2),
+			},
+			[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+		},
 		.num_channels = 9,
 		.int_vref_mv = 1024,
 		.default_config = AD7998_ALERT_EN,
 		.info = &ad7993_4_7_8_info,
 	},
 	[ad7998] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 12, 16, 0), 0),
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 12, 16, 0), 0),
-		.channel[2] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       2, 2, IIO_ST('u', 12, 16, 0), 0),
-		.channel[3] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       3, 3, IIO_ST('u', 12, 16, 0), 0),
-		.channel[4] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       4, 4, IIO_ST('u', 12, 16, 0), 0),
-		.channel[5] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       5, 5, IIO_ST('u', 12, 16, 0), 0),
-		.channel[6] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       6, 6, IIO_ST('u', 12, 16, 0), 0),
-		.channel[7] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
-					  (1 << IIO_CHAN_INFO_SCALE_SHARED),
-					  7, 7, IIO_ST('u', 12, 16, 0), 0),
-		.channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+		.channel = {
+			[0] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 0,
+				.address = 0,
+				.scan_index = 0,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[1] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 1,
+				.address = 1,
+				.scan_index = 1,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[2] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 2,
+				.address = 2,
+				.scan_index = 2,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[3] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 3,
+				.address = 3,
+				.scan_index = 3,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[4] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 4,
+				.address = 4,
+				.scan_index = 4,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[5] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 5,
+				.address = 5,
+				.scan_index = 5,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[6] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 6,
+				.address = 6,
+				.scan_index = 6,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[7] = {
+				.type = IIO_VOLTAGE,
+				.indexed = 1,
+				.channel = 7,
+				.address = 7,
+				.scan_index = 7,
+				.scan_type = IIO_ST('u', 12, 16, 0),
+			},
+			[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+		},
 		.num_channels = 9,
 		.int_vref_mv = 4096,
 		.default_config = AD7998_ALERT_EN,
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
  2011-09-23 12:01 ` [PATCH 01/16] staging:iio:adc:ad799x fix incorrect scan_type descriptions Jonathan Cameron
  2011-09-23 12:01 ` [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:24   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct Jonathan Cameron
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

It is a bit mask whereas current code treats it as a straight value.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 975a3f7..3b5f8be 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -123,7 +123,8 @@ static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch)
 		break;
 	case ad7997:
 	case ad7998:
-		cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE;
+		cmd = ((1 << ch) << AD799X_CHANNEL_SHIFT) |
+			AD7997_8_READ_SINGLE;
 		break;
 	default:
 		return -EINVAL;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (2 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:32   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch Jonathan Cameron
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

This is much cleaner than bouncing through the various structures
to get to the same thing.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 3b5f8be..517cbd9 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -159,12 +159,11 @@ static int ad799x_read_raw(struct iio_dev *dev_info,
 
 		if (ret < 0)
 			return ret;
-		*val = (ret >> st->chip_info->channel[0].scan_type.shift) &
-			RES_MASK(st->chip_info->channel[0].scan_type.realbits);
+		*val = (ret >> chan->scan_type.shift) &
+			RES_MASK(chan->scan_type.realbits);
 		return IIO_VAL_INT;
 	case (1 << IIO_CHAN_INFO_SCALE_SHARED):
-		scale_uv = (st->int_vref_mv * 1000)
-			>> st->chip_info->channel[0].scan_type.realbits;
+		scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits;
 		*val =  scale_uv / 1000;
 		*val2 = (scale_uv % 1000) * 1000;
 		return IIO_VAL_INT_PLUS_MICRO;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (3 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:25   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space Jonathan Cameron
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |   74 ++++++++-------------------------
 1 files changed, 17 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 517cbd9..c615188 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -170,7 +170,15 @@ static int ad799x_read_raw(struct iio_dev *dev_info,
 	}
 	return -EINVAL;
 }
-
+static const unsigned int ad7998_frequencies[] = {
+	[AD7998_CYC_DIS]	= 0,
+	[AD7998_CYC_TCONF_32]	= 15625,
+	[AD7998_CYC_TCONF_64]	= 7812,
+	[AD7998_CYC_TCONF_128]	= 3906,
+	[AD7998_CYC_TCONF_512]	= 976,
+	[AD7998_CYC_TCONF_1024]	= 488,
+	[AD7998_CYC_TCONF_2048]	= 244,
+};
 static ssize_t ad799x_read_frequency(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
@@ -178,7 +186,7 @@ static ssize_t ad799x_read_frequency(struct device *dev,
 	struct iio_dev *dev_info = dev_get_drvdata(dev);
 	struct ad799x_state *st = iio_priv(dev_info);
 
-	int ret, len = 0;
+	int ret;
 	u8 val;
 	ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val);
 	if (ret)
@@ -186,33 +194,7 @@ static ssize_t ad799x_read_frequency(struct device *dev,
 
 	val &= AD7998_CYC_MASK;
 
-	switch (val) {
-	case AD7998_CYC_DIS:
-		len = sprintf(buf, "0\n");
-		break;
-	case AD7998_CYC_TCONF_32:
-		len = sprintf(buf, "15625\n");
-		break;
-	case AD7998_CYC_TCONF_64:
-		len = sprintf(buf, "7812\n");
-		break;
-	case AD7998_CYC_TCONF_128:
-		len = sprintf(buf, "3906\n");
-		break;
-	case AD7998_CYC_TCONF_256:
-		len = sprintf(buf, "1953\n");
-		break;
-	case AD7998_CYC_TCONF_512:
-		len = sprintf(buf, "976\n");
-		break;
-	case AD7998_CYC_TCONF_1024:
-		len = sprintf(buf, "488\n");
-		break;
-	case AD7998_CYC_TCONF_2048:
-		len = sprintf(buf, "244\n");
-		break;
-	}
-	return len;
+	return sprintf(buf, "%u\n", ad7998_frequencies[val]);
 }
 
 static ssize_t ad799x_write_frequency(struct device *dev,
@@ -224,7 +206,7 @@ static ssize_t ad799x_write_frequency(struct device *dev,
 	struct ad799x_state *st = iio_priv(dev_info);
 
 	long val;
-	int ret;
+	int ret, i;
 	u8 t;
 
 	ret = strict_strtol(buf, 10, &val);
@@ -238,36 +220,14 @@ static ssize_t ad799x_write_frequency(struct device *dev,
 	/* Wipe the bits clean */
 	t &= ~AD7998_CYC_MASK;
 
-	switch (val) {
-	case 15625:
-		t |= AD7998_CYC_TCONF_32;
-		break;
-	case 7812:
-		t |= AD7998_CYC_TCONF_64;
-		break;
-	case 3906:
-		t |= AD7998_CYC_TCONF_128;
-		break;
-	case 1953:
-		t |= AD7998_CYC_TCONF_256;
-		break;
-	case 976:
-		t |= AD7998_CYC_TCONF_512;
-		break;
-	case 488:
-		t |= AD7998_CYC_TCONF_1024;
-		break;
-	case 244:
-		t |= AD7998_CYC_TCONF_2048;
-		break;
-	case  0:
-		t |= AD7998_CYC_DIS;
-		break;
-	default:
+	for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++)
+		if (val == ad7998_frequencies[i])
+			break;
+	if (i == ARRAY_SIZE(ad7998_frequencies)) {
 		ret = -EINVAL;
 		goto error_ret_mutex;
 	}
-
+	t |= i;
 	ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t);
 
 error_ret_mutex:
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (4 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:29   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible Jonathan Cameron
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x.h      |    4 ++--
 drivers/staging/iio/adc/ad799x_core.c |    2 +-
 drivers/staging/iio/adc/ad799x_ring.c |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h
index 98f06f6..eda01d5 100644
--- a/drivers/staging/iio/adc/ad799x.h
+++ b/drivers/staging/iio/adc/ad799x.h
@@ -124,11 +124,11 @@ struct ad799x_platform_data {
 int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask);
 
 #ifdef CONFIG_AD799X_RING_BUFFER
-int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum);
+int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum);
 int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev);
 void ad799x_ring_cleanup(struct iio_dev *indio_dev);
 #else /* CONFIG_AD799X_RING_BUFFER */
-int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum)
+int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum)
 {
 	return -EINVAL;
 }
diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index c615188..a24d695 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -151,7 +151,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info,
 	case 0:
 		mutex_lock(&dev_info->mlock);
 		if (iio_buffer_enabled(dev_info))
-			ret = ad799x_single_channel_from_ring(st,
+			ret = ad799x_single_channel_from_ring(dev_info,
 							      chan->scan_index);
 		else
 			ret = ad799x_scan_direct(st, chan->address);
diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c
index 1bcc168..e3f4698 100644
--- a/drivers/staging/iio/adc/ad799x_ring.c
+++ b/drivers/staging/iio/adc/ad799x_ring.c
@@ -23,9 +23,9 @@
 
 #include "ad799x.h"
 
-int ad799x_single_channel_from_ring(struct ad799x_state *st, int channum)
+int ad799x_single_channel_from_ring(struct iio_dev *indio_dev, int channum)
 {
-	struct iio_buffer *ring = iio_priv_to_dev(st)->buffer;
+	struct iio_buffer *ring = indio_dev->buffer;
 	int count = 0, ret;
 	u16 *ring_data;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (5 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:51   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 08/16] staging:iio:adc:ad799x set the device name only once Jonathan Cameron
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |  142 +++++++++++++++++++--------------
 1 files changed, 82 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index a24d695..304d9ae 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -236,6 +236,61 @@ error_ret_mutex:
 	return ret ? ret : len;
 }
 
+static int ad799x_read_event_config(struct iio_dev *dev_info,
+				    u64 event_code)
+{
+	return 1;
+}
+
+static const u8 ad799x_threshold_addresses[][2] = {
+	{ AD7998_DATALOW_CH1_REG, AD7998_DATAHIGH_CH1_REG },
+	{ AD7998_DATALOW_CH2_REG, AD7998_DATAHIGH_CH2_REG },
+	{ AD7998_DATALOW_CH3_REG, AD7998_DATAHIGH_CH3_REG },
+	{ AD7998_DATALOW_CH4_REG, AD7998_DATAHIGH_CH4_REG },
+};
+
+static int ad799x_write_event_value(struct iio_dev *indio_dev,
+				    u64 event_code,
+				    int val)
+{
+	int ret;
+	struct ad799x_state *st = iio_priv(indio_dev);
+	int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
+			   IIO_EV_DIR_FALLING);
+	int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code);
+
+	mutex_lock(&indio_dev->mlock);
+	ret = ad799x_i2c_write16(st,
+				 ad799x_threshold_addresses[number][direction],
+				 val);
+	mutex_unlock(&indio_dev->mlock);
+
+	return ret;
+}
+
+static int ad799x_read_event_value(struct iio_dev *indio_dev,
+				    u64 event_code,
+				    int *val)
+{
+	int ret;
+	struct ad799x_state *st = iio_priv(indio_dev);
+	int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
+			   IIO_EV_DIR_FALLING);
+	int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code);
+	u16 valin;
+
+	mutex_lock(&indio_dev->mlock);
+	ret = ad799x_i2c_read16(st,
+				ad799x_threshold_addresses[number][direction],
+				&valin);
+	mutex_unlock(&indio_dev->mlock);
+	if (ret < 0)
+		return ret;
+	*val = valin;
+
+	return 0;
+}
+
 static ssize_t ad799x_read_channel_config(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
@@ -310,72 +365,24 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
 	return IRQ_HANDLED;
 }
 
-static IIO_DEVICE_ATTR(in_voltage0_thresh_low_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATALOW_CH1_REG);
-
-static IIO_DEVICE_ATTR(in_voltage0_thresh_high_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATAHIGH_CH1_REG);
-
 static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw,
 		       S_IRUGO | S_IWUSR,
 		       ad799x_read_channel_config,
 		       ad799x_write_channel_config,
 		       AD7998_HYST_CH1_REG);
 
-static IIO_DEVICE_ATTR(in_voltage1_thresh_low_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATALOW_CH2_REG);
-
-static IIO_DEVICE_ATTR(in_voltage1_thresh_high_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATAHIGH_CH2_REG);
-
 static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw,
 		       S_IRUGO | S_IWUSR,
 		       ad799x_read_channel_config,
 		       ad799x_write_channel_config,
 		       AD7998_HYST_CH2_REG);
 
-static IIO_DEVICE_ATTR(in_voltage2_thresh_low_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATALOW_CH3_REG);
-
-static IIO_DEVICE_ATTR(in_voltage2_thresh_high_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATAHIGH_CH3_REG);
-
 static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw,
 		       S_IRUGO | S_IWUSR,
 		       ad799x_read_channel_config,
 		       ad799x_write_channel_config,
 		       AD7998_HYST_CH3_REG);
 
-static IIO_DEVICE_ATTR(in_voltage3_thresh_low_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATALOW_CH4_REG);
-
-static IIO_DEVICE_ATTR(in_voltage3_thresh_high_value,
-		       S_IRUGO | S_IWUSR,
-		       ad799x_read_channel_config,
-		       ad799x_write_channel_config,
-		       AD7998_DATAHIGH_CH4_REG);
-
 static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw,
 		       S_IRUGO | S_IWUSR,
 		       ad799x_read_channel_config,
@@ -388,17 +395,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0");
 
 static struct attribute *ad7993_4_7_8_event_attributes[] = {
-	&iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr,
-	&iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr,
-	&iio_dev_attr_in_voltage2_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage2_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr,
-	&iio_dev_attr_in_voltage3_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage3_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr,
 	&iio_dev_attr_sampling_frequency.dev_attr.attr,
 	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
@@ -411,11 +410,7 @@ static struct attribute_group ad7993_4_7_8_event_attrs_group = {
 };
 
 static struct attribute *ad7992_event_attributes[] = {
-	&iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr,
-	&iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr,
-	&iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr,
 	&iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr,
 	&iio_dev_attr_sampling_frequency.dev_attr.attr,
 	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
@@ -435,15 +430,24 @@ static const struct iio_info ad7991_info = {
 static const struct iio_info ad7992_info = {
 	.read_raw = &ad799x_read_raw,
 	.event_attrs = &ad7992_event_attrs_group,
+	.read_event_config = &ad799x_read_event_config,
+	.read_event_value = &ad799x_read_event_value,
+	.write_event_value = &ad799x_write_event_value,
 	.driver_module = THIS_MODULE,
 };
 
 static const struct iio_info ad7993_4_7_8_info = {
 	.read_raw = &ad799x_read_raw,
 	.event_attrs = &ad7993_4_7_8_event_attrs_group,
+	.read_event_config = &ad799x_read_event_config,
+	.read_event_value = &ad799x_read_event_value,
+	.write_event_value = &ad799x_write_event_value,
 	.driver_module = THIS_MODULE,
 };
 
+#define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
+			IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
+
 static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 	[ad7991] = {
 		.channel = {
@@ -574,6 +578,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[1] = {
 				.type = IIO_VOLTAGE,
@@ -582,6 +587,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
 		},
@@ -599,6 +605,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[1] = {
 				.type = IIO_VOLTAGE,
@@ -607,6 +614,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[2] = {
 				.type = IIO_VOLTAGE,
@@ -615,6 +623,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[3] = {
 				.type = IIO_VOLTAGE,
@@ -623,6 +632,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
 		},
@@ -640,6 +650,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[1] = {
 				.type = IIO_VOLTAGE,
@@ -648,6 +659,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[2] = {
 				.type = IIO_VOLTAGE,
@@ -656,6 +668,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[3] = {
 				.type = IIO_VOLTAGE,
@@ -664,6 +677,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
 		},
@@ -681,6 +695,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[1] = {
 				.type = IIO_VOLTAGE,
@@ -689,6 +704,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[2] = {
 				.type = IIO_VOLTAGE,
@@ -697,6 +713,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[3] = {
 				.type = IIO_VOLTAGE,
@@ -705,6 +722,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 10, 16, 2),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[4] = {
 				.type = IIO_VOLTAGE,
@@ -754,6 +772,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[1] = {
 				.type = IIO_VOLTAGE,
@@ -762,6 +781,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[2] = {
 				.type = IIO_VOLTAGE,
@@ -770,6 +790,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[3] = {
 				.type = IIO_VOLTAGE,
@@ -778,6 +799,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 12, 16, 0),
+				.event_mask = AD799X_EV_MASK,
 			},
 			[4] = {
 				.type = IIO_VOLTAGE,
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 08/16] staging:iio:adc:ad799x set the device name only once.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (6 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:25   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address Jonathan Cameron
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 304d9ae..879b9d8 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -879,7 +879,6 @@ static int __devinit ad799x_probe(struct i2c_client *client,
 	indio_dev->dev.parent = &client->dev;
 	indio_dev->name = id->name;
 	indio_dev->info = st->chip_info->info;
-	indio_dev->name = id->name;
 
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->channels = st->chip_info->channel;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (7 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 08/16] staging:iio:adc:ad799x set the device name only once Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:32   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures Jonathan Cameron
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Saves on setting the value of address for the simple situation seen in this
device. They are already used interchangably to get data from the buffer.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad799x_core.c |   40 +--------------------------------
 1 files changed, 1 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 879b9d8..982c42c 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -154,7 +154,7 @@ static int ad799x_read_raw(struct iio_dev *dev_info,
 			ret = ad799x_single_channel_from_ring(dev_info,
 							      chan->scan_index);
 		else
-			ret = ad799x_scan_direct(st, chan->address);
+			ret = ad799x_scan_direct(st, chan->scan_index);
 		mutex_unlock(&dev_info->mlock);
 
 		if (ret < 0)
@@ -455,7 +455,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -463,7 +462,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -471,7 +469,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -479,7 +476,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -495,7 +491,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -503,7 +498,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -511,7 +505,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -519,7 +512,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -535,7 +527,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 8, 16, 4),
 			},
@@ -543,7 +534,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 8, 16, 4),
 			},
@@ -551,7 +541,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 8, 16, 4),
 			},
@@ -559,7 +548,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 8, 16, 4),
 			},
@@ -575,7 +563,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -584,7 +571,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -602,7 +588,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -611,7 +596,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -620,7 +604,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -629,7 +612,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -647,7 +629,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -656,7 +637,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -665,7 +645,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -674,7 +653,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -692,7 +670,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -701,7 +678,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -710,7 +686,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -719,7 +694,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 				.event_mask = AD799X_EV_MASK,
@@ -728,7 +702,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 4,
-				.address = 4,
 				.scan_index = 4,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -736,7 +709,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 5,
-				.address = 5,
 				.scan_index = 5,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -744,7 +716,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 6,
-				.address = 6,
 				.scan_index = 6,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -752,7 +723,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 7,
-				.address = 7,
 				.scan_index = 7,
 				.scan_type = IIO_ST('u', 10, 16, 2),
 			},
@@ -769,7 +739,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 0,
-				.address = 0,
 				.scan_index = 0,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -778,7 +747,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 1,
-				.address = 1,
 				.scan_index = 1,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -787,7 +755,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 2,
-				.address = 2,
 				.scan_index = 2,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -796,7 +763,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 3,
-				.address = 3,
 				.scan_index = 3,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 				.event_mask = AD799X_EV_MASK,
@@ -805,7 +771,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 4,
-				.address = 4,
 				.scan_index = 4,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -813,7 +778,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 5,
-				.address = 5,
 				.scan_index = 5,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -821,7 +785,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 6,
-				.address = 6,
 				.scan_index = 6,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
@@ -829,7 +792,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
 				.type = IIO_VOLTAGE,
 				.indexed = 1,
 				.channel = 7,
-				.address = 7,
 				.scan_index = 7,
 				.scan_type = IIO_ST('u', 12, 16, 0),
 			},
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (8 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:40   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix Jonathan Cameron
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

IIO_CHAN is being phased out and in this case things are so
simple it makes sense to have a local one parameter equivalent.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606_core.c |   82 +++++++++++---------------------
 1 files changed, 28 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 17cdafb..7ea5232 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -233,69 +233,43 @@ static const struct attribute_group ad7606_attribute_group = {
 	.is_visible = ad7606_attr_is_visible,
 };
 
+#define AD7606_CHANNEL(num)				\
+	{						\
+		.type = IIO_VOLTAGE,			\
+		.indexed = 1,				\
+		.channel = num,				\
+		.address = num,				\
+		.scan_index = num,			\
+		.scan_type = IIO_ST('s', 16, 16, 0),	\
+	}
+
 static struct iio_chan_spec ad7606_8_channels[] = {
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 0, 0, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 1, 1, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 2, 2, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 3, 3, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 4, 4, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 5, 5, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 6, 6, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 7, 7, IIO_ST('s', 16, 16, 0), 0),
+	AD7606_CHANNEL(0),
+	AD7606_CHANNEL(1),
+	AD7606_CHANNEL(2),
+	AD7606_CHANNEL(3),
+	AD7606_CHANNEL(4),
+	AD7606_CHANNEL(5),
+	AD7606_CHANNEL(6),
+	AD7606_CHANNEL(7),
 	IIO_CHAN_SOFT_TIMESTAMP(8),
 };
 
 static struct iio_chan_spec ad7606_6_channels[] = {
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 0, 0, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 1, 1, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 2, 2, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 3, 3, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 4, 4, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 5, 5, IIO_ST('s', 16, 16, 0), 0),
+	AD7606_CHANNEL(0),
+	AD7606_CHANNEL(1),
+	AD7606_CHANNEL(2),
+	AD7606_CHANNEL(3),
+	AD7606_CHANNEL(4),
+	AD7606_CHANNEL(5),
 	IIO_CHAN_SOFT_TIMESTAMP(6),
 };
 
 static struct iio_chan_spec ad7606_4_channels[] = {
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 0, 0, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 1, 1, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 2, 2, IIO_ST('s', 16, 16, 0), 0),
-	IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
-		 (1 << IIO_CHAN_INFO_SCALE_SHARED),
-		 3, 3, IIO_ST('s', 16, 16, 0), 0),
+	AD7606_CHANNEL(0),
+	AD7606_CHANNEL(1),
+	AD7606_CHANNEL(2),
+	AD7606_CHANNEL(3),
 	IIO_CHAN_SOFT_TIMESTAMP(4),
 };
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (9 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:33   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent Jonathan Cameron
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606_core.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 7ea5232..02b0a5b 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -329,9 +329,8 @@ static int ad7606_request_gpios(struct ad7606_state *st)
 	}
 
 	ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array));
-	if (!ret) {
+	if (!ret)
 		st->have_os = true;
-	}
 
 	ret = gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
 			       "AD7606_RESET");
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (10 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:37   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv Jonathan Cameron
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

To my mind, if a gpio is specified in the board file, yet fails
to be successfully requested, that is an error condidtion and
the driver should not muddle on regardless.

This does mean unwinding the gpios on error. Also the free_gpios
function is reordered so that it is consistent with the request one
(reverse order obviously).

This patch is the category of not technically fixing anything, just
making the driver be more in line with what a reviewer will expect.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606.h      |    5 -
 drivers/staging/iio/adc/ad7606_core.c |  135 +++++++++++++++++++++------------
 drivers/staging/iio/adc/ad7606_ring.c |    2 +-
 3 files changed, 86 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h
index b8b3d8e..8fc259f 100644
--- a/drivers/staging/iio/adc/ad7606.h
+++ b/drivers/staging/iio/adc/ad7606.h
@@ -75,11 +75,6 @@ struct ad7606_state {
 	unsigned			range;
 	unsigned			oversampling;
 	bool				done;
-	bool				have_frstdata;
-	bool				have_os;
-	bool				have_stby;
-	bool				have_reset;
-	bool				have_range;
 	void __iomem			*base_address;
 
 	/*
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 02b0a5b..e762acb 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -26,7 +26,7 @@
 
 int ad7606_reset(struct ad7606_state *st)
 {
-	if (st->have_reset) {
+	if (gpio_is_valid(st->pdata->gpio_reset)) {
 		gpio_set_value(st->pdata->gpio_reset, 1);
 		ndelay(100); /* t_reset >= 100ns */
 		gpio_set_value(st->pdata->gpio_reset, 0);
@@ -48,7 +48,7 @@ static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned ch)
 	if (ret)
 		goto error_ret;
 
-	if (st->have_frstdata) {
+	if (gpio_is_valid(st->pdata->gpio_frstdata)) {
 		ret = st->bops->read_block(st->dev, 1, st->data);
 		if (ret)
 			goto error_ret;
@@ -214,12 +214,14 @@ static mode_t ad7606_attr_is_visible(struct kobject *kobj,
 
 	mode_t mode = attr->mode;
 
-	if (!st->have_os &&
-		(attr == &iio_dev_attr_oversampling_ratio.dev_attr.attr ||
-		attr ==
-		&iio_const_attr_oversampling_ratio_available.dev_attr.attr))
+	if (!(gpio_is_valid(st->pdata->gpio_os0) &&
+	      gpio_is_valid(st->pdata->gpio_os1) &&
+	      gpio_is_valid(st->pdata->gpio_os2)) &&
+	    (attr == &iio_dev_attr_oversampling_ratio.dev_attr.attr ||
+	     attr ==
+	     &iio_const_attr_oversampling_ratio_available.dev_attr.attr))
 		mode = 0;
-	else if (!st->have_range &&
+	else if (!gpio_is_valid(st->pdata->gpio_range) &&
 		 (attr == &iio_dev_attr_in_voltage_range.dev_attr.attr ||
 		  attr ==
 		  &iio_const_attr_in_voltage_range_available.dev_attr.attr))
@@ -321,63 +323,96 @@ static int ad7606_request_gpios(struct ad7606_state *st)
 	};
 	int ret;
 
-	ret = gpio_request_one(st->pdata->gpio_convst, GPIOF_OUT_INIT_LOW,
-			       "AD7606_CONVST");
-	if (ret) {
-		dev_err(st->dev, "failed to request GPIO CONVST\n");
-		return ret;
+	if (gpio_is_valid(st->pdata->gpio_convst)) {
+		ret = gpio_request_one(st->pdata->gpio_convst,
+				       GPIOF_OUT_INIT_LOW,
+				       "AD7606_CONVST");
+		if (ret) {
+			dev_err(st->dev, "failed to request GPIO CONVST\n");
+			goto error_ret;
+		}
+	} else {
+		ret = -EIO;
+		goto error_ret;
 	}
 
-	ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array));
-	if (!ret)
-		st->have_os = true;
-
-	ret = gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
-			       "AD7606_RESET");
-	if (!ret)
-		st->have_reset = true;
+	if (gpio_is_valid(st->pdata->gpio_os0) &&
+	    gpio_is_valid(st->pdata->gpio_os1) &&
+	    gpio_is_valid(st->pdata->gpio_os2)) {
+		ret = gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array));
+		if (ret < 0)
+			goto error_free_convst;
+	}
 
-	ret = gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT |
-				((st->range == 10000) ? GPIOF_INIT_HIGH :
-				GPIOF_INIT_LOW), "AD7606_RANGE");
-	if (!ret)
-		st->have_range = true;
+	if (gpio_is_valid(st->pdata->gpio_reset)) {
+		ret = gpio_request_one(st->pdata->gpio_reset,
+				       GPIOF_OUT_INIT_LOW,
+				       "AD7606_RESET");
+		if (ret < 0)
+			goto error_free_os;
+	}
 
-	ret = gpio_request_one(st->pdata->gpio_stby, GPIOF_OUT_INIT_HIGH,
-			       "AD7606_STBY");
-	if (!ret)
-		st->have_stby = true;
+	if (gpio_is_valid(st->pdata->gpio_range)) {
+		ret = gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT |
+				       ((st->range == 10000) ? GPIOF_INIT_HIGH :
+					GPIOF_INIT_LOW), "AD7606_RANGE");
+		if (ret < 0)
+			goto error_free_reset;
+	}
+	if (gpio_is_valid(st->pdata->gpio_stby)) {
+		ret = gpio_request_one(st->pdata->gpio_stby,
+				       GPIOF_OUT_INIT_HIGH,
+				       "AD7606_STBY");
+		if (ret < 0)
+			goto error_free_range;
+	}
 
 	if (gpio_is_valid(st->pdata->gpio_frstdata)) {
 		ret = gpio_request_one(st->pdata->gpio_frstdata, GPIOF_IN,
 				       "AD7606_FRSTDATA");
-		if (!ret)
-			st->have_frstdata = true;
+		if (ret < 0)
+			goto error_free_stby;
 	}
 
 	return 0;
+
+error_free_stby:
+	if (gpio_is_valid(st->pdata->gpio_stby))
+		gpio_free(st->pdata->gpio_stby);
+error_free_range:
+	if (gpio_is_valid(st->pdata->gpio_range))
+		gpio_free(st->pdata->gpio_range);
+error_free_reset:
+	if (gpio_is_valid(st->pdata->gpio_reset))
+		gpio_free(st->pdata->gpio_reset);
+error_free_os:
+	if (gpio_is_valid(st->pdata->gpio_os0) &&
+	    gpio_is_valid(st->pdata->gpio_os1) &&
+	    gpio_is_valid(st->pdata->gpio_os2))
+		gpio_free_array(gpio_array, ARRAY_SIZE(gpio_array));
+error_free_convst:
+	gpio_free(st->pdata->gpio_convst);
+error_ret:
+	return ret;
 }
 
 static void ad7606_free_gpios(struct ad7606_state *st)
 {
-	if (st->have_range)
-		gpio_free(st->pdata->gpio_range);
-
-	if (st->have_stby)
+	if (gpio_is_valid(st->pdata->gpio_frstdata))
+		gpio_free(st->pdata->gpio_frstdata);
+	if (gpio_is_valid(st->pdata->gpio_stby))
 		gpio_free(st->pdata->gpio_stby);
-
-	if (st->have_os) {
-		gpio_free(st->pdata->gpio_os0);
-		gpio_free(st->pdata->gpio_os1);
+	if (gpio_is_valid(st->pdata->gpio_range))
+		gpio_free(st->pdata->gpio_range);
+	if (gpio_is_valid(st->pdata->gpio_reset))
+		gpio_free(st->pdata->gpio_reset);
+	if (gpio_is_valid(st->pdata->gpio_os0) &&
+	    gpio_is_valid(st->pdata->gpio_os1) &&
+	    gpio_is_valid(st->pdata->gpio_os2)) {
 		gpio_free(st->pdata->gpio_os2);
+		gpio_free(st->pdata->gpio_os1);
+		gpio_free(st->pdata->gpio_os0);
 	}
-
-	if (st->have_reset)
-		gpio_free(st->pdata->gpio_reset);
-
-	if (st->have_frstdata)
-		gpio_free(st->pdata->gpio_frstdata);
-
 	gpio_free(st->pdata->gpio_convst);
 }
 
@@ -531,8 +566,8 @@ void ad7606_suspend(struct iio_dev *indio_dev)
 {
 	struct ad7606_state *st = iio_priv(indio_dev);
 
-	if (st->have_stby) {
-		if (st->have_range)
+	if (gpio_is_valid(st->pdata->gpio_stby)) {
+		if (gpio_is_valid(st->pdata->gpio_range))
 			gpio_set_value(st->pdata->gpio_range, 1);
 		gpio_set_value(st->pdata->gpio_stby, 0);
 	}
@@ -542,8 +577,8 @@ void ad7606_resume(struct iio_dev *indio_dev)
 {
 	struct ad7606_state *st = iio_priv(indio_dev);
 
-	if (st->have_stby) {
-		if (st->have_range)
+	if (gpio_is_valid(st->pdata->gpio_stby)) {
+		if (gpio_is_valid(st->pdata->gpio_range))
 			gpio_set_value(st->pdata->gpio_range,
 					st->range == 10000);
 
diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
index 0b60a6e..f0742d6 100644
--- a/drivers/staging/iio/adc/ad7606_ring.c
+++ b/drivers/staging/iio/adc/ad7606_ring.c
@@ -110,7 +110,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 	if (buf == NULL)
 		return;
 
-	if (st->have_frstdata) {
+	if (gpio_is_valid(st->pdata->gpio_frstdata)) {
 		ret = st->bops->read_block(st->dev, 1, buf);
 		if (ret)
 			goto done;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (11 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:42   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id Jonathan Cameron
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

Other than a few slight refactorings the local version was pretty standard
so replace it and rework to get rid of st->d_size which it setup.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606.h      |    1 -
 drivers/staging/iio/adc/ad7606_ring.c |   42 +++++---------------------------
 2 files changed, 7 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h
index 8fc259f..bc95f09 100644
--- a/drivers/staging/iio/adc/ad7606.h
+++ b/drivers/staging/iio/adc/ad7606.h
@@ -68,7 +68,6 @@ struct ad7606_state {
 	struct regulator		*reg;
 	struct work_struct		poll_work;
 	wait_queue_head_t		wq_data_avail;
-	size_t				d_size;
 	const struct ad7606_bus_ops	*bops;
 	int				irq;
 	unsigned			id;
diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
index f0742d6..20927fd 100644
--- a/drivers/staging/iio/adc/ad7606_ring.c
+++ b/drivers/staging/iio/adc/ad7606_ring.c
@@ -43,37 +43,6 @@ error_ret:
 }
 
 /**
- * ad7606_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the nuber of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
- **/
-static int ad7606_ring_preenable(struct iio_dev *indio_dev)
-{
-	struct ad7606_state *st = iio_priv(indio_dev);
-	struct iio_buffer *ring = indio_dev->buffer;
-	size_t d_size;
-
-	d_size = st->chip_info->num_channels *
-		 st->chip_info->channels[0].scan_type.storagebits / 8;
-
-	if (ring->scan_timestamp) {
-		d_size += sizeof(s64);
-
-		if (d_size % sizeof(s64))
-			d_size += sizeof(s64) - (d_size % sizeof(s64));
-	}
-
-	if (ring->access->set_bytes_per_datum)
-		ring->access->set_bytes_per_datum(ring, d_size);
-
-	st->d_size = d_size;
-
-	return 0;
-}
-
-/**
  * ad7606_trigger_handler_th() th/bh of trigger launched polling to ring buffer
  *
  **/
@@ -106,7 +75,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 	__u8 *buf;
 	int ret;
 
-	buf = kzalloc(st->d_size, GFP_KERNEL);
+	buf = kzalloc(ring->access->get_bytes_per_datum(ring),
+		      GFP_KERNEL);
 	if (buf == NULL)
 		return;
 
@@ -137,8 +107,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 	time_ns = iio_get_time_ns();
 
 	if (ring->scan_timestamp)
-		memcpy(buf + st->d_size - sizeof(s64),
-			&time_ns, sizeof(time_ns));
+		*((s64 *)(buf + ring->access->get_bytes_per_datum(ring) -
+			  sizeof(s64))) = time_ns;
 
 	ring->access->store_to(indio_dev->buffer, buf, time_ns);
 done:
@@ -148,7 +118,7 @@ done:
 }
 
 static const struct iio_buffer_setup_ops ad7606_ring_setup_ops = {
-	.preenable = &ad7606_ring_preenable,
+	.preenable = &iio_sw_buffer_preenable,
 	.postenable = &iio_triggered_buffer_postenable,
 	.predisable = &iio_triggered_buffer_predisable,
 };
@@ -166,6 +136,8 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 
 	/* Effectively select the ring buffer implementation */
 	indio_dev->buffer->access = &ring_sw_access_funcs;
+	indio_dev->buffer->bpe =
+		st->chip_info->channels[0].scan_type.storagebits / 8;
 	indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh,
 						 &ad7606_trigger_handler_th_bh,
 						 0,
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (12 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:38   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements Jonathan Cameron
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

id wasn't used anywhere and st->irq can be removed by simply
passing it into the core remove function (trivially available in
the two bus implementations).

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606.h      |    4 +---
 drivers/staging/iio/adc/ad7606_core.c |   10 ++++------
 drivers/staging/iio/adc/ad7606_par.c  |    2 +-
 drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h
index bc95f09..0d1bb26 100644
--- a/drivers/staging/iio/adc/ad7606.h
+++ b/drivers/staging/iio/adc/ad7606.h
@@ -69,8 +69,6 @@ struct ad7606_state {
 	struct work_struct		poll_work;
 	wait_queue_head_t		wq_data_avail;
 	const struct ad7606_bus_ops	*bops;
-	int				irq;
-	unsigned			id;
 	unsigned			range;
 	unsigned			oversampling;
 	bool				done;
@@ -94,7 +92,7 @@ void ad7606_resume(struct iio_dev *indio_dev);
 struct iio_dev *ad7606_probe(struct device *dev, int irq,
 			      void __iomem *base_address, unsigned id,
 			      const struct ad7606_bus_ops *bops);
-int ad7606_remove(struct iio_dev *indio_dev);
+int ad7606_remove(struct iio_dev *indio_dev, int irq);
 int ad7606_reset(struct ad7606_state *st);
 
 enum ad7606_supported_device_ids {
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index e762acb..3c0fb72 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -459,8 +459,6 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
 	st = iio_priv(indio_dev);
 
 	st->dev = dev;
-	st->id = id;
-	st->irq = irq;
 	st->bops = bops;
 	st->base_address = base_address;
 	st->range = pdata->default_range == 10000 ? 10000 : 5000;
@@ -501,7 +499,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
 	if (ret)
 		dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n");
 
-	ret = request_irq(st->irq, ad7606_interrupt,
+	ret = request_irq(irq, ad7606_interrupt,
 		IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev);
 	if (ret)
 		goto error_free_gpios;
@@ -527,7 +525,7 @@ error_cleanup_ring:
 	ad7606_ring_cleanup(indio_dev);
 
 error_free_irq:
-	free_irq(st->irq, indio_dev);
+	free_irq(irq, indio_dev);
 
 error_free_gpios:
 	ad7606_free_gpios(st);
@@ -543,14 +541,14 @@ error_ret:
 	return ERR_PTR(ret);
 }
 
-int ad7606_remove(struct iio_dev *indio_dev)
+int ad7606_remove(struct iio_dev *indio_dev, int irq)
 {
 	struct ad7606_state *st = iio_priv(indio_dev);
 
 	iio_buffer_unregister(indio_dev);
 	ad7606_ring_cleanup(indio_dev);
 
-	free_irq(st->irq, indio_dev);
+	free_irq(irq, indio_dev);
 	if (!IS_ERR(st->reg)) {
 		regulator_disable(st->reg);
 		regulator_put(st->reg);
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index d21218d..688632e 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -106,7 +106,7 @@ static int __devexit ad7606_par_remove(struct platform_device *pdev)
 	struct resource *res;
 	struct ad7606_state *st = iio_priv(indio_dev);
 
-	ad7606_remove(indio_dev);
+	ad7606_remove(indio_dev, platform_get_irq(pdev, 0));
 
 	iounmap(st->base_address);
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c
index 0769c80..aede1ba 100644
--- a/drivers/staging/iio/adc/ad7606_spi.c
+++ b/drivers/staging/iio/adc/ad7606_spi.c
@@ -59,7 +59,7 @@ static int __devexit ad7606_spi_remove(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
 
-	return ad7606_remove(indio_dev);
+	return ad7606_remove(indio_dev, spi->irq);
 }
 
 #ifdef CONFIG_PM
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (13 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:40   ` Hennerich, Michael
  2011-09-23 12:01 ` [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro Jonathan Cameron
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

These are now handled through the chan_spec arrays and no one
is using them anymore.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7606.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h
index 0d1bb26..35018c3 100644
--- a/drivers/staging/iio/adc/ad7606.h
+++ b/drivers/staging/iio/adc/ad7606.h
@@ -50,8 +50,6 @@ struct ad7606_platform_data {
 
 struct ad7606_chip_info {
 	const char			*name;
-	u8				bits;
-	char				sign;
 	u16				int_vref_mv;
 	struct iio_chan_spec		*channels;
 	unsigned			num_channels;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (14 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements Jonathan Cameron
@ 2011-09-23 12:01 ` Jonathan Cameron
  2011-09-26  7:39   ` Hennerich, Michael
  2011-09-26  7:55 ` [PATCH 00/16] staging:iio:adc cleanups / fixes Hennerich, Michael
  2011-09-27  8:58 ` Jonathan Cameron
  17 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-23 12:01 UTC (permalink / raw)
  To: Michael.Hennerich; +Cc: linux-iio, Jonathan Cameron

It's going away.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/adc/ad7887_core.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c
index 71af6cb..37e6cc9 100644
--- a/drivers/staging/iio/adc/ad7887_core.c
+++ b/drivers/staging/iio/adc/ad7887_core.c
@@ -71,14 +71,24 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
 	 * More devices added in future
 	 */
 	[ID_AD7887] = {
-		.channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       1, 1, IIO_ST('u', 12, 16, 0), 0),
-
-		.channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
-				       (1 << IIO_CHAN_INFO_SCALE_SHARED),
-				       0, 0, IIO_ST('u', 12, 16, 0), 0),
-
+		.channel[0] = {
+			.type = IIO_VOLTAGE,
+			.indexed = 1,
+			.channel = 1,
+			.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
+			.address = 1,
+			.scan_index = 1,
+			.scan_type = IIO_ST('u', 12, 16, 0),
+		},
+		.channel[1] = {
+			.type = IIO_VOLTAGE,
+			.indexed = 1,
+			.channel = 0,
+			.info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
+			.address = 0,
+			.scan_index = 0,
+			.scan_type = IIO_ST('u', 12, 16, 0),
+		},
 		.channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
 		.int_vref_mv = 2500,
 	},
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* RE: [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read.
  2011-09-23 12:01 ` [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read Jonathan Cameron
@ 2011-09-26  7:24   ` Hennerich, Michael
  2011-09-26  8:31     ` Jonathan Cameron
  0 siblings, 1 reply; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:24 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> It is a bit mask whereas current code treats it as a straight value.

That's a NAK.
See MODE 2 - COMMAND MODE: Table 26. Address Pointer Byte.

On the AD7998 and AD7997 the channel is a straight value and not a mask.

>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/staging/iio/adc/ad799x_core.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 975a3f7..3b5f8be 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -123,7 +123,8 @@ static int
> ad799x_scan_direct(struct ad799x_state *st, unsigned ch)
>               break;
>       case ad7997:
>       case ad7998:
> -             cmd =3D (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE=
;
> +             cmd =3D ((1 << ch) << AD799X_CHANNEL_SHIFT) |
> +                     AD7997_8_READ_SINGLE;
>               break;
>       default:
>               return -EINVAL;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 08/16] staging:iio:adc:ad799x set the device name only once.
  2011-09-23 12:01 ` [PATCH 08/16] staging:iio:adc:ad799x set the device name only once Jonathan Cameron
@ 2011-09-26  7:25   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:25 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 304d9ae..879b9d8 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -879,7 +879,6 @@ static int
> __devinit ad799x_probe(struct i2c_client *client,
>       indio_dev->dev.parent =3D &client->dev;
>       indio_dev->name =3D id->name;
>       indio_dev->info =3D st->chip_info->info;
> -     indio_dev->name =3D id->name;
>
>       indio_dev->modes =3D INDIO_DIRECT_MODE;
>       indio_dev->channels =3D st->chip_info->channel;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch.
  2011-09-23 12:01 ` [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch Jonathan Cameron
@ 2011-09-26  7:25   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:25 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |   74 ++++++++-----------------
>  -------- 1 files changed, 17 insertions(+), 57 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 517cbd9..c615188 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -170,7 +170,15 @@ static int
> ad799x_read_raw(struct iio_dev *dev_info,
>       }
>       return -EINVAL;
>  }
> -
> +static const unsigned int ad7998_frequencies[] =3D {
> +     [AD7998_CYC_DIS]        =3D 0,
> +     [AD7998_CYC_TCONF_32]   =3D 15625,
> +     [AD7998_CYC_TCONF_64]   =3D 7812,
> +     [AD7998_CYC_TCONF_128]  =3D 3906,
> +     [AD7998_CYC_TCONF_512]  =3D 976,
> +     [AD7998_CYC_TCONF_1024] =3D 488,
> +     [AD7998_CYC_TCONF_2048] =3D 244,
> +};
>  static ssize_t ad799x_read_frequency(struct device *dev,
>                                       struct device_attribute *attr,
>                                       char *buf)
> @@ -178,7 +186,7 @@ static ssize_t ad799x_read_frequency(struct device
> *dev,
>       struct iio_dev *dev_info =3D dev_get_drvdata(dev);
>       struct ad799x_state *st =3D iio_priv(dev_info);
> -     int ret, len =3D 0;
> +     int ret;
>       u8 val;
>       ret =3D ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val);
>       if (ret)
> @@ -186,33 +194,7 @@ static ssize_t ad799x_read_frequency(struct device
> *dev,
>
>       val &=3D AD7998_CYC_MASK;
> -     switch (val) {
> -     case AD7998_CYC_DIS:
> -             len =3D sprintf(buf, "0\n");
> -             break;
> -     case AD7998_CYC_TCONF_32:
> -             len =3D sprintf(buf, "15625\n");
> -             break;
> -     case AD7998_CYC_TCONF_64:
> -             len =3D sprintf(buf, "7812\n");
> -             break;
> -     case AD7998_CYC_TCONF_128:
> -             len =3D sprintf(buf, "3906\n");
> -             break;
> -     case AD7998_CYC_TCONF_256:
> -             len =3D sprintf(buf, "1953\n");
> -             break;
> -     case AD7998_CYC_TCONF_512:
> -             len =3D sprintf(buf, "976\n");
> -             break;
> -     case AD7998_CYC_TCONF_1024:
> -             len =3D sprintf(buf, "488\n");
> -             break;
> -     case AD7998_CYC_TCONF_2048:
> -             len =3D sprintf(buf, "244\n");
> -             break;
> -     }
> -     return len;
> +     return sprintf(buf, "%u\n", ad7998_frequencies[val]);
>  }
>
>  static ssize_t ad799x_write_frequency(struct device *dev,
> @@ -224,7 +206,7 @@ static ssize_t ad799x_write_frequency(struct device
> *dev,
>       struct ad799x_state *st =3D iio_priv(dev_info);
>
>       long val;
> -     int ret;
> +     int ret, i;
>       u8 t;
>
>       ret =3D strict_strtol(buf, 10, &val);
> @@ -238,36 +220,14 @@ static ssize_t ad799x_write_frequency(struct
> device *dev,
>       /* Wipe the bits clean */
>       t &=3D ~AD7998_CYC_MASK;
> -     switch (val) {
> -     case 15625:
> -             t |=3D AD7998_CYC_TCONF_32;
> -             break;
> -     case 7812:
> -             t |=3D AD7998_CYC_TCONF_64;
> -             break;
> -     case 3906:
> -             t |=3D AD7998_CYC_TCONF_128;
> -             break;
> -     case 1953:
> -             t |=3D AD7998_CYC_TCONF_256;
> -             break;
> -     case 976:
> -             t |=3D AD7998_CYC_TCONF_512;
> -             break;
> -     case 488:
> -             t |=3D AD7998_CYC_TCONF_1024;
> -             break;
> -     case 244:
> -             t |=3D AD7998_CYC_TCONF_2048;
> -             break;
> -     case  0:
> -             t |=3D AD7998_CYC_DIS;
> -             break;
> -     default:
> +     for (i =3D 0; i < ARRAY_SIZE(ad7998_frequencies); i++)
> +             if (val =3D=3D ad7998_frequencies[i])
> +                     break;
> +     if (i =3D=3D ARRAY_SIZE(ad7998_frequencies)) {
>               ret =3D -EINVAL;
>               goto error_ret_mutex;
>       }
> -
> +     t |=3D i;
>       ret =3D ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t);
>
>  error_ret_mutex:

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space.
  2011-09-23 12:01 ` [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space Jonathan Cameron
@ 2011-09-26  7:29   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:29 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

Jonathan Cameron wrote on 2011-09-23:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x.h      |    4 ++--
>  drivers/staging/iio/adc/ad799x_core.c |    2 +-
>  drivers/staging/iio/adc/ad799x_ring.c |    4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x.h
> b/drivers/staging/iio/adc/ad799x.h index 98f06f6..eda01d5 100644 ---
> a/drivers/staging/iio/adc/ad799x.h +++
> b/drivers/staging/iio/adc/ad799x.h @@ -124,11 +124,11 @@ struct
> ad799x_platform_data {
>  int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask);
>
>  #ifdef CONFIG_AD799X_RING_BUFFER
> -int ad799x_single_channel_from_ring(struct ad799x_state *st, int
> channum); +int ad799x_single_channel_from_ring(struct iio_dev
> *indio_dev, int channum);
>  int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev);
>  void ad799x_ring_cleanup(struct iio_dev *indio_dev);
>  #else /* CONFIG_AD799X_RING_BUFFER */
> -int ad799x_single_channel_from_ring(struct ad799x_state *st, int
> channum) +int ad799x_single_channel_from_ring(struct iio_dev *indio_dev,
> int channum)
>  {
>       return -EINVAL;
>  }
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index c615188..a24d695 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -151,7 +151,7 @@ static int
> ad799x_read_raw(struct iio_dev *dev_info,
>       case 0:
>               mutex_lock(&dev_info->mlock);
>               if (iio_buffer_enabled(dev_info))
> -                     ret =3D ad799x_single_channel_from_ring(st,
> +                     ret =3D ad799x_single_channel_from_ring(dev_info,
>                                                             chan->scan_in=
dex);
>               else
>                       ret =3D ad799x_scan_direct(st, chan->address);
> diff --git a/drivers/staging/iio/adc/ad799x_ring.c
> b/drivers/staging/iio/adc/ad799x_ring.c index 1bcc168..e3f4698 100644
> --- a/drivers/staging/iio/adc/ad799x_ring.c +++
> b/drivers/staging/iio/adc/ad799x_ring.c @@ -23,9 +23,9 @@
>
>  #include "ad799x.h"
> -int ad799x_single_channel_from_ring(struct ad799x_state *st, int
> channum) +int ad799x_single_channel_from_ring(struct iio_dev *indio_dev,
> int channum)
>  {
> -     struct iio_buffer *ring =3D iio_priv_to_dev(st)->buffer;
> +     struct iio_buffer *ring =3D indio_dev->buffer;
>       int count =3D 0, ret;
>       u16 *ring_data;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address
  2011-09-23 12:01 ` [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address Jonathan Cameron
@ 2011-09-26  7:32   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:32 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

Jonathan Cameron wrote on 2011-09-23:
> Saves on setting the value of address for the simple situation seen in
> this device. They are already used interchangably to get data from the
> buffer.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |   40 +------------------------
>  -------- 1 files changed, 1 insertions(+), 39 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 879b9d8..982c42c 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -154,7 +154,7 @@ static int
> ad799x_read_raw(struct iio_dev *dev_info,
>                       ret =3D ad799x_single_channel_from_ring(dev_info,
>                                                             chan->scan_in=
dex);
>               else
> -                     ret =3D ad799x_scan_direct(st, chan->address);
> +                     ret =3D ad799x_scan_direct(st, chan->scan_index);
>               mutex_unlock(&dev_info->mlock);
>
>               if (ret < 0)
> @@ -455,7 +455,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -463,7 +462,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -471,7 +469,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -479,7 +476,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -495,7 +491,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -503,7 +498,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -511,7 +505,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -519,7 +512,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -535,7 +527,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 8,
>  16, 4),                      },
> @@ -543,7 +534,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 8,
>  16, 4),                      },
> @@ -551,7 +541,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',=
 8,
>  16, 4),                      },
> @@ -559,7 +548,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',=
 8,
>  16, 4),                      },
> @@ -575,7 +563,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -584,7 +571,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -602,7 +588,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -611,7 +596,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -620,7 +604,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -629,7 +612,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -647,7 +629,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -656,7 +637,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -665,7 +645,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -674,7 +653,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -692,7 +670,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -701,7 +678,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -710,7 +686,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -719,7 +694,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                          .event_mask =3D AD799X_EV_MASK,
> @@ -728,7 +702,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 4,
>  -                            .address =3D 4,                           .=
scan_index =3D 4,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -736,7 +709,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 5,
>  -                            .address =3D 5,                           .=
scan_index =3D 5,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -744,7 +716,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 6,
>  -                            .address =3D 6,                           .=
scan_index =3D 6,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -752,7 +723,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 7,
>  -                            .address =3D 7,                           .=
scan_index =3D 7,                                .scan_type =3D IIO_ST('u',
>  10, 16, 2),                  },
> @@ -769,7 +739,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 0,
>  -                            .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -778,7 +747,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 1,
>  -                            .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -787,7 +755,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 2,
>  -                            .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -796,7 +763,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 3,
>  -                            .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                          .event_mask =3D AD799X_EV_MASK,
> @@ -805,7 +771,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 4,
>  -                            .address =3D 4,                           .=
scan_index =3D 4,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -813,7 +778,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 5,
>  -                            .address =3D 5,                           .=
scan_index =3D 5,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -821,7 +785,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 6,
>  -                            .address =3D 6,                           .=
scan_index =3D 6,                                .scan_type =3D IIO_ST('u',
>  12, 16, 0),                  },
> @@ -829,7 +792,6 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
                                .type =3D IIO_VOLTAGE,                     =
       .indexed =3D 1,                           .channel =3D 7,
 -                              .address =3D 7,                           .=
scan_index =3D 7,                                .scan_type =3D IIO_ST('u',=
 12,
 16, 0),                        },

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct.
  2011-09-23 12:01 ` [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct Jonathan Cameron
@ 2011-09-26  7:32   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:32 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> This is much cleaner than bouncing through the various structures
> to get to the same thing.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 3b5f8be..517cbd9 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -159,12 +159,11 @@ static int
> ad799x_read_raw(struct iio_dev *dev_info,
>
>               if (ret < 0)
>                       return ret;
> -             *val =3D (ret >> st->chip_info->channel[0].scan_type.shift)=
 &
> -                     RES_MASK(st->chip_info-
>> channel[0].scan_type.realbits);
> +             *val =3D (ret >> chan->scan_type.shift) &
> +                     RES_MASK(chan->scan_type.realbits);
>               return IIO_VAL_INT;
>       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
> -             scale_uv =3D (st->int_vref_mv * 1000)
> -                     >> st->chip_info->channel[0].scan_type.realbits;
> +             scale_uv =3D (st->int_vref_mv * 1000) >> chan-
>> scan_type.realbits;
>>              *val =3D  scale_uv / 1000;
>>              *val2 =3D (scale_uv % 1000) * 1000;
>>              return IIO_VAL_INT_PLUS_MICRO;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix.
  2011-09-23 12:01 ` [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix Jonathan Cameron
@ 2011-09-26  7:33   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:33 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606_core.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606_core.c
> b/drivers/staging/iio/adc/ad7606_core.c index 7ea5232..02b0a5b 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c +++
> b/drivers/staging/iio/adc/ad7606_core.c @@ -329,9 +329,8 @@ static int
> ad7606_request_gpios(struct ad7606_state *st)
>       }
>
>       ret =3D gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array));
> -     if (!ret) {
> +     if (!ret)
>               st->have_os =3D true;
> -     }
>
>       ret =3D gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
>                              "AD7606_RESET");

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent
  2011-09-23 12:01 ` [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent Jonathan Cameron
@ 2011-09-26  7:37   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:37 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> To my mind, if a gpio is specified in the board file, yet fails
> to be successfully requested, that is an error condidtion and
> the driver should not muddle on regardless.
>
> This does mean unwinding the gpios on error. Also the free_gpios
> function is reordered so that it is consistent with the request one
> (reverse order obviously).
>
> This patch is the category of not technically fixing anything, just
> making the driver be more in line with what a reviewer will expect.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606.h      |    5 -
>  drivers/staging/iio/adc/ad7606_core.c |  135 +++++++++++++++++++++----
>  -------- drivers/staging/iio/adc/ad7606_ring.c |    2 +- 3 files
>  changed, 86 insertions(+), 56 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606.h
> b/drivers/staging/iio/adc/ad7606.h index b8b3d8e..8fc259f 100644 ---
> a/drivers/staging/iio/adc/ad7606.h +++
> b/drivers/staging/iio/adc/ad7606.h @@ -75,11 +75,6 @@ struct
> ad7606_state {
>       unsigned                        range;
>       unsigned                        oversampling;
>       bool                            done;
> -     bool                            have_frstdata;
> -     bool                            have_os;
> -     bool                            have_stby;
> -     bool                            have_reset;
> -     bool                            have_range;
>       void __iomem                    *base_address;
>
>       /*
> diff --git a/drivers/staging/iio/adc/ad7606_core.c
> b/drivers/staging/iio/adc/ad7606_core.c index 02b0a5b..e762acb 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c +++
> b/drivers/staging/iio/adc/ad7606_core.c @@ -26,7 +26,7 @@
>
>  int ad7606_reset(struct ad7606_state *st)
>  {
> -     if (st->have_reset) {
> +     if (gpio_is_valid(st->pdata->gpio_reset)) {
>               gpio_set_value(st->pdata->gpio_reset, 1);
>               ndelay(100); /* t_reset >=3D 100ns */
>               gpio_set_value(st->pdata->gpio_reset, 0);
> @@ -48,7 +48,7 @@ static int ad7606_scan_direct(struct iio_dev
> *indio_dev, unsigned ch)
>       if (ret)
>               goto error_ret;
> -     if (st->have_frstdata) {
> +     if (gpio_is_valid(st->pdata->gpio_frstdata)) {
>               ret =3D st->bops->read_block(st->dev, 1, st->data);
>               if (ret)
>                       goto error_ret;
> @@ -214,12 +214,14 @@ static mode_t ad7606_attr_is_visible(struct
> kobject *kobj,
>
>       mode_t mode =3D attr->mode;
> -     if (!st->have_os &&
> -             (attr =3D=3D &iio_dev_attr_oversampling_ratio.dev_attr.attr=
 ||
> -             attr =3D=3D
> -
>       &iio_const_attr_oversampling_ratio_available.dev_attr.attr))
> +     if (!(gpio_is_valid(st->pdata->gpio_os0) &&
> +           gpio_is_valid(st->pdata->gpio_os1) &&
> +           gpio_is_valid(st->pdata->gpio_os2)) &&
> +         (attr =3D=3D &iio_dev_attr_oversampling_ratio.dev_attr.attr ||
> +          attr =3D=3D
> +          &iio_const_attr_oversampling_ratio_available.dev_attr.attr))
>               mode =3D 0;
> -     else if (!st->have_range &&
> +     else if (!gpio_is_valid(st->pdata->gpio_range) &&
>                (attr =3D=3D &iio_dev_attr_in_voltage_range.dev_attr.attr =
||
>                 attr =3D=3D
> &iio_const_attr_in_voltage_range_available.dev_attr.attr))
> @@ -321,63 +323,96 @@ static int ad7606_request_gpios(struct
> ad7606_state *st)
>       };
>       int ret;
> -     ret =3D gpio_request_one(st->pdata->gpio_convst, GPIOF_OUT_INIT_LOW=
,
> -                            "AD7606_CONVST"); -      if (ret) { -       =
     dev_err(st->dev, "failed to
> request GPIO CONVST\n"); -            return ret; +   if
> (gpio_is_valid(st->pdata->gpio_convst)) { +           ret =3D
> gpio_request_one(st->pdata->gpio_convst, +                               =
    GPIOF_OUT_INIT_LOW,
> +                                    "AD7606_CONVST"); +              if =
(ret) { +                    dev_err(st->dev, "failed
> to request GPIO CONVST\n"); +                 goto error_ret; +          =
     } +     } else { +              ret =3D
> -EIO; +               goto error_ret;
>       }
> -     ret =3D gpio_request_array(gpio_array, ARRAY_SIZE(gpio_array));
> -     if (!ret)
> -             st->have_os =3D true;
> -
> -     ret =3D gpio_request_one(st->pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
> -                            "AD7606_RESET");
> -     if (!ret)
> -             st->have_reset =3D true;
> +     if (gpio_is_valid(st->pdata->gpio_os0) &&
> +         gpio_is_valid(st->pdata->gpio_os1) &&
> +         gpio_is_valid(st->pdata->gpio_os2)) {
> +             ret =3D gpio_request_array(gpio_array,
> ARRAY_SIZE(gpio_array));
> +             if (ret < 0)
> +                     goto error_free_convst;
> +     }
>
> -     ret =3D gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT |
> -                             ((st->range =3D=3D 10000) ? GPIOF_INIT_HIGH=
 :
> -                             GPIOF_INIT_LOW), "AD7606_RANGE");
> -     if (!ret)
> -             st->have_range =3D true;
> +     if (gpio_is_valid(st->pdata->gpio_reset)) {
> +             ret =3D gpio_request_one(st->pdata->gpio_reset,
> +                                    GPIOF_OUT_INIT_LOW,
> +                                    "AD7606_RESET");
> +             if (ret < 0)
> +                     goto error_free_os;
> +     }
>
> -     ret =3D gpio_request_one(st->pdata->gpio_stby, GPIOF_OUT_INIT_HIGH,
> -                            "AD7606_STBY");
> -     if (!ret)
> -             st->have_stby =3D true;
> +     if (gpio_is_valid(st->pdata->gpio_range)) {
> +             ret =3D gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_O=
UT
> |
> +                                    ((st->range =3D=3D 10000) ? GPIOF_IN=
IT_HIGH
> :
> +                                     GPIOF_INIT_LOW), "AD7606_RANGE");
> +             if (ret < 0)
> +                     goto error_free_reset;
> +     }
> +     if (gpio_is_valid(st->pdata->gpio_stby)) {
> +             ret =3D gpio_request_one(st->pdata->gpio_stby,
> +                                    GPIOF_OUT_INIT_HIGH,
> +                                    "AD7606_STBY");
> +             if (ret < 0)
> +                     goto error_free_range;
> +     }
>
>       if (gpio_is_valid(st->pdata->gpio_frstdata)) {
>               ret =3D gpio_request_one(st->pdata->gpio_frstdata, GPIOF_IN=
,
>                                      "AD7606_FRSTDATA");
> -             if (!ret)
> -                     st->have_frstdata =3D true;
> +             if (ret < 0)
> +                     goto error_free_stby;
>       }
>
>       return 0;
> + +error_free_stby: + if (gpio_is_valid(st->pdata->gpio_stby))
> +             gpio_free(st->pdata->gpio_stby); +error_free_range: +   if
> (gpio_is_valid(st->pdata->gpio_range))
> +             gpio_free(st->pdata->gpio_range); +error_free_reset: +  if
> (gpio_is_valid(st->pdata->gpio_reset))
> +             gpio_free(st->pdata->gpio_reset); +error_free_os: +     if
> (gpio_is_valid(st->pdata->gpio_os0) && +
> gpio_is_valid(st->pdata->gpio_os1) && +
> gpio_is_valid(st->pdata->gpio_os2)) +         gpio_free_array(gpio_array,
> ARRAY_SIZE(gpio_array)); +error_free_convst:
> +     gpio_free(st->pdata->gpio_convst); +error_ret: +        return ret;
>  }
>
>  static void ad7606_free_gpios(struct ad7606_state *st)
>  {
> -     if (st->have_range) -           gpio_free(st->pdata->gpio_range); -=
 -   if
> (st->have_stby) +     if (gpio_is_valid(st->pdata->gpio_frstdata))
> +             gpio_free(st->pdata->gpio_frstdata); +  if
> (gpio_is_valid(st->pdata->gpio_stby))
>               gpio_free(st->pdata->gpio_stby);
> - -   if (st->have_os) { -            gpio_free(st->pdata->gpio_os0);
> -             gpio_free(st->pdata->gpio_os1); +       if
> (gpio_is_valid(st->pdata->gpio_range))
> +             gpio_free(st->pdata->gpio_range); +     if
> (gpio_is_valid(st->pdata->gpio_reset))
> +             gpio_free(st->pdata->gpio_reset); +     if
> (gpio_is_valid(st->pdata->gpio_os0) && +
> gpio_is_valid(st->pdata->gpio_os1) && +
> gpio_is_valid(st->pdata->gpio_os2)) {
>               gpio_free(st->pdata->gpio_os2);
> +             gpio_free(st->pdata->gpio_os1);
> +             gpio_free(st->pdata->gpio_os0);
>       }
> -
> -     if (st->have_reset)
> -             gpio_free(st->pdata->gpio_reset);
> -
> -     if (st->have_frstdata)
> -             gpio_free(st->pdata->gpio_frstdata);
> -
>       gpio_free(st->pdata->gpio_convst);
>  }
> @@ -531,8 +566,8 @@ void ad7606_suspend(struct iio_dev *indio_dev)
>  {
>       struct ad7606_state *st =3D iio_priv(indio_dev);
> -     if (st->have_stby) {
> -             if (st->have_range)
> +     if (gpio_is_valid(st->pdata->gpio_stby)) {
> +             if (gpio_is_valid(st->pdata->gpio_range))
>                       gpio_set_value(st->pdata->gpio_range, 1);
>               gpio_set_value(st->pdata->gpio_stby, 0);        } @@ -542,8=
 +577,8 @@ void
>  ad7606_resume(struct iio_dev *indio_dev) {   struct ad7606_state *st =3D
>  iio_priv(indio_dev);
> -     if (st->have_stby) {
> -             if (st->have_range)
> +     if (gpio_is_valid(st->pdata->gpio_stby)) {
> +             if (gpio_is_valid(st->pdata->gpio_range))
>                       gpio_set_value(st->pdata->gpio_range,
>                                       st->range =3D=3D 10000);
> diff --git a/drivers/staging/iio/adc/ad7606_ring.c
> b/drivers/staging/iio/adc/ad7606_ring.c index 0b60a6e..f0742d6 100644
> --- a/drivers/staging/iio/adc/ad7606_ring.c +++
> b/drivers/staging/iio/adc/ad7606_ring.c @@ -110,7 +110,7 @@ static void
> ad7606_poll_bh_to_ring(struct work_struct *work_s)
>       if (buf =3D=3D NULL)
>               return;
> -     if (st->have_frstdata) {
> +     if (gpio_is_valid(st->pdata->gpio_frstdata)) {
>               ret =3D st->bops->read_block(st->dev, 1, buf);
>               if (ret)
>                       goto done;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
  2011-09-23 12:01 ` [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id Jonathan Cameron
@ 2011-09-26  7:38   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:38 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> id wasn't used anywhere and st->irq can be removed by simply
> passing it into the core remove function (trivially available in
> the two bus implementations).
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606.h      |    4 +---
>  drivers/staging/iio/adc/ad7606_core.c |   10 ++++------
>  drivers/staging/iio/adc/ad7606_par.c  |    2 +-
>  drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
>  4 files changed, 7 insertions(+), 11 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606.h
> b/drivers/staging/iio/adc/ad7606.h index bc95f09..0d1bb26 100644 ---
> a/drivers/staging/iio/adc/ad7606.h +++
> b/drivers/staging/iio/adc/ad7606.h @@ -69,8 +69,6 @@ struct ad7606_state
> {
>       struct work_struct              poll_work;      wait_queue_head_t  =
             wq_data_avail;
>       const struct ad7606_bus_ops     *bops;
> -     int                             irq;
> -     unsigned                        id;
>       unsigned                        range;  unsigned                   =
     oversampling;   bool                            done; @@ -94,7
>  +92,7 @@ void ad7606_resume(struct iio_dev *indio_dev); struct iio_dev
>  *ad7606_probe(struct device *dev, int irq,                         void =
__iomem
>  *base_address, unsigned id,                        const struct ad7606_b=
us_ops *bops);
> -int ad7606_remove(struct iio_dev *indio_dev);
> +int ad7606_remove(struct iio_dev *indio_dev, int irq);
>  int ad7606_reset(struct ad7606_state *st);
>
>  enum ad7606_supported_device_ids {
> diff --git a/drivers/staging/iio/adc/ad7606_core.c
> b/drivers/staging/iio/adc/ad7606_core.c index e762acb..3c0fb72 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c +++
> b/drivers/staging/iio/adc/ad7606_core.c @@ -459,8 +459,6 @@ struct
> iio_dev *ad7606_probe(struct device *dev, int irq,
>       st =3D iio_priv(indio_dev);
>
>       st->dev =3D dev;
> -     st->id =3D id;
> -     st->irq =3D irq;
>       st->bops =3D bops;
>       st->base_address =3D base_address;
>       st->range =3D pdata->default_range =3D=3D 10000 ? 10000 : 5000;
> @@ -501,7 +499,7 @@ struct iio_dev *ad7606_probe(struct device *dev,
> int irq,
>       if (ret)
>               dev_warn(st->dev, "failed to RESET: no RESET GPIO
> specified\n");
>
> -     ret =3D request_irq(st->irq, ad7606_interrupt,
> +     ret =3D request_irq(irq, ad7606_interrupt,
>               IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev);  if =
(ret)
>               goto error_free_gpios; @@ -527,7 +525,7 @@ error_cleanup_ri=
ng:
>       ad7606_ring_cleanup(indio_dev);
>
>  error_free_irq:
> -     free_irq(st->irq, indio_dev);
> +     free_irq(irq, indio_dev);
>
>  error_free_gpios:    ad7606_free_gpios(st); @@ -543,14 +541,14 @@
>  error_ret:   return ERR_PTR(ret); }
> -int ad7606_remove(struct iio_dev *indio_dev)
> +int ad7606_remove(struct iio_dev *indio_dev, int irq)
>  {
>       struct ad7606_state *st =3D iio_priv(indio_dev);
>
>       iio_buffer_unregister(indio_dev);
>       ad7606_ring_cleanup(indio_dev);
> -     free_irq(st->irq, indio_dev);
> +     free_irq(irq, indio_dev);
>       if (!IS_ERR(st->reg)) {
>               regulator_disable(st->reg);
>               regulator_put(st->reg);
> diff --git a/drivers/staging/iio/adc/ad7606_par.c
> b/drivers/staging/iio/adc/ad7606_par.c index d21218d..688632e 100644 ---
> a/drivers/staging/iio/adc/ad7606_par.c +++
> b/drivers/staging/iio/adc/ad7606_par.c @@ -106,7 +106,7 @@ static int
> __devexit ad7606_par_remove(struct platform_device *pdev)
>       struct resource *res;
>       struct ad7606_state *st =3D iio_priv(indio_dev);
> -     ad7606_remove(indio_dev);
> +     ad7606_remove(indio_dev, platform_get_irq(pdev, 0));
>
>       iounmap(st->base_address);
>       res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0);
> diff --git a/drivers/staging/iio/adc/ad7606_spi.c
> b/drivers/staging/iio/adc/ad7606_spi.c index 0769c80..aede1ba 100644 ---
> a/drivers/staging/iio/adc/ad7606_spi.c +++
> b/drivers/staging/iio/adc/ad7606_spi.c @@ -59,7 +59,7 @@ static int
> __devexit ad7606_spi_remove(struct spi_device *spi)
>  {
>       struct iio_dev *indio_dev =3D dev_get_drvdata(&spi->dev);
> -     return ad7606_remove(indio_dev);
> +     return ad7606_remove(indio_dev, spi->irq);
>  }
>
>  #ifdef CONFIG_PM

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro.
  2011-09-23 12:01 ` [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro Jonathan Cameron
@ 2011-09-26  7:39   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:39 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> It's going away.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7887_core.c |   26 ++++++++++++++++++-------
>  - 1 files changed, 18 insertions(+), 8 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7887_core.c
> b/drivers/staging/iio/adc/ad7887_core.c index 71af6cb..37e6cc9 100644
> --- a/drivers/staging/iio/adc/ad7887_core.c +++
> b/drivers/staging/iio/adc/ad7887_core.c @@ -71,14 +71,24 @@ static const
> struct ad7887_chip_info ad7887_chip_info_tbl[] = {
>        * More devices added in future
>        */
>       [ID_AD7887] = {
> -             .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 12, 16, 0), 0),
> -
> -             .channel[1] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 12, 16, 0), 0),
> -
> +             .channel[0] = {
> +                     .type = IIO_VOLTAGE,
> +                     .indexed = 1,
> +                     .channel = 1,
> +                     .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
> +                     .address = 1,
> +                     .scan_index = 1,
> +                     .scan_type = IIO_ST('u', 12, 16, 0),
> +             },
> +             .channel[1] = {
> +                     .type = IIO_VOLTAGE,
> +                     .indexed = 1,
> +                     .channel = 0,
> +                     .info_mask = (1 << IIO_CHAN_INFO_SCALE_SHARED),
> +                     .address = 0,
> +                     .scan_index = 0,
> +                     .scan_type = IIO_ST('u', 12, 16, 0),
> +             },
>               .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
>               .int_vref_mv = 2500,
>       },

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif




^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro.
  2011-09-23 12:01 ` [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro Jonathan Cameron
@ 2011-09-26  7:40   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:40 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Preparation for moving driver out of staging.
> That macro is a nightmare to maintain so it is going away.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |  452 ++++++++++++++++++++++++-
>  -------- 1 files changed, 329 insertions(+), 123 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index 58f70aa..975a3f7 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -151,7 +151,7 @@ static int
> ad799x_read_raw(struct iio_dev *dev_info,
>               mutex_lock(&dev_info->mlock);
>               if (iio_buffer_enabled(dev_info))
>                       ret =3D ad799x_single_channel_from_ring(st,
> -                                                           chan->address=
);
> +                                                           chan->scan_in=
dex);
>               else
>                       ret =3D ad799x_scan_direct(st, chan->address);
>               mutex_unlock(&dev_info->mlock);
> @@ -486,167 +486,373 @@ static const struct iio_info ad7993_4_7_8_info
> =3D {
>
>  static const struct ad799x_chip_info ad799x_chip_info_tbl[] =3D {
>       [ad7991] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             },
>               .num_channels =3D 5,
>               .int_vref_mv =3D 4096,
>               .info =3D &ad7991_info,
>       },
>       [ad7995] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             },
>               .num_channels =3D 5,
>               .int_vref_mv =3D 1024,
>               .info =3D &ad7991_info,
>       },
>       [ad7999] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 8, 16, 4), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 8, 16, 4), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 8, 16, 4), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 8, 16, 4), 0),
> -             .channel[4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 8, 16, 4),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 8, 16, 4),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 8, 16, 4),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 8, 16, 4),
> +                     },
> +                     [4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             },
>               .num_channels =3D 5,
>               .int_vref_mv =3D 1024,
>               .info =3D &ad7991_info,
>       },
>       [ad7992] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[2] =3D IIO_CHAN_SOFT_TIMESTAMP(2),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [2] =3D IIO_CHAN_SOFT_TIMESTAMP(2),
> +             },
>               .num_channels =3D 3,
>               .int_vref_mv =3D 4096,
>               .default_config =3D AD7998_ALERT_EN,
>               .info =3D &ad7992_info,
>       },
>       [ad7993] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             },
>               .num_channels =3D 5,
>               .int_vref_mv =3D 1024,
>               .default_config =3D AD7998_ALERT_EN,
>               .info =3D &ad7993_4_7_8_info,
>       },
>       [ad7994] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [4] =3D IIO_CHAN_SOFT_TIMESTAMP(4),
> +             },
>               .num_channels =3D 5,
>               .int_vref_mv =3D 4096,
>               .default_config =3D AD7998_ALERT_EN,
>               .info =3D &ad7993_4_7_8_info,
>       },
>       [ad7997] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       0, 0, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       1, 1, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       2, 2, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       3, 3, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[4] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       4, 4, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[5] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       5, 5, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[6] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       6, 6, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[7] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       7, 7, IIO_ST('u', 10, 16, 2), 0),
> -             .channel[8] =3D IIO_CHAN_SOFT_TIMESTAMP(8),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [4] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 4,
> +                             .address =3D 4,
> +                             .scan_index =3D 4,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [5] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 5,
> +                             .address =3D 5,
> +                             .scan_index =3D 5,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [6] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 6,
> +                             .address =3D 6,
> +                             .scan_index =3D 6,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [7] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 7,
> +                             .address =3D 7,
> +                             .scan_index =3D 7,
> +                             .scan_type =3D IIO_ST('u', 10, 16, 2),
> +                     },
> +                     [8] =3D IIO_CHAN_SOFT_TIMESTAMP(8),
> +             },
>               .num_channels =3D 9,
>               .int_vref_mv =3D 1024,
>               .default_config =3D AD7998_ALERT_EN,
>               .info =3D &ad7993_4_7_8_info,
>       },
>       [ad7998] =3D {
> -             .channel[0] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    0, 0, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[1] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    1, 1, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[2] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    2, 2, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[3] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    3, 3, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[4] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    4, 4, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[5] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    5, 5, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[6] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
> -                                    (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -                                    6, 6, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[7] =3D IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
> -                                       (1 << IIO_CHAN_INFO_SCALE_SHARED)=
,
> -                                       7, 7, IIO_ST('u', 12, 16, 0), 0),
> -             .channel[8] =3D IIO_CHAN_SOFT_TIMESTAMP(8),
> +             .channel =3D {
> +                     [0] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 0,
> +                             .address =3D 0,
> +                             .scan_index =3D 0,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [1] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 1,
> +                             .address =3D 1,
> +                             .scan_index =3D 1,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [2] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 2,
> +                             .address =3D 2,
> +                             .scan_index =3D 2,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [3] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 3,
> +                             .address =3D 3,
> +                             .scan_index =3D 3,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [4] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 4,
> +                             .address =3D 4,
> +                             .scan_index =3D 4,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [5] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 5,
> +                             .address =3D 5,
> +                             .scan_index =3D 5,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [6] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 6,
> +                             .address =3D 6,
> +                             .scan_index =3D 6,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [7] =3D {
> +                             .type =3D IIO_VOLTAGE,
> +                             .indexed =3D 1,
> +                             .channel =3D 7,
> +                             .address =3D 7,
> +                             .scan_index =3D 7,
> +                             .scan_type =3D IIO_ST('u', 12, 16, 0),
> +                     },
> +                     [8] =3D IIO_CHAN_SOFT_TIMESTAMP(8),
> +             },
>               .num_channels =3D 9,
>               .int_vref_mv =3D 4096,
>               .default_config =3D AD7998_ALERT_EN,

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures.
  2011-09-23 12:01 ` [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures Jonathan Cameron
@ 2011-09-26  7:40   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:40 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> IIO_CHAN is being phased out and in this case things are so
> simple it makes sense to have a local one parameter equivalent.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606_core.c |   82 +++++++++++--------------
>  ------- 1 files changed, 28 insertions(+), 54 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606_core.c
> b/drivers/staging/iio/adc/ad7606_core.c index 17cdafb..7ea5232 100644
> --- a/drivers/staging/iio/adc/ad7606_core.c +++
> b/drivers/staging/iio/adc/ad7606_core.c @@ -233,69 +233,43 @@ static
> const struct attribute_group ad7606_attribute_group = {
>       .is_visible = ad7606_attr_is_visible,
>  };
> +#define AD7606_CHANNEL(num)                          \
> +     {                                               \
> +             .type = IIO_VOLTAGE,                    \
> +             .indexed = 1,                           \
> +             .channel = num,                         \
> +             .address = num,                         \
> +             .scan_index = num,                      \
> +             .scan_type = IIO_ST('s', 16, 16, 0),    \
> +     }
> +
>  static struct iio_chan_spec ad7606_8_channels[] = {
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              0, 0, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              1, 1, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              2, 2, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              3, 3, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              4, 4, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              5, 5, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              6, 6, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              7, 7, IIO_ST('s', 16, 16, 0), 0),
> +     AD7606_CHANNEL(0),
> +     AD7606_CHANNEL(1),
> +     AD7606_CHANNEL(2),
> +     AD7606_CHANNEL(3),
> +     AD7606_CHANNEL(4),
> +     AD7606_CHANNEL(5),
> +     AD7606_CHANNEL(6),
> +     AD7606_CHANNEL(7),
>       IIO_CHAN_SOFT_TIMESTAMP(8),
>  };
>
>  static struct iio_chan_spec ad7606_6_channels[] = {
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              0, 0, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              1, 1, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              2, 2, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              3, 3, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              4, 4, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              5, 5, IIO_ST('s', 16, 16, 0), 0),
> +     AD7606_CHANNEL(0),
> +     AD7606_CHANNEL(1),
> +     AD7606_CHANNEL(2),
> +     AD7606_CHANNEL(3),
> +     AD7606_CHANNEL(4),
> +     AD7606_CHANNEL(5),
>       IIO_CHAN_SOFT_TIMESTAMP(6),
>  };
>
>  static struct iio_chan_spec ad7606_4_channels[] = {
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              0, 0, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              1, 1, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              2, 2, IIO_ST('s', 16, 16, 0), 0),
> -     IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
> -              (1 << IIO_CHAN_INFO_SCALE_SHARED),
> -              3, 3, IIO_ST('s', 16, 16, 0), 0),
> +     AD7606_CHANNEL(0),
> +     AD7606_CHANNEL(1),
> +     AD7606_CHANNEL(2),
> +     AD7606_CHANNEL(3),
>       IIO_CHAN_SOFT_TIMESTAMP(4),
>  };

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif




^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements.
  2011-09-23 12:01 ` [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements Jonathan Cameron
@ 2011-09-26  7:40   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:40 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> These are now handled through the chan_spec arrays and no one
> is using them anymore.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606.h |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606.h
> b/drivers/staging/iio/adc/ad7606.h index 0d1bb26..35018c3 100644 ---
> a/drivers/staging/iio/adc/ad7606.h +++
> b/drivers/staging/iio/adc/ad7606.h @@ -50,8 +50,6 @@ struct
> ad7606_platform_data {
>
>  struct ad7606_chip_info {
>       const char                      *name;
> -     u8                              bits;
> -     char                            sign;
>       u16                             int_vref_mv;
>       struct iio_chan_spec            *channels;
>       unsigned                        num_channels;

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv
  2011-09-23 12:01 ` [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv Jonathan Cameron
@ 2011-09-26  7:42   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:42 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

Jonathan Cameron wrote on 2011-09-23:
> Other than a few slight refactorings the local version was pretty
> standard so replace it and rework to get rid of st->d_size which it
> setup.
>
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad7606.h      |    1 -
>  drivers/staging/iio/adc/ad7606_ring.c |   42 +++++--------------------
>  ------- 2 files changed, 7 insertions(+), 36 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad7606.h
> b/drivers/staging/iio/adc/ad7606.h index 8fc259f..bc95f09 100644 ---
> a/drivers/staging/iio/adc/ad7606.h +++
> b/drivers/staging/iio/adc/ad7606.h @@ -68,7 +68,6 @@ struct ad7606_state
> {
>       struct regulator                *reg;   struct work_struct         =
     poll_work;
>       wait_queue_head_t               wq_data_avail; -        size_t     =
                     d_size;         const struct
>  ad7606_bus_ops       *bops;  int                             irq;    uns=
igned                        id;
> diff --git a/drivers/staging/iio/adc/ad7606_ring.c
> b/drivers/staging/iio/adc/ad7606_ring.c index f0742d6..20927fd 100644
> --- a/drivers/staging/iio/adc/ad7606_ring.c +++
> b/drivers/staging/iio/adc/ad7606_ring.c @@ -43,37 +43,6 @@ error_ret:
>  }
>
>  /**
> - * ad7606_ring_preenable() setup the parameters of the ring before
> enabling - * - * The complex nature of the setting of the nuber of bytes
> per datum is due - * to this driver currently ensuring that the
> timestamp is stored at an 8 - * byte boundary. - **/ -static int
> ad7606_ring_preenable(struct iio_dev *indio_dev) -{ - struct
> ad7606_state *st =3D iio_priv(indio_dev); -     struct iio_buffer *ring =
=3D
> indio_dev->buffer; -  size_t d_size; - -      d_size =3D
> st->chip_info->num_channels * -
> st->chip_info->channels[0].scan_type.storagebits / 8; - -     if
> (ring->scan_timestamp) { -            d_size +=3D sizeof(s64); - -       =
       if (d_size %
> sizeof(s64)) -                        d_size +=3D sizeof(s64) - (d_size %=
 sizeof(s64)); -       } -
> -     if (ring->access->set_bytes_per_datum)
> -             ring->access->set_bytes_per_datum(ring, d_size); - -    st-=
>d_size =3D
> d_size; - -   return 0; -} - -/**
>   * ad7606_trigger_handler_th() th/bh of trigger launched polling to
>   ring buffer * **/
> @@ -106,7 +75,8 @@ static void ad7606_poll_bh_to_ring(struct
> work_struct *work_s)
>       __u8 *buf;
>       int ret;
> -     buf =3D kzalloc(st->d_size, GFP_KERNEL);
> +     buf =3D kzalloc(ring->access->get_bytes_per_datum(ring),
> +                   GFP_KERNEL);
>       if (buf =3D=3D NULL)
>               return;
> @@ -137,8 +107,8 @@ static void ad7606_poll_bh_to_ring(struct
> work_struct *work_s)
>       time_ns =3D iio_get_time_ns();
>
>       if (ring->scan_timestamp)
> -             memcpy(buf + st->d_size - sizeof(s64),
> -                     &time_ns, sizeof(time_ns));
> +             *((s64 *)(buf + ring->access->get_bytes_per_datum(ring) -
> +                       sizeof(s64))) =3D time_ns;
>
>       ring->access->store_to(indio_dev->buffer, buf, time_ns); done: @@
>  -148,7 +118,7 @@ done: }
>
>  static const struct iio_buffer_setup_ops ad7606_ring_setup_ops =3D {
> -     .preenable =3D &ad7606_ring_preenable,
> +     .preenable =3D &iio_sw_buffer_preenable,
>       .postenable =3D &iio_triggered_buffer_postenable,
>       .predisable =3D &iio_triggered_buffer_predisable,
>  };
> @@ -166,6 +136,8 @@ int ad7606_register_ring_funcs_and_init(struct
> iio_dev *indio_dev)
>
>       /* Effectively select the ring buffer implementation */
>       indio_dev->buffer->access =3D &ring_sw_access_funcs;
> +     indio_dev->buffer->bpe =3D
> +             st->chip_info->channels[0].scan_type.storagebits / 8;
        indio_dev->pollfunc =3D iio_alloc_pollfunc(&ad7606_trigger_handler_=
th_bh,
                                                 &ad7606_trigger_handler_th=
_bh,                                                  0,

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible.
  2011-09-23 12:01 ` [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible Jonathan Cameron
@ 2011-09-26  7:51   ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:51 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>  drivers/staging/iio/adc/ad799x_core.c |  142 +++++++++++++++++++------
>  -------- 1 files changed, 82 insertions(+), 60 deletions(-)
> diff --git a/drivers/staging/iio/adc/ad799x_core.c
> b/drivers/staging/iio/adc/ad799x_core.c index a24d695..304d9ae 100644
> --- a/drivers/staging/iio/adc/ad799x_core.c +++
> b/drivers/staging/iio/adc/ad799x_core.c @@ -236,6 +236,61 @@
> error_ret_mutex:
>       return ret ? ret : len;
>  }
> +static int ad799x_read_event_config(struct iio_dev *dev_info, +
> u64 event_code) +{ +  return 1; +} + +static const u8
> ad799x_threshold_addresses[][2] =3D { + { AD7998_DATALOW_CH1_REG,
> AD7998_DATAHIGH_CH1_REG }, +  { AD7998_DATALOW_CH2_REG,
> AD7998_DATAHIGH_CH2_REG }, +  { AD7998_DATALOW_CH3_REG,
> AD7998_DATAHIGH_CH3_REG }, +  { AD7998_DATALOW_CH4_REG,
> AD7998_DATAHIGH_CH4_REG }, +}; + +static int
> ad799x_write_event_value(struct iio_dev *indio_dev, +                    =
         u64
> event_code, +                             int val) +{ +       int ret; + =
     struct ad799x_state *st =3D
> iio_priv(indio_dev); +        int direction =3D
> !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) =3D=3D +                       =
    IIO_EV_DIR_FALLING);
> +     int number =3D IIO_EVENT_CODE_EXTRACT_NUM(event_code); +
> +     mutex_lock(&indio_dev->mlock); +        ret =3D ad799x_i2c_write16(=
st, +
> ad799x_threshold_addresses[number][direction], +                         =
      val);
> +     mutex_unlock(&indio_dev->mlock); + +    return ret; +} + +static in=
t
> ad799x_read_event_value(struct iio_dev *indio_dev, +                     =
         u64
> event_code, +                             int *val) +{ +      int ret; + =
     struct ad799x_state *st =3D
> iio_priv(indio_dev); +        int direction =3D
> !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) =3D=3D +                       =
    IIO_EV_DIR_FALLING);
> +     int number =3D IIO_EVENT_CODE_EXTRACT_NUM(event_code); +  u16 valin=
; +
> +     mutex_lock(&indio_dev->mlock); +        ret =3D ad799x_i2c_read16(s=
t,
> +                             ad799x_threshold_addresses[number][directio=
n], +                                &valin);
> +     mutex_unlock(&indio_dev->mlock); +      if (ret < 0) +          ret=
urn ret; +   *val
> =3D valin; + +  return 0; +} +
>  static ssize_t ad799x_read_channel_config(struct device *dev,
>                                       struct device_attribute *attr,
>                                       char *buf)
> @@ -310,72 +365,24 @@ static irqreturn_t ad799x_event_handler(int irq,
> void *private)
>       return IRQ_HANDLED;
>  }
> -static IIO_DEVICE_ATTR(in_voltage0_thresh_low_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATALOW_CH1_REG);
> -
> -static IIO_DEVICE_ATTR(in_voltage0_thresh_high_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATAHIGH_CH1_REG);
> -
>  static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw,
>                      S_IRUGO | S_IWUSR,
>                      ad799x_read_channel_config,
>                      ad799x_write_channel_config,
>                      AD7998_HYST_CH1_REG);
> -static IIO_DEVICE_ATTR(in_voltage1_thresh_low_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATALOW_CH2_REG);
> -
> -static IIO_DEVICE_ATTR(in_voltage1_thresh_high_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATAHIGH_CH2_REG);
> -
>  static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw,
>                      S_IRUGO | S_IWUSR,
>                      ad799x_read_channel_config,
>                      ad799x_write_channel_config,
>                      AD7998_HYST_CH2_REG);
> -static IIO_DEVICE_ATTR(in_voltage2_thresh_low_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATALOW_CH3_REG);
> -
> -static IIO_DEVICE_ATTR(in_voltage2_thresh_high_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATAHIGH_CH3_REG);
> -
>  static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw,
>                      S_IRUGO | S_IWUSR,
>                      ad799x_read_channel_config,
>                      ad799x_write_channel_config,
>                      AD7998_HYST_CH3_REG);
> -static IIO_DEVICE_ATTR(in_voltage3_thresh_low_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATALOW_CH4_REG);
> -
> -static IIO_DEVICE_ATTR(in_voltage3_thresh_high_value,
> -                    S_IRUGO | S_IWUSR,
> -                    ad799x_read_channel_config,
> -                    ad799x_write_channel_config,
> -                    AD7998_DATAHIGH_CH4_REG);
> -
>  static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw,
>  S_IRUGO | S_IWUSR,                  ad799x_read_channel_config, @@ -388,=
17
>  +395,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, static
>  IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488
> 244 0");
>
>  static struct attribute *ad7993_4_7_8_event_attributes[] =3D {
> -     &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr,
> -     &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr,
> -     &iio_dev_attr_in_voltage2_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage2_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr,
> -     &iio_dev_attr_in_voltage3_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage3_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr,
>       &iio_dev_attr_sampling_frequency.dev_attr.attr,
>       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
> @@ -411,11 +410,7 @@ static struct attribute_group
> ad7993_4_7_8_event_attrs_group =3D {
>  };
>
>  static struct attribute *ad7992_event_attributes[] =3D {
> -     &iio_dev_attr_in_voltage0_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage0_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr,
> -     &iio_dev_attr_in_voltage1_thresh_low_value.dev_attr.attr,
> -     &iio_dev_attr_in_voltage1_thresh_high_value.dev_attr.attr,
>       &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr,
>       &iio_dev_attr_sampling_frequency.dev_attr.attr,
>       &iio_const_attr_sampling_frequency_available.dev_attr.attr, @@ -435=
,15
>  +430,24 @@ static const struct iio_info ad7991_info =3D { static const
>  struct iio_info ad7992_info =3D {      .read_raw =3D &ad799x_read_raw,
>       .event_attrs =3D &ad7992_event_attrs_group,
> +     .read_event_config =3D &ad799x_read_event_config,
> +     .read_event_value =3D &ad799x_read_event_value,
> +     .write_event_value =3D &ad799x_write_event_value,
>       .driver_module =3D THIS_MODULE,
>  };
>
>  static const struct iio_info ad7993_4_7_8_info =3D {
>       .read_raw =3D &ad799x_read_raw,
>       .event_attrs =3D &ad7993_4_7_8_event_attrs_group,
> +     .read_event_config =3D &ad799x_read_event_config,
> +     .read_event_value =3D &ad799x_read_event_value,
> +     .write_event_value =3D &ad799x_write_event_value,
>       .driver_module =3D THIS_MODULE,
>  };
> +#define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH,
> IIO_EV_DIR_RISING) | \
> +                     IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
> +
>  static const struct ad799x_chip_info ad799x_chip_info_tbl[] =3D {
>       [ad7991] =3D {
>               .channel =3D {
> @@ -574,6 +578,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [1] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -582,6 +587,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [2] =3D
>  IIO_CHAN_SOFT_TIMESTAMP(2),          },
> @@ -599,6 +605,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [1] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -607,6 +614,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [2] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -615,6 +623,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [3] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -623,6 +632,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [4] =3D
>  IIO_CHAN_SOFT_TIMESTAMP(4),          },
> @@ -640,6 +650,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [1] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -648,6 +659,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [2] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -656,6 +668,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [3] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -664,6 +677,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [4] =3D
>  IIO_CHAN_SOFT_TIMESTAMP(4),          },
> @@ -681,6 +695,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [1] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -689,6 +704,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [2] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -697,6 +713,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [3] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -705,6 +722,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',=
 10,
>  16, 2), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [4] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -754,6 +772,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 0,                           .=
scan_index =3D 0,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [1] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -762,6 +781,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 1,                           .=
scan_index =3D 1,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [2] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -770,6 +790,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
>                               .address =3D 2,                           .=
scan_index =3D 2,                                .scan_type =3D IIO_ST('u',=
 12,
>  16, 0), +                            .event_mask =3D AD799X_EV_MASK,    =
               },                      [3] =3D {                           =
      .type =3D
>  IIO_VOLTAGE,
> @@ -778,6 +799,7 @@ static const struct ad799x_chip_info
> ad799x_chip_info_tbl[] =3D {
                                .address =3D 3,                           .=
scan_index =3D 3,                                .scan_type =3D IIO_ST('u',=
 12,
 16, 0), +                              .event_mask =3D AD799X_EV_MASK,    =
               },                      [4] =3D {                           =
      .type =3D
 IIO_VOLTAGE,

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 00/16] staging:iio:adc cleanups / fixes.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (15 preceding siblings ...)
  2011-09-23 12:01 ` [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro Jonathan Cameron
@ 2011-09-26  7:55 ` Hennerich, Michael
  2011-09-26  8:34   ` Jonathan Cameron
  2011-09-27  8:58 ` Jonathan Cameron
  17 siblings, 1 reply; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-26  7:55 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-23:
> Hi Michael,
>
> Result of doing a careful review of these fundamentally clean
> drivers.  A few actual bug fixes and quite a few cases of moving
> to prefered means of doing things (not using IIO_CHAN for starters).
>
> Please look over these as I may well have 'cleaned' things into
> not working.  Only functional changes beyond bug fixes are that
> we now have event _en attributes for the ad799x (read only and always
> equal to 1) and what happens with gpio request failures has changed
> in the ad7606.

Hi Jonathan,

Great work. Looks good except for one patch I've NACKed.

[PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration=
 register on single channel read.

Thanks!

-Michael


> Thanks,
>
> Jonathan
>
> Jonathan Cameron (16):
>   staging:iio:adc:ad799x fix incorrect scan_type descriptions.
>   staging:iio:adc:ad799x stop using IIO_CHAN macro.
>   staging:iio:adc:ad799x fix incorrect setting of configuration
>     register on single channel read.
>   staging:iio:adc:ad799x trivial: use the convenient chan struct.
>   staging:iio:adc:ad799x use a table for frequency values rather than
>     big switch. staging:iio:adc:ad799x avoid bouncing back and forth
>     from iio_priv space. staging:iio:adc:ad799x use the core handling
>     for as much of the events as possible.
>   staging:iio:adc:ad799x set the device name only once.
>   staging:iio:adc:ad799x address and scan_index always match so stop
>     using address
>   staging:iio:adc:ad7606 add local define for chan_spec structures.
>   staging:iio:adc:ad7606 trivial code style fix.
>   staging:iio:adc:ad7606 make gpio request failures more consistent
>   staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local
>     equiv
>   staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
>   staging:iio:adc:ad7606 remove unused chip info elements.
>   staging:iio:adc:ad7887 stop using IIO_CHAN macro.
>  drivers/staging/iio/adc/ad7606.h      |   12 +-
>  drivers/staging/iio/adc/ad7606_core.c |  226 ++++++------
>  drivers/staging/iio/adc/ad7606_par.c  |    2 +-
>  drivers/staging/iio/adc/ad7606_ring.c |   44 +--
>  drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
>  drivers/staging/iio/adc/ad7887_core.c |   26 +-
>  drivers/staging/iio/adc/ad799x.h      |    4 +-
>  drivers/staging/iio/adc/ad799x_core.c |  645 ++++++++++++++++++++-----
>  -------- drivers/staging/iio/adc/ad799x_ring.c |    4 +- 9 files
>  changed, 546 insertions(+), 419 deletions(-)

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read.
  2011-09-26  7:24   ` Hennerich, Michael
@ 2011-09-26  8:31     ` Jonathan Cameron
  0 siblings, 0 replies; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-26  8:31 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: linux-iio, Device-drivers-devel

On 09/26/11 08:24, Hennerich, Michael wrote:
> Jonathan Cameron wrote on 2011-09-23:
>> It is a bit mask whereas current code treats it as a straight value.
> 
> That's a NAK.
> See MODE 2 - COMMAND MODE: Table 26. Address Pointer Byte.
> 
> On the AD7998 and AD7997 the channel is a straight value and not a mask.
Ah, my mistake, I thought we were using the configuration register to setup
the scan. Didn't notice you could tell the chip to ignore that and do a read
of a single channel.

Obviously, will drop this one.
> 
>>
>> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
>> ---
>>  drivers/staging/iio/adc/ad799x_core.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>> diff --git a/drivers/staging/iio/adc/ad799x_core.c
>> b/drivers/staging/iio/adc/ad799x_core.c index 975a3f7..3b5f8be 100644
>> --- a/drivers/staging/iio/adc/ad799x_core.c +++
>> b/drivers/staging/iio/adc/ad799x_core.c @@ -123,7 +123,8 @@ static int
>> ad799x_scan_direct(struct ad799x_state *st, unsigned ch)
>>               break;
>>       case ad7997:
>>       case ad7998:
>> -             cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE;
>> +             cmd = ((1 << ch) << AD799X_CHANNEL_SHIFT) |
>> +                     AD7997_8_READ_SINGLE;
>>               break;
>>       default:
>>               return -EINVAL;
> 
> Greetings,
> Michael
> 
> --
> Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
> Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
> Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif
> 
> 
> 


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/16] staging:iio:adc cleanups / fixes.
  2011-09-26  7:55 ` [PATCH 00/16] staging:iio:adc cleanups / fixes Hennerich, Michael
@ 2011-09-26  8:34   ` Jonathan Cameron
  2011-09-27  6:17     ` Hennerich, Michael
  0 siblings, 1 reply; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-26  8:34 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: linux-iio, Device-drivers-devel

On 09/26/11 08:55, Hennerich, Michael wrote:
> Jonathan Cameron wrote on 2011-09-23:
>> Hi Michael,
>>
>> Result of doing a careful review of these fundamentally clean
>> drivers.  A few actual bug fixes and quite a few cases of moving
>> to prefered means of doing things (not using IIO_CHAN for starters).
>>
>> Please look over these as I may well have 'cleaned' things into
>> not working.  Only functional changes beyond bug fixes are that
>> we now have event _en attributes for the ad799x (read only and always
>> equal to 1) and what happens with gpio request failures has changed
>> in the ad7606.
> 
> Hi Jonathan,
> 
> Great work. Looks good except for one patch I've NACKed.
> 
> [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read.
Dropped.
> 
> Thanks!
You are welcome.  I was so nearly happy with these drivers it made
sense to just spend a few mins hammering the last few corners.

Have you given any thought to which drivers we want to take with
us through the review process for moving the core out of staging?

Jonathan
> 
> -Michael
> 
> 
>> Thanks,
>>
>> Jonathan
>>
>> Jonathan Cameron (16):
>>   staging:iio:adc:ad799x fix incorrect scan_type descriptions.
>>   staging:iio:adc:ad799x stop using IIO_CHAN macro.
>>   staging:iio:adc:ad799x fix incorrect setting of configuration
>>     register on single channel read.
>>   staging:iio:adc:ad799x trivial: use the convenient chan struct.
>>   staging:iio:adc:ad799x use a table for frequency values rather than
>>     big switch. staging:iio:adc:ad799x avoid bouncing back and forth
>>     from iio_priv space. staging:iio:adc:ad799x use the core handling
>>     for as much of the events as possible.
>>   staging:iio:adc:ad799x set the device name only once.
>>   staging:iio:adc:ad799x address and scan_index always match so stop
>>     using address
>>   staging:iio:adc:ad7606 add local define for chan_spec structures.
>>   staging:iio:adc:ad7606 trivial code style fix.
>>   staging:iio:adc:ad7606 make gpio request failures more consistent
>>   staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local
>>     equiv
>>   staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
>>   staging:iio:adc:ad7606 remove unused chip info elements.
>>   staging:iio:adc:ad7887 stop using IIO_CHAN macro.
>>  drivers/staging/iio/adc/ad7606.h      |   12 +-
>>  drivers/staging/iio/adc/ad7606_core.c |  226 ++++++------
>>  drivers/staging/iio/adc/ad7606_par.c  |    2 +-
>>  drivers/staging/iio/adc/ad7606_ring.c |   44 +--
>>  drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
>>  drivers/staging/iio/adc/ad7887_core.c |   26 +-
>>  drivers/staging/iio/adc/ad799x.h      |    4 +-
>>  drivers/staging/iio/adc/ad799x_core.c |  645 ++++++++++++++++++++-----
>>  -------- drivers/staging/iio/adc/ad799x_ring.c |    4 +- 9 files
>>  changed, 546 insertions(+), 419 deletions(-)
> 
> Greetings,
> Michael
> 
> --
> Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
> Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
> Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 37+ messages in thread

* RE: [PATCH 00/16] staging:iio:adc cleanups / fixes.
  2011-09-26  8:34   ` Jonathan Cameron
@ 2011-09-27  6:17     ` Hennerich, Michael
  0 siblings, 0 replies; 37+ messages in thread
From: Hennerich, Michael @ 2011-09-27  6:17 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Device-drivers-devel

Jonathan Cameron wrote on 2011-09-26:
> Have you given any thought to which drivers we want to take with
> us through the review process for moving the core out of staging?

Hi Jonathan,

I really have no preference here. Whatever you think makes the most sense a=
nd
gives a good panorama view on what IIO is and for what its being used for.

Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar=
garet Seif

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/16] staging:iio:adc cleanups / fixes.
  2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
                   ` (16 preceding siblings ...)
  2011-09-26  7:55 ` [PATCH 00/16] staging:iio:adc cleanups / fixes Hennerich, Michael
@ 2011-09-27  8:58 ` Jonathan Cameron
  17 siblings, 0 replies; 37+ messages in thread
From: Jonathan Cameron @ 2011-09-27  8:58 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Michael.Hennerich, linux-iio

As stated in the patch series staging:iio: unwind IIO_IN -> IIO_VOLTAGE define
This was actually dependent on that series. My mess up due to some false
tagging in my local tree.  That one is uncontroversial and has been
in git hub tree under this.

Sorry about that,

Jonathan
> Hi Michael,
> 
> Result of doing a careful review of these fundamentally clean
> drivers.  A few actual bug fixes and quite a few cases of moving
> to prefered means of doing things (not using IIO_CHAN for starters).
> 
> Please look over these as I may well have 'cleaned' things into
> not working.  Only functional changes beyond bug fixes are that
> we now have event _en attributes for the ad799x (read only and always
> equal to 1) and what happens with gpio request failures has changed
> in the ad7606.
> 
> Thanks,
> 
> Jonathan
> 
> Jonathan Cameron (16):
>   staging:iio:adc:ad799x fix incorrect scan_type descriptions.
>   staging:iio:adc:ad799x stop using IIO_CHAN macro.
>   staging:iio:adc:ad799x fix incorrect setting of configuration
>     register on single channel read.
>   staging:iio:adc:ad799x trivial: use the convenient chan struct.
>   staging:iio:adc:ad799x use a table for frequency values rather than
>     big switch.
>   staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv
>     space.
>   staging:iio:adc:ad799x use the core handling for as much of the
>     events as possible.
>   staging:iio:adc:ad799x set the device name only once.
>   staging:iio:adc:ad799x address and scan_index always match so stop
>     using address
>   staging:iio:adc:ad7606 add local define for chan_spec structures.
>   staging:iio:adc:ad7606 trivial code style fix.
>   staging:iio:adc:ad7606 make gpio request failures more consistent
>   staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local
>     equiv
>   staging:iio:adc:ad7606 refactor to remove st->irq and st->id.
>   staging:iio:adc:ad7606 remove unused chip info elements.
>   staging:iio:adc:ad7887 stop using IIO_CHAN macro.
> 
>  drivers/staging/iio/adc/ad7606.h      |   12 +-
>  drivers/staging/iio/adc/ad7606_core.c |  226 ++++++------
>  drivers/staging/iio/adc/ad7606_par.c  |    2 +-
>  drivers/staging/iio/adc/ad7606_ring.c |   44 +--
>  drivers/staging/iio/adc/ad7606_spi.c  |    2 +-
>  drivers/staging/iio/adc/ad7887_core.c |   26 +-
>  drivers/staging/iio/adc/ad799x.h      |    4 +-
>  drivers/staging/iio/adc/ad799x_core.c |  645 ++++++++++++++++++++-------------
>  drivers/staging/iio/adc/ad799x_ring.c |    4 +-
>  9 files changed, 546 insertions(+), 419 deletions(-)
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2011-09-27  8:58 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-23 12:01 [PATCH 00/16] staging:iio:adc cleanups / fixes Jonathan Cameron
2011-09-23 12:01 ` [PATCH 01/16] staging:iio:adc:ad799x fix incorrect scan_type descriptions Jonathan Cameron
2011-09-23 12:01 ` [PATCH 02/16] staging:iio:adc:ad799x stop using IIO_CHAN macro Jonathan Cameron
2011-09-26  7:40   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 03/16] staging:iio:adc:ad799x fix incorrect setting of configuration register on single channel read Jonathan Cameron
2011-09-26  7:24   ` Hennerich, Michael
2011-09-26  8:31     ` Jonathan Cameron
2011-09-23 12:01 ` [PATCH 04/16] staging:iio:adc:ad799x trivial: use the convenient chan struct Jonathan Cameron
2011-09-26  7:32   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 05/16] staging:iio:adc:ad799x use a table for frequency values rather than big switch Jonathan Cameron
2011-09-26  7:25   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 06/16] staging:iio:adc:ad799x avoid bouncing back and forth from iio_priv space Jonathan Cameron
2011-09-26  7:29   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 07/16] staging:iio:adc:ad799x use the core handling for as much of the events as possible Jonathan Cameron
2011-09-26  7:51   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 08/16] staging:iio:adc:ad799x set the device name only once Jonathan Cameron
2011-09-26  7:25   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 09/16] staging:iio:adc:ad799x address and scan_index always match so stop using address Jonathan Cameron
2011-09-26  7:32   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 10/16] staging:iio:adc:ad7606 add local define for chan_spec structures Jonathan Cameron
2011-09-26  7:40   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 11/16] staging:iio:adc:ad7606 trivial code style fix Jonathan Cameron
2011-09-26  7:33   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 12/16] staging:iio:adc:ad7606 make gpio request failures more consistent Jonathan Cameron
2011-09-26  7:37   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 13/16] staging;iio:adc:ad7606 use iio_sw_buffer_preenable rather than local equiv Jonathan Cameron
2011-09-26  7:42   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 14/16] staging:iio:adc:ad7606 refactor to remove st->irq and st->id Jonathan Cameron
2011-09-26  7:38   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 15/16] staging:iio:adc:ad7606 remove unused chip info elements Jonathan Cameron
2011-09-26  7:40   ` Hennerich, Michael
2011-09-23 12:01 ` [PATCH 16/16] staging:iio:adc:ad7887 stop using IIO_CHAN macro Jonathan Cameron
2011-09-26  7:39   ` Hennerich, Michael
2011-09-26  7:55 ` [PATCH 00/16] staging:iio:adc cleanups / fixes Hennerich, Michael
2011-09-26  8:34   ` Jonathan Cameron
2011-09-27  6:17     ` Hennerich, Michael
2011-09-27  8:58 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.