linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] IIO: resolvers - first round of cleanups.
@ 2011-09-30 10:14 Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 01/11] staging:iio:resolver:ad2s90 fix registration of null pointer Jonathan Cameron
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Hi All,

Mostly straight forward, but that change I suggested yesterday
IIO_GYRO -> IIO_ANGL_VEL and in_gyro_x_* -> in_anglvel_x_*
is in here.  I'm interested to hear peoples opinions on that
in particular.

Note the ad2s1210 is still definitely a work in progress.
There are numerous weird and wonderful corners of its abi
a the moment that need sorting out.

Thanks,

Jonathan

Jonathan Cameron (11):
  staging:iio:resolver:ad2s90 fix registration of null pointer
  staging:iio:resolver:ad2s90 ensure name is passed to iio_core.
  stagiong:iio:resolver:ad2s90 chan spec conversion
  staging:iio: rename gyro channels to anglvel
  staging:iio:Documentation gyro -> anglvel updates in attribute names
  staging:iio:resolver:ad2s120x chan spec conversion
  staging:iio:resolver rename ad2s120x ->ad2s1200
  staging:iio:resolver:ad2s1210 ensure iio_dev->name is set
  staging:iio:resolver:ad2s1210 minimal chan spec conversion.
  staging:iio:resolver:ad2s1210 drop raw config register access
  staging:iio:resolver:ad2s1210 cleanup gpio handling.

 drivers/staging/iio/Documentation/sysfs-bus-iio |  108 ++++++------
 drivers/staging/iio/gyro/adis16060_core.c       |    2 +-
 drivers/staging/iio/gyro/adis16080_core.c       |    2 +-
 drivers/staging/iio/gyro/adis16130_core.c       |    2 +-
 drivers/staging/iio/gyro/adis16260_core.c       |    8 +-
 drivers/staging/iio/gyro/adxrs450_core.c        |    4 +-
 drivers/staging/iio/iio.h                       |    2 +-
 drivers/staging/iio/imu/adis16400_core.c        |   22 ++--
 drivers/staging/iio/industrialio-core.c         |    2 +-
 drivers/staging/iio/resolver/Kconfig            |    4 +-
 drivers/staging/iio/resolver/Makefile           |    2 +-
 drivers/staging/iio/resolver/ad2s1200.c         |  187 ++++++++++++++++++++
 drivers/staging/iio/resolver/ad2s120x.c         |  178 -------------------
 drivers/staging/iio/resolver/ad2s1210.c         |  216 +++++++++-------------
 drivers/staging/iio/resolver/ad2s90.c           |   57 +++---
 15 files changed, 382 insertions(+), 414 deletions(-)
 create mode 100644 drivers/staging/iio/resolver/ad2s1200.c
 delete mode 100644 drivers/staging/iio/resolver/ad2s120x.c

-- 
1.7.3.4


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

* [PATCH 01/11] staging:iio:resolver:ad2s90 fix registration of null pointer
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 02/11] staging:iio:resolver:ad2s90 ensure name is passed to iio_core Jonathan Cameron
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

When the new allocation code was introduced a stray pointer
to iio_dev structure was left in the chip state structure.
This was never set but was then registered with the core.

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

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 3739bd2..161442e 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -23,7 +23,6 @@
 
 struct ad2s90_state {
 	struct mutex lock;
-	struct iio_dev *idev;
 	struct spi_device *sdev;
 	u8 rx[2] ____cacheline_aligned;
 };
@@ -87,7 +86,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
 	indio_dev->info = &ad2s90_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = iio_device_register(st->idev);
+	ret = iio_device_register(indio_dev);
 	if (ret)
 		goto error_free_dev;
 
@@ -99,7 +98,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
 	return 0;
 
 error_free_dev:
-	iio_free_device(st->idev);
+	iio_free_device(indio_dev);
 error_ret:
 	return ret;
 }
-- 
1.7.3.4

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

* [PATCH 02/11] staging:iio:resolver:ad2s90 ensure name is passed to iio_core.
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 01/11] staging:iio:resolver:ad2s90 fix registration of null pointer Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 03/11] stagiong:iio:resolver:ad2s90 chan spec conversion Jonathan Cameron
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Scraps the pointless name define and adds an id table.
It's not technically required in drivers with only one supported
part but it does make the probe code more consistent.

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

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 161442e..4b936d6 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -19,8 +19,6 @@
 #include "../iio.h"
 #include "../sysfs.h"
 
-#define DRV_NAME "ad2s90"
-
 struct ad2s90_state {
 	struct mutex lock;
 	struct spi_device *sdev;
@@ -85,6 +83,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
 	indio_dev->dev.parent = &spi->dev;
 	indio_dev->info = &ad2s90_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->name = spi_get_device_id(spi)->name;
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
@@ -110,13 +109,19 @@ static int __devexit ad2s90_remove(struct spi_device *spi)
 	return 0;
 }
 
+static const struct spi_device_id ad2s90_id[] = {
+	{ "ad2s90" },
+	{}
+};
+
 static struct spi_driver ad2s90_driver = {
 	.driver = {
-		.name = DRV_NAME,
+		.name = "ad2s90",
 		.owner = THIS_MODULE,
 	},
 	.probe = ad2s90_probe,
 	.remove = __devexit_p(ad2s90_remove),
+	.id_table = ad2s90_id,
 };
 
 static __init int ad2s90_spi_init(void)
-- 
1.7.3.4


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

* [PATCH 03/11] stagiong:iio:resolver:ad2s90 chan spec conversion
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 01/11] staging:iio:resolver:ad2s90 fix registration of null pointer Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 02/11] staging:iio:resolver:ad2s90 ensure name is passed to iio_core Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 04/11] staging:iio: rename gyro channels to anglvel Jonathan Cameron
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Trivial conversion.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/resolver/ad2s90.c |   41 ++++++++++++++------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 4b936d6..8b3d34d 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -25,45 +25,38 @@ struct ad2s90_state {
 	u8 rx[2] ____cacheline_aligned;
 };
 
-static ssize_t ad2s90_show_angular(struct device *dev,
-			struct device_attribute *attr, char *buf)
+static int ad2s90_read_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan,
+			   int *val,
+			   int *val2,
+			   long m)
 {
 	int ret;
-	ssize_t len = 0;
-	u16 val;
-	struct ad2s90_state *st = iio_priv(dev_get_drvdata(dev));
+	struct ad2s90_state *st = iio_priv(indio_dev);
 
 	mutex_lock(&st->lock);
 	ret = spi_read(st->sdev, st->rx, 2);
 	if (ret)
 		goto error_ret;
-	val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-	len = sprintf(buf, "%d\n", val);
+	*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+
 error_ret:
 	mutex_unlock(&st->lock);
 
-	return ret ? ret : len;
+	return IIO_VAL_INT;
 }
 
-#define IIO_DEV_ATTR_SIMPLE_RESOLVER(_show) \
-	IIO_DEVICE_ATTR(angular, S_IRUGO, _show, NULL, 0)
-
-static IIO_DEV_ATTR_SIMPLE_RESOLVER(ad2s90_show_angular);
-
-static struct attribute *ad2s90_attributes[] = {
-	&iio_dev_attr_angular.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ad2s90_attribute_group = {
-	.attrs = ad2s90_attributes,
-};
-
 static const struct iio_info ad2s90_info = {
-	.attrs = &ad2s90_attribute_group,
+	.read_raw = &ad2s90_read_raw,
 	.driver_module = THIS_MODULE,
 };
 
+static const struct iio_chan_spec ad2s90_chan = {
+	.type = IIO_ANGL,
+	.indexed = 1,
+	.channel = 0,
+};
+
 static int __devinit ad2s90_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
@@ -83,6 +76,8 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
 	indio_dev->dev.parent = &spi->dev;
 	indio_dev->info = &ad2s90_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->channels = &ad2s90_chan;
+	indio_dev->num_channels = 1;
 	indio_dev->name = spi_get_device_id(spi)->name;
 
 	ret = iio_device_register(indio_dev);
-- 
1.7.3.4


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

* [PATCH 04/11] staging:iio: rename gyro channels to anglvel
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (2 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 03/11] stagiong:iio:resolver:ad2s90 chan spec conversion Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 05/11] staging:iio:Documentation gyro -> anglvel updates in attribute names Jonathan Cameron
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Ensure naming reflects what is measured, not how it is done.
Resolvers can measure the same thing for starters.
IIO_GYRO->IIO_ANGL_VEL to ensure consistent naming.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/gyro/adis16060_core.c |    2 +-
 drivers/staging/iio/gyro/adis16080_core.c |    2 +-
 drivers/staging/iio/gyro/adis16130_core.c |    2 +-
 drivers/staging/iio/gyro/adis16260_core.c |    8 ++++----
 drivers/staging/iio/gyro/adxrs450_core.c  |    4 ++--
 drivers/staging/iio/iio.h                 |    2 +-
 drivers/staging/iio/imu/adis16400_core.c  |   22 +++++++++++-----------
 drivers/staging/iio/industrialio-core.c   |    2 +-
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c
index f812991..abb6f05 100644
--- a/drivers/staging/iio/gyro/adis16060_core.c
+++ b/drivers/staging/iio/gyro/adis16060_core.c
@@ -117,7 +117,7 @@ static const struct iio_info adis16060_info = {
 
 static const struct iio_chan_spec adis16060_channels[] = {
 	{
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.address = ADIS16060_GYRO,
diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c
index a2ee9be..07b013a 100644
--- a/drivers/staging/iio/gyro/adis16080_core.c
+++ b/drivers/staging/iio/gyro/adis16080_core.c
@@ -108,7 +108,7 @@ static int adis16080_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_chan_spec adis16080_channels[] = {
 	{
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.address = ADIS16080_DIN_GYRO,
diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c
index a9f270e..87670c0 100644
--- a/drivers/staging/iio/gyro/adis16130_core.c
+++ b/drivers/staging/iio/gyro/adis16130_core.c
@@ -97,7 +97,7 @@ static int adis16130_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_chan_spec adis16130_channels[] = {
 	{
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.address = ADIS16130_RATEDATA,
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index efbee27..dc440d15 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -390,7 +390,7 @@ enum adis16260_channel {
 };
 #define ADIS16260_GYRO_CHANNEL_SET(axis, mod)				\
 	struct iio_chan_spec adis16260_channels_##axis[] = {		\
-		IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, mod,		\
+		IIO_CHAN(IIO_ANGL_VEL, 1, 0, 0, NULL, 0, mod,		\
 			 (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |	\
 			 (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) |	\
 			 (1 << IIO_CHAN_INFO_SCALE_SEPARATE),		\
@@ -468,7 +468,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
 	case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
 	case (1 << IIO_CHAN_INFO_SCALE_SHARED):
 		switch (chan->type) {
-		case IIO_GYRO:
+		case IIO_ANGL_VEL:
 			*val = 0;
 			if (spi_get_device_id(st->us)->driver_data)
 				*val2 = 320;
@@ -495,7 +495,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 	case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
 		switch (chan->type) {
-		case IIO_GYRO:
+		case IIO_ANGL_VEL:
 			bits = 12;
 			break;
 		default:
@@ -515,7 +515,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 	case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
 		switch (chan->type) {
-		case IIO_GYRO:
+		case IIO_ANGL_VEL:
 			bits = 12;
 			break;
 		default:
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
index 670b615..1fda3db 100644
--- a/drivers/staging/iio/gyro/adxrs450_core.c
+++ b/drivers/staging/iio/gyro/adxrs450_core.c
@@ -268,7 +268,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
 	switch (mask) {
 	case 0:
 		switch (chan->type) {
-		case IIO_GYRO:
+		case IIO_ANGL_VEL:
 			ret = adxrs450_spi_sensor_data(indio_dev, &t);
 			if (ret)
 				break;
@@ -305,7 +305,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_chan_spec adxrs450_channels[] = {
 	{
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
index 3c39e1c..a6aec66 100644
--- a/drivers/staging/iio/iio.h
+++ b/drivers/staging/iio/iio.h
@@ -31,7 +31,7 @@ enum iio_chan_type {
 	IIO_CURRENT,
 	IIO_POWER,
 	IIO_ACCEL,
-	IIO_GYRO,
+	IIO_ANGL_VEL,
 	IIO_MAGN,
 	IIO_LIGHT,
 	IIO_INTENSITY,
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index fe9b6a5..4e31c79 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -565,7 +565,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
 	case (1 << IIO_CHAN_INFO_SCALE_SHARED):
 	case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
 		switch (chan->type) {
-		case IIO_GYRO:
+		case IIO_ANGL_VEL:
 			*val = 0;
 			*val2 = st->variant->gyro_scale_micro;
 			return IIO_VAL_INT_PLUS_MICRO;
@@ -641,7 +641,7 @@ static struct iio_chan_spec adis16400_channels[] = {
 		.scan_index = ADIS16400_SCAN_SUPPLY,
 		.scan_type = IIO_ST('u', 14, 16, 0)
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_X,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -651,7 +651,7 @@ static struct iio_chan_spec adis16400_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_X,
 		.scan_type = IIO_ST('s', 14, 16, 0)
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Y,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -661,7 +661,7 @@ static struct iio_chan_spec adis16400_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_Y,
 		.scan_type = IIO_ST('s', 14, 16, 0),
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -759,7 +759,7 @@ static struct iio_chan_spec adis16350_channels[] = {
 		.scan_index = ADIS16400_SCAN_SUPPLY,
 		.scan_type = IIO_ST('u', 12, 16, 0)
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_X,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -769,7 +769,7 @@ static struct iio_chan_spec adis16350_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_X,
 		.scan_type = IIO_ST('s', 14, 16, 0)
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Y,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -779,7 +779,7 @@ static struct iio_chan_spec adis16350_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_Y,
 		.scan_type = IIO_ST('s', 14, 16, 0),
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -873,7 +873,7 @@ static struct iio_chan_spec adis16300_channels[] = {
 		.scan_index = ADIS16400_SCAN_SUPPLY,
 		.scan_type = IIO_ST('u', 12, 16, 0)
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_X,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -951,7 +951,7 @@ static struct iio_chan_spec adis16300_channels[] = {
 
 static const struct iio_chan_spec adis16334_channels[] = {
 	{
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_X,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -961,7 +961,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_X,
 		.scan_type = IIO_ST('s', 14, 16, 0),
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Y,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
@@ -971,7 +971,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
 		.scan_index = ADIS16400_SCAN_GYRO_Y,
 		.scan_type = IIO_ST('s', 14, 16, 0),
 	}, {
-		.type = IIO_GYRO,
+		.type = IIO_ANGL_VEL,
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index d2af50a..f776099 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -54,7 +54,7 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_CURRENT] = "current",
 	[IIO_POWER] = "power",
 	[IIO_ACCEL] = "accel",
-	[IIO_GYRO] = "gyro",
+	[IIO_ANGL_VEL] = "anglvel",
 	[IIO_MAGN] = "magn",
 	[IIO_LIGHT] = "illuminance",
 	[IIO_INTENSITY] = "intensity",
-- 
1.7.3.4


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

* [PATCH 05/11] staging:iio:Documentation gyro -> anglvel updates in attribute names
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (3 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 04/11] staging:iio: rename gyro channels to anglvel Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 06/11] staging:iio:resolver:ad2s120x chan spec conversion Jonathan Cameron
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Follows directly from change made in previous patch.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/Documentation/sysfs-bus-iio |  108 +++++++++++-----------
 1 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio
index fb6c381..0d6823d 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio
@@ -141,9 +141,9 @@ Description:
 		Has all of the equivalent parameters as per voltageY. Units
 		after application of scale and offset are m/s^2.
 
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_x_raw
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_y_raw
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_z_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
 KernelVersion:	2.6.35
 Contact:	linux-iio@vger.kernel.org
 Description:
@@ -221,7 +221,7 @@ What:		/sys/bus/iio/devices/iio:deviceX/in_voltage_scale
 What:		/sys/bus/iio/devices/iio:deviceX/out_voltageY_scale
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_scale
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_scale
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_scale
 What:		/sys/bus/iio/devices/iio:deviceX/in_magn_scale
 What:		/sys/bus/iio/devices/iio:deviceX/in_magn_x_scale
 What:		/sys/bus/iio/devices/iio:deviceX/in_magn_y_scale
@@ -240,9 +240,9 @@ Description:
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_y_calibbias
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_z_calibbias
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibbias
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibbias
-What:		/sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibbias
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibbias
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibbias
+What:		/sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibbias
 KernelVersion:	2.6.35
 Contact:	linux-iio@vger.kernel.org
 Description:
@@ -255,9 +255,9 @@ What		/sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale
 What		/sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale
 What		/sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale
 What		/sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale
-What		/sys/bus/iio/devices/iio:deviceX/in_gyro_x_calibscale
-What		/sys/bus/iio/devices/iio:deviceX/in_gyro_y_calibscale
-What		/sys/bus/iio/devices/iio:deviceX/in_gyro_z_calibscale
+What		/sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibscale
+What		/sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibscale
+What		/sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibscale
 KernelVersion:	2.6.35
 Contact:	linux-iio@vger.kernel.org
 Description:
@@ -338,12 +338,12 @@ What:		/sys/.../iio:deviceX/events/in_accel_y_thresh_rising_en
 What:		/sys/.../iio:deviceX/events/in_accel_y_thresh_falling_en
 What:		/sys/.../iio:deviceX/events/in_accel_z_thresh_rising_en
 What:		/sys/.../iio:deviceX/events/in_accel_z_thresh_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_x_thresh_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_x_thresh_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_y_thresh_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_y_thresh_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_z_thresh_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_z_thresh_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_x_thresh_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_x_thresh_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_y_thresh_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_y_thresh_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_z_thresh_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_z_thresh_falling_en
 What:		/sys/.../iio:deviceX/events/in_magn_x_thresh_rising_en
 What:		/sys/.../iio:deviceX/events/in_magn_x_thresh_falling_en
 What:		/sys/.../iio:deviceX/events/in_magn_y_thresh_rising_en
@@ -383,12 +383,12 @@ What:		/sys/.../iio:deviceX/events/in_accel_y_roc_rising_en
 What:		/sys/.../iio:deviceX/events/in_accel_y_roc_falling_en
 What:		/sys/.../iio:deviceX/events/in_accel_z_roc_rising_en
 What:		/sys/.../iio:deviceX/events/in_accel_z_roc_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_x_roc_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_x_roc_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_y_roc_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_y_roc_falling_en
-What:		/sys/.../iio:deviceX/events/in_gyro_z_roc_rising_en
-What:		/sys/.../iio:deviceX/events/in_gyro_z_roc_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_x_roc_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_x_roc_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_y_roc_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_y_roc_falling_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_z_roc_rising_en
+What:		/sys/.../iio:deviceX/events/in_anglvel_z_roc_falling_en
 What:		/sys/.../iio:deviceX/events/in_magn_x_roc_rising_en
 What:		/sys/.../iio:deviceX/events/in_magn_x_roc_falling_en
 What:		/sys/.../iio:deviceX/events/in_magn_y_roc_rising_en
@@ -429,12 +429,12 @@ What:		/sys/.../events/in_accel_y_raw_thresh_rising_value
 What:		/sys/.../events/in_accel_y_raw_thresh_falling_value
 What:		/sys/.../events/in_accel_z_raw_thresh_rising_value
 What:		/sys/.../events/in_accel_z_raw_thresh_falling_value
-What:		/sys/.../events/in_gyro_x_raw_thresh_rising_value
-What:		/sys/.../events/in_gyro_x_raw_thresh_falling_value
-What:		/sys/.../events/in_gyro_y_raw_thresh_rising_value
-What:		/sys/.../events/in_gyro_y_raw_thresh_falling_value
-What:		/sys/.../events/in_gyro_z_raw_thresh_rising_value
-What:		/sys/.../events/in_gyro_z_raw_thresh_falling_value
+What:		/sys/.../events/in_anglvel_x_raw_thresh_rising_value
+What:		/sys/.../events/in_anglvel_x_raw_thresh_falling_value
+What:		/sys/.../events/in_anglvel_y_raw_thresh_rising_value
+What:		/sys/.../events/in_anglvel_y_raw_thresh_falling_value
+What:		/sys/.../events/in_anglvel_z_raw_thresh_rising_value
+What:		/sys/.../events/in_anglvel_z_raw_thresh_falling_value
 What:		/sys/.../events/in_magn_x_raw_thresh_rising_value
 What:		/sys/.../events/in_magn_x_raw_thresh_falling_value
 What:		/sys/.../events/in_magn_y_raw_thresh_rising_value
@@ -466,12 +466,12 @@ What:		/sys/.../events/in_accel_y_raw_roc_rising_value
 What:		/sys/.../events/in_accel_y_raw_roc_falling_value
 What:		/sys/.../events/in_accel_z_raw_roc_rising_value
 What:		/sys/.../events/in_accel_z_raw_roc_falling_value
-What:		/sys/.../events/in_gyro_x_raw_roc_rising_value
-What:		/sys/.../events/in_gyro_x_raw_roc_falling_value
-What:		/sys/.../events/in_gyro_y_raw_roc_rising_value
-What:		/sys/.../events/in_gyro_y_raw_roc_falling_value
-What:		/sys/.../events/in_gyro_z_raw_roc_rising_value
-What:		/sys/.../events/in_gyro_z_raw_roc_falling_value
+What:		/sys/.../events/in_anglvel_x_raw_roc_rising_value
+What:		/sys/.../events/in_anglvel_x_raw_roc_falling_value
+What:		/sys/.../events/in_anglvel_y_raw_roc_rising_value
+What:		/sys/.../events/in_anglvel_y_raw_roc_falling_value
+What:		/sys/.../events/in_anglvel_z_raw_roc_rising_value
+What:		/sys/.../events/in_anglvel_z_raw_roc_falling_value
 What:		/sys/.../events/in_magn_x_raw_roc_rising_value
 What:		/sys/.../events/in_magn_x_raw_roc_falling_value
 What:		/sys/.../events/in_magn_y_raw_roc_rising_value
@@ -509,18 +509,18 @@ What:		/sys/.../events/in_accel_z_thresh_rising_period
 What:		/sys/.../events/in_accel_z_thresh_falling_period
 What:		/sys/.../events/in_accel_z_roc_rising_period
 What:		/sys/.../events/in_accel_z_roc_falling_period
-What:		/sys/.../events/in_gyro_x_thresh_rising_period
-What:		/sys/.../events/in_gyro_x_thresh_falling_period
-What:		/sys/.../events/in_gyro_x_roc_rising_period
-What:		/sys/.../events/in_gyro_x_roc_falling_period
-What:		/sys/.../events/in_gyro_y_thresh_rising_period
-What:		/sys/.../events/in_gyro_y_thresh_falling_period
-What:		/sys/.../events/in_gyro_y_roc_rising_period
-What:		/sys/.../events/in_gyro_y_roc_falling_period
-What:		/sys/.../events/in_gyro_z_thresh_rising_period
-What:		/sys/.../events/in_gyro_z_thresh_falling_period
-What:		/sys/.../events/in_gyro_z_roc_rising_period
-What:		/sys/.../events/in_gyro_z_roc_falling_period
+What:		/sys/.../events/in_anglvel_x_thresh_rising_period
+What:		/sys/.../events/in_anglvel_x_thresh_falling_period
+What:		/sys/.../events/in_anglvel_x_roc_rising_period
+What:		/sys/.../events/in_anglvel_x_roc_falling_period
+What:		/sys/.../events/in_anglvel_y_thresh_rising_period
+What:		/sys/.../events/in_anglvel_y_thresh_falling_period
+What:		/sys/.../events/in_anglvel_y_roc_rising_period
+What:		/sys/.../events/in_anglvel_y_roc_falling_period
+What:		/sys/.../events/in_anglvel_z_thresh_rising_period
+What:		/sys/.../events/in_anglvel_z_thresh_falling_period
+What:		/sys/.../events/in_anglvel_z_roc_rising_period
+What:		/sys/.../events/in_anglvel_z_roc_falling_period
 What:		/sys/.../events/in_magn_x_thresh_rising_period
 What:		/sys/.../events/in_magn_x_thresh_falling_period
 What:		/sys/.../events/in_magn_x_roc_rising_period
@@ -622,9 +622,9 @@ Description:
 What:		/sys/.../buffer/scan_elements/in_accel_x_en
 What:		/sys/.../buffer/scan_elements/in_accel_y_en
 What:		/sys/.../buffer/scan_elements/in_accel_z_en
-What:		/sys/.../buffer/scan_elements/in_gyro_x_en
-What:		/sys/.../buffer/scan_elements/in_gyro_y_en
-What:		/sys/.../buffer/scan_elements/in_gyro_z_en
+What:		/sys/.../buffer/scan_elements/in_anglvel_x_en
+What:		/sys/.../buffer/scan_elements/in_anglvel_y_en
+What:		/sys/.../buffer/scan_elements/in_anglvel_z_en
 What:		/sys/.../buffer/scan_elements/in_magn_x_en
 What:		/sys/.../buffer/scan_elements/in_magn_y_en
 What:		/sys/.../buffer/scan_elements/in_magn_z_en
@@ -640,7 +640,7 @@ Description:
 		Scan element control for triggered data capture.
 
 What:		/sys/.../buffer/scan_elements/in_accel_type
-What:		/sys/.../buffer/scan_elements/in_gyro_type
+What:		/sys/.../buffer/scan_elements/in_anglvel_type
 What:		/sys/.../buffer/scan_elements/in_magn_type
 What:		/sys/.../buffer/scan_elements/in_incli_type
 What:		/sys/.../buffer/scan_elements/in_voltageY_type
@@ -682,9 +682,9 @@ What:		/sys/.../buffer/scan_elements/in_voltageY_supply_index
 What:		/sys/.../buffer/scan_elements/in_accel_x_index
 What:		/sys/.../buffer/scan_elements/in_accel_y_index
 What:		/sys/.../buffer/scan_elements/in_accel_z_index
-What:		/sys/.../buffer/scan_elements/in_gyro_x_index
-What:		/sys/.../buffer/scan_elements/in_gyro_y_index
-What:		/sys/.../buffer/scan_elements/in_gyro_z_index
+What:		/sys/.../buffer/scan_elements/in_anglvel_x_index
+What:		/sys/.../buffer/scan_elements/in_anglvel_y_index
+What:		/sys/.../buffer/scan_elements/in_anglvel_z_index
 What:		/sys/.../buffer/scan_elements/in_magn_x_index
 What:		/sys/.../buffer/scan_elements/in_magn_y_index
 What:		/sys/.../buffer/scan_elements/in_magn_z_index
@@ -702,7 +702,7 @@ Description:
 		and the relevant _type attributes to establish the data storage
 		format.
 
-What:		/sys/.../iio:deviceX/in_gyro_z_quadrature_correction_raw
+What:		/sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw
 KernelVersion:	2.6.38
 Contact:	linux-iio@vger.kernel.org
 Description:
-- 
1.7.3.4


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

* [PATCH 06/11] staging:iio:resolver:ad2s120x chan spec conversion
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (4 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 05/11] staging:iio:Documentation gyro -> anglvel updates in attribute names Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 07/11] staging:iio:resolver rename ad2s120x ->ad2s1200 Jonathan Cameron
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Straight forward conversion.

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

diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s120x.c
index fdaf0a8..7dadcd0 100644
--- a/drivers/staging/iio/resolver/ad2s120x.c
+++ b/drivers/staging/iio/resolver/ad2s120x.c
@@ -39,62 +39,60 @@ struct ad2s120x_state {
 	u8 rx[2] ____cacheline_aligned;
 };
 
-static ssize_t ad2s120x_show_val(struct device *dev,
-			struct device_attribute *attr, char *buf)
+static int ad2s1200_read_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan,
+			   int *val,
+			   int *val2,
+			   long m)
 {
 	int ret = 0;
-	ssize_t len = 0;
-	u16 pos;
 	s16 vel;
-	u8 status;
-	struct ad2s120x_state *st = iio_priv(dev_get_drvdata(dev));
-	struct iio_dev_attr *iattr = to_iio_dev_attr(attr);
+	struct ad2s120x_state *st = iio_priv(indio_dev);
 
 	mutex_lock(&st->lock);
-
 	gpio_set_value(st->sample, 0);
 	/* delay (6 * AD2S120X_TSCLK + 20) nano seconds */
 	udelay(1);
 	gpio_set_value(st->sample, 1);
-	gpio_set_value(st->rdvel, iattr->address);
+	gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
 	ret = spi_read(st->sdev, st->rx, 2);
-	if (ret < 0)
-		goto error_ret;
-	status = st->rx[1];
-	if (iattr->address)
-		pos = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-	else {
-		vel = (st->rx[0] & 0x80) ? 0xf000 : 0;
-		vel |= (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+	if (ret < 0) {
+		mutex_unlock(&st->lock);
+		return ret;
+	}
+
+	switch (chan->type) {
+	case IIO_ANGL:
+		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+		break;
+	case IIO_ANGL_VEL:
+		vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+		vel = (vel << 4) >> 4;
+		*val = vel;
+	default:
+		mutex_unlock(&st->lock);
+		return -EINVAL;
 	}
-	len = sprintf(buf, "%d %c%c%c%c ", iattr->address ? pos : vel,
-				(status & 0x8) ? 'P' : 'V',
-				(status & 0x4) ? 'd' : '_',
-				(status & 0x2) ? 'l' : '_',
-				(status & 0x1) ? '1' : '0');
-error_ret:
 	/* delay (2 * AD2S120X_TSCLK + 20) ns for sample pulse */
 	udelay(1);
 	mutex_unlock(&st->lock);
-
-	return ret ? ret : len;
+	return IIO_VAL_INT;
 }
 
-static IIO_DEVICE_ATTR(pos, S_IRUGO, ad2s120x_show_val, NULL, 1);
-static IIO_DEVICE_ATTR(vel, S_IRUGO, ad2s120x_show_val, NULL, 0);
-
-static struct attribute *ad2s120x_attributes[] = {
-	&iio_dev_attr_pos.dev_attr.attr,
-	&iio_dev_attr_vel.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ad2s120x_attribute_group = {
-	.attrs = ad2s120x_attributes,
+static const struct iio_chan_spec ad2s1200_channels[] = {
+	{
+		.type = IIO_ANGL,
+		.indexed = 1,
+		.channel = 0,
+	}, {
+		.type = IIO_ANGL_VEL,
+		.indexed = 1,
+		.channel = 0,
+	}
 };
 
 static const struct iio_info ad2s120x_info = {
-	.attrs = &ad2s120x_attribute_group,
+	.read_raw = &ad2s1200_read_raw,
 	.driver_module = THIS_MODULE,
 };
 
@@ -126,6 +124,8 @@ static int __devinit ad2s120x_probe(struct spi_device *spi)
 	indio_dev->dev.parent = &spi->dev;
 	indio_dev->info = &ad2s120x_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->channels = ad2s1200_channels;
+	indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
-- 
1.7.3.4


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

* [PATCH 07/11] staging:iio:resolver rename ad2s120x ->ad2s1200
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (5 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 06/11] staging:iio:resolver:ad2s120x chan spec conversion Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 08/11] staging:iio:resolver:ad2s1210 ensure iio_dev->name is set Jonathan Cameron
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

There are far too many possible part numbers that are
not covered in here to have such a generic name.
So move to naming after one of the supported parts.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/resolver/Kconfig    |    4 +-
 drivers/staging/iio/resolver/Makefile   |    2 +-
 drivers/staging/iio/resolver/ad2s1200.c |  187 +++++++++++++++++++++++++++++++
 drivers/staging/iio/resolver/ad2s120x.c |  178 -----------------------------
 4 files changed, 190 insertions(+), 181 deletions(-)

diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig
index 07c309b..90b3bbc 100644
--- a/drivers/staging/iio/resolver/Kconfig
+++ b/drivers/staging/iio/resolver/Kconfig
@@ -10,8 +10,8 @@ config AD2S90
 	  Say yes here to build support for Analog Devices spi resolver
 	  to digital converters, ad2s90, provides direct access via sysfs.
 
-config AD2S120X
-	tristate "Analog Devices ad2s120x driver"
+config AD2S1200
+	tristate "Analog Devices ad2s1200/ad2s1205 driver"
 	depends on SPI
 	help
 	  Say yes here to build support for Analog Devices spi resolver
diff --git a/drivers/staging/iio/resolver/Makefile b/drivers/staging/iio/resolver/Makefile
index 0b84a89..14375e4 100644
--- a/drivers/staging/iio/resolver/Makefile
+++ b/drivers/staging/iio/resolver/Makefile
@@ -3,5 +3,5 @@
 #
 
 obj-$(CONFIG_AD2S90) += ad2s90.o
-obj-$(CONFIG_AD2S120X) += ad2s120x.o
+obj-$(CONFIG_AD2S1200) += ad2s1200.o
 obj-$(CONFIG_AD2S1210) += ad2s1210.o
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c
new file mode 100644
index 0000000..26268bf
--- /dev/null
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -0,0 +1,187 @@
+/*
+ * ad2s1200.c simple support for the ADI Resolver to Digital Converters:
+ * AD2S1200/1205
+ *
+ * Copyright (c) 2010-2010 Analog Devices Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/device.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+
+#include "../iio.h"
+#include "../sysfs.h"
+
+#define DRV_NAME "ad2s1200"
+
+/* input pin sample and rdvel is controlled by driver */
+#define AD2S1200_PN	2
+
+/* input clock on serial interface */
+#define AD2S1200_HZ	8192000
+/* clock period in nano second */
+#define AD2S1200_TSCLK	(1000000000/AD2S1200_HZ)
+
+struct ad2s1200_state {
+	struct mutex lock;
+	struct spi_device *sdev;
+	int sample;
+	int rdvel;
+	u8 rx[2] ____cacheline_aligned;
+};
+
+static int ad2s1200_read_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan,
+			   int *val,
+			   int *val2,
+			   long m)
+{
+	int ret = 0;
+	s16 vel;
+	struct ad2s1200_state *st = iio_priv(indio_dev);
+
+	mutex_lock(&st->lock);
+	gpio_set_value(st->sample, 0);
+	/* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
+	udelay(1);
+	gpio_set_value(st->sample, 1);
+	gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+	ret = spi_read(st->sdev, st->rx, 2);
+	if (ret < 0) {
+		mutex_unlock(&st->lock);
+		return ret;
+	}
+
+	switch (chan->type) {
+	case IIO_ANGL:
+		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+		break;
+	case IIO_ANGL_VEL:
+		vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+		vel = (vel << 4) >> 4;
+		*val = vel;
+	default:
+		mutex_unlock(&st->lock);
+		return -EINVAL;
+	}
+	/* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
+	udelay(1);
+	mutex_unlock(&st->lock);
+	return IIO_VAL_INT;
+}
+
+static const struct iio_chan_spec ad2s1200_channels[] = {
+	{
+		.type = IIO_ANGL,
+		.indexed = 1,
+		.channel = 0,
+	}, {
+		.type = IIO_ANGL_VEL,
+		.indexed = 1,
+		.channel = 0,
+	}
+};
+
+static const struct iio_info ad2s1200_info = {
+	.read_raw = &ad2s1200_read_raw,
+	.driver_module = THIS_MODULE,
+};
+
+static int __devinit ad2s1200_probe(struct spi_device *spi)
+{
+	struct ad2s1200_state *st;
+	struct iio_dev *indio_dev;
+	int pn, ret = 0;
+	unsigned short *pins = spi->dev.platform_data;
+
+	for (pn = 0; pn < AD2S1200_PN; pn++)
+		if (gpio_request_one(pins[pn], GPIOF_DIR_OUT, DRV_NAME)) {
+			pr_err("%s: request gpio pin %d failed\n",
+						DRV_NAME, pins[pn]);
+			goto error_ret;
+		}
+	indio_dev = iio_allocate_device(sizeof(*st));
+	if (indio_dev == NULL) {
+		ret = -ENOMEM;
+		goto error_ret;
+	}
+	spi_set_drvdata(spi, indio_dev);
+	st = iio_priv(indio_dev);
+	mutex_init(&st->lock);
+	st->sdev = spi;
+	st->sample = pins[0];
+	st->rdvel = pins[1];
+
+	indio_dev->dev.parent = &spi->dev;
+	indio_dev->info = &ad2s1200_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->channels = ad2s1200_channels;
+	indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
+	indio_dev->name = spi_get_device_id(spi)->name;
+
+	ret = iio_device_register(indio_dev);
+	if (ret)
+		goto error_free_dev;
+
+	spi->max_speed_hz = AD2S1200_HZ;
+	spi->mode = SPI_MODE_3;
+	spi_setup(spi);
+
+	return 0;
+
+error_free_dev:
+	iio_free_device(indio_dev);
+error_ret:
+	for (--pn; pn >= 0; pn--)
+		gpio_free(pins[pn]);
+	return ret;
+}
+
+static int __devexit ad2s1200_remove(struct spi_device *spi)
+{
+	iio_device_unregister(spi_get_drvdata(spi));
+
+	return 0;
+}
+
+static const struct spi_device_id ad2s1200_id[] = {
+	{ "ad2s1200" },
+	{ "ad2s1205" },
+	{}
+};
+
+static struct spi_driver ad2s1200_driver = {
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+	},
+	.probe = ad2s1200_probe,
+	.remove = __devexit_p(ad2s1200_remove),
+	.id_table = ad2s1200_id,
+};
+
+static __init int ad2s1200_spi_init(void)
+{
+	return spi_register_driver(&ad2s1200_driver);
+}
+module_init(ad2s1200_spi_init);
+
+static __exit void ad2s1200_spi_exit(void)
+{
+	spi_unregister_driver(&ad2s1200_driver);
+}
+module_exit(ad2s1200_spi_exit);
+
+MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
+MODULE_DESCRIPTION("Analog Devices AD2S1200/1205 Resolver to Digital SPI driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s120x.c
deleted file mode 100644
index 7dadcd0..0000000
--- a/drivers/staging/iio/resolver/ad2s120x.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * ad2s120x.c simple support for the ADI Resolver to Digital Converters: AD2S1200/1205
- *
- * Copyright (c) 2010-2010 Analog Devices Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-#include <linux/types.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/delay.h>
-#include <linux/gpio.h>
-#include <linux/module.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-
-#define DRV_NAME "ad2s120x"
-
-/* input pin sample and rdvel is controlled by driver */
-#define AD2S120X_PN	2
-
-/* input clock on serial interface */
-#define AD2S120X_HZ	8192000
-/* clock period in nano second */
-#define AD2S120X_TSCLK	(1000000000/AD2S120X_HZ)
-
-struct ad2s120x_state {
-	struct mutex lock;
-	struct spi_device *sdev;
-	int sample;
-	int rdvel;
-	u8 rx[2] ____cacheline_aligned;
-};
-
-static int ad2s1200_read_raw(struct iio_dev *indio_dev,
-			   struct iio_chan_spec const *chan,
-			   int *val,
-			   int *val2,
-			   long m)
-{
-	int ret = 0;
-	s16 vel;
-	struct ad2s120x_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->lock);
-	gpio_set_value(st->sample, 0);
-	/* delay (6 * AD2S120X_TSCLK + 20) nano seconds */
-	udelay(1);
-	gpio_set_value(st->sample, 1);
-	gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
-	ret = spi_read(st->sdev, st->rx, 2);
-	if (ret < 0) {
-		mutex_unlock(&st->lock);
-		return ret;
-	}
-
-	switch (chan->type) {
-	case IIO_ANGL:
-		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-		break;
-	case IIO_ANGL_VEL:
-		vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-		vel = (vel << 4) >> 4;
-		*val = vel;
-	default:
-		mutex_unlock(&st->lock);
-		return -EINVAL;
-	}
-	/* delay (2 * AD2S120X_TSCLK + 20) ns for sample pulse */
-	udelay(1);
-	mutex_unlock(&st->lock);
-	return IIO_VAL_INT;
-}
-
-static const struct iio_chan_spec ad2s1200_channels[] = {
-	{
-		.type = IIO_ANGL,
-		.indexed = 1,
-		.channel = 0,
-	}, {
-		.type = IIO_ANGL_VEL,
-		.indexed = 1,
-		.channel = 0,
-	}
-};
-
-static const struct iio_info ad2s120x_info = {
-	.read_raw = &ad2s1200_read_raw,
-	.driver_module = THIS_MODULE,
-};
-
-static int __devinit ad2s120x_probe(struct spi_device *spi)
-{
-	struct ad2s120x_state *st;
-	struct iio_dev *indio_dev;
-	int pn, ret = 0;
-	unsigned short *pins = spi->dev.platform_data;
-
-	for (pn = 0; pn < AD2S120X_PN; pn++)
-		if (gpio_request_one(pins[pn], GPIOF_DIR_OUT, DRV_NAME)) {
-			pr_err("%s: request gpio pin %d failed\n",
-						DRV_NAME, pins[pn]);
-			goto error_ret;
-		}
-	indio_dev = iio_allocate_device(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
-	spi_set_drvdata(spi, indio_dev);
-	st = iio_priv(indio_dev);
-	mutex_init(&st->lock);
-	st->sdev = spi;
-	st->sample = pins[0];
-	st->rdvel = pins[1];
-
-	indio_dev->dev.parent = &spi->dev;
-	indio_dev->info = &ad2s120x_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->channels = ad2s1200_channels;
-	indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
-
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		goto error_free_dev;
-
-	spi->max_speed_hz = AD2S120X_HZ;
-	spi->mode = SPI_MODE_3;
-	spi_setup(spi);
-
-	return 0;
-
-error_free_dev:
-	iio_free_device(indio_dev);
-error_ret:
-	for (--pn; pn >= 0; pn--)
-		gpio_free(pins[pn]);
-	return ret;
-}
-
-static int __devexit ad2s120x_remove(struct spi_device *spi)
-{
-	iio_device_unregister(spi_get_drvdata(spi));
-
-	return 0;
-}
-
-static struct spi_driver ad2s120x_driver = {
-	.driver = {
-		.name = DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-	.probe = ad2s120x_probe,
-	.remove = __devexit_p(ad2s120x_remove),
-};
-
-static __init int ad2s120x_spi_init(void)
-{
-	return spi_register_driver(&ad2s120x_driver);
-}
-module_init(ad2s120x_spi_init);
-
-static __exit void ad2s120x_spi_exit(void)
-{
-	spi_unregister_driver(&ad2s120x_driver);
-}
-module_exit(ad2s120x_spi_exit);
-
-MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices AD2S1200/1205 Resolver to Digital SPI driver");
-MODULE_LICENSE("GPL v2");
-- 
1.7.3.4


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

* [PATCH 08/11] staging:iio:resolver:ad2s1210 ensure iio_dev->name is set
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (6 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 07/11] staging:iio:resolver rename ad2s120x ->ad2s1200 Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 09/11] staging:iio:resolver:ad2s1210 minimal chan spec conversion Jonathan Cameron
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

This is needed to ensure the required name attribute is
created. Using an id table is the route most consistent
with other drivers.

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

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 5c9c409..9a88563 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -760,6 +760,7 @@ static int __devinit ad2s1210_probe(struct spi_device *spi)
 	indio_dev->dev.parent = &spi->dev;
 	indio_dev->info = &ad2s1210_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->name = spi_get_device_id(spi)->name;
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
@@ -791,6 +792,11 @@ static int __devexit ad2s1210_remove(struct spi_device *spi)
 	return 0;
 }
 
+static const struct spi_device_id ad2s1210_id[] = {
+	{ "ad2s1210" },
+	{}
+};
+
 static struct spi_driver ad2s1210_driver = {
 	.driver = {
 		.name = DRV_NAME,
@@ -798,6 +804,7 @@ static struct spi_driver ad2s1210_driver = {
 	},
 	.probe = ad2s1210_probe,
 	.remove = __devexit_p(ad2s1210_remove),
+	.id_table = ad2s1210_id,
 };
 
 static __init int ad2s1210_spi_init(void)
-- 
1.7.3.4


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

* [PATCH 09/11] staging:iio:resolver:ad2s1210 minimal chan spec conversion.
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (7 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 08/11] staging:iio:resolver:ad2s1210 ensure iio_dev->name is set Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 10/11] staging:iio:resolver:ad2s1210 drop raw config register access Jonathan Cameron
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Just convert the raw reads in this patch.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/resolver/ad2s1210.c |  114 +++++++++++++++++--------------
 1 files changed, 63 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 9a88563..697db80 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -514,71 +514,70 @@ error_ret:
 	return ret < 0 ? ret : len;
 }
 
-static ssize_t ad2s1210_show_pos(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
+static int ad2s1210_read_raw(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan,
+			     int *val,
+			     int *val2,
+			     long m)
 {
+	struct ad2s1210_state *st = iio_priv(indio_dev);
+	bool negative;
 	int ret = 0;
-	ssize_t len = 0;
 	u16 pos;
-	struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
-
-	mutex_lock(&st->lock);
-	gpio_set_value(st->pdata->sample, 0);
-	/* delay (6 * tck + 20) nano seconds */
-	udelay(1);
-
-	ad2s1210_set_mode(MOD_POS, st);
-	ret = spi_read(st->sdev, st->rx, 2);
-	if (ret)
-		goto error_ret;
-	pos = be16_to_cpup((u16 *)st->rx);
-	if (st->hysteresis)
-		pos >>= 16 - st->resolution;
-	len = sprintf(buf, "%d\n", pos);
-error_ret:
-	gpio_set_value(st->pdata->sample, 1);
-	/* delay (2 * tck + 20) nano seconds */
-	udelay(1);
-	mutex_unlock(&st->lock);
-
-	return ret < 0 ? ret : len;
-}
-
-static ssize_t ad2s1210_show_vel(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
-{
-	unsigned short negative;
-	int ret = 0;
-	ssize_t len = 0;
 	s16 vel;
-	struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
 
 	mutex_lock(&st->lock);
 	gpio_set_value(st->pdata->sample, 0);
 	/* delay (6 * tck + 20) nano seconds */
 	udelay(1);
 
-	ad2s1210_set_mode(MOD_VEL, st);
+	switch (chan->type) {
+	case IIO_ANGL:
+		ad2s1210_set_mode(MOD_POS, st);
+		break;
+	case IIO_ANGL_VEL:
+		ad2s1210_set_mode(MOD_VEL, st);
+		break;
+	default:
+	       ret = -EINVAL;
+	       break;
+	}
+	if (ret < 0)
+		goto error_ret;
 	ret = spi_read(st->sdev, st->rx, 2);
-	if (ret)
+	if (ret < 0)
 		goto error_ret;
-	negative = st->rx[0] & 0x80;
-	vel = be16_to_cpup((s16 *)st->rx);
-	vel >>= 16 - st->resolution;
-	if (vel & 0x8000) {
-		negative = (0xffff >> st->resolution) << st->resolution;
-		vel |= negative;
+
+	switch (chan->type) {
+	case IIO_ANGL:
+		pos = be16_to_cpup((u16 *)st->rx);
+		if (st->hysteresis)
+			pos >>= 16 - st->resolution;
+		*val = pos;
+		ret = IIO_VAL_INT;
+		break;
+	case IIO_ANGL_VEL:
+		negative = st->rx[0] & 0x80;
+		vel = be16_to_cpup((s16 *)st->rx);
+		vel >>= 16 - st->resolution;
+		if (vel & 0x8000) {
+			negative = (0xffff >> st->resolution) << st->resolution;
+			vel |= negative;
+		}
+		*val = vel;
+		ret = IIO_VAL_INT;
+		break;
+	default:
+		mutex_unlock(&st->lock);
+		return -EINVAL;
 	}
-	len = sprintf(buf, "%d\n", vel);
+
 error_ret:
 	gpio_set_value(st->pdata->sample, 1);
 	/* delay (2 * tck + 20) nano seconds */
 	udelay(1);
 	mutex_unlock(&st->lock);
-
-	return ret < 0 ? ret : len;
+	return ret;
 }
 
 static IIO_DEVICE_ATTR(raw_io, S_IRUGO | S_IWUSR,
@@ -595,8 +594,7 @@ static IIO_DEVICE_ATTR(bits, S_IRUGO | S_IWUSR,
 		       ad2s1210_show_resolution, ad2s1210_store_resolution, 0);
 static IIO_DEVICE_ATTR(fault, S_IRUGO | S_IWUSR,
 		       ad2s1210_show_fault, ad2s1210_clear_fault, 0);
-static IIO_DEVICE_ATTR(pos, S_IRUGO, ad2s1210_show_pos, NULL, 0);
-static IIO_DEVICE_ATTR(vel, S_IRUGO,  ad2s1210_show_vel, NULL, 0);
+
 static IIO_DEVICE_ATTR(los_thrd, S_IRUGO | S_IWUSR,
 		       ad2s1210_show_reg, ad2s1210_store_reg,
 		       AD2S1210_REG_LOS_THRD);
@@ -619,6 +617,19 @@ static IIO_DEVICE_ATTR(lot_low_thrd, S_IRUGO | S_IWUSR,
 		       ad2s1210_show_reg, ad2s1210_store_reg,
 		       AD2S1210_REG_LOT_LOW_THRD);
 
+
+static struct iio_chan_spec ad2s1210_channels[] = {
+	{
+		.type = IIO_ANGL,
+		.indexed = 1,
+		.channel = 0,
+	}, {
+		.type = IIO_ANGL_VEL,
+		.indexed = 1,
+		.channel = 0,
+	}
+};
+
 static struct attribute *ad2s1210_attributes[] = {
 	&iio_dev_attr_raw_io.dev_attr.attr,
 	&iio_dev_attr_reset.dev_attr.attr,
@@ -627,8 +638,6 @@ static struct attribute *ad2s1210_attributes[] = {
 	&iio_dev_attr_control.dev_attr.attr,
 	&iio_dev_attr_bits.dev_attr.attr,
 	&iio_dev_attr_fault.dev_attr.attr,
-	&iio_dev_attr_pos.dev_attr.attr,
-	&iio_dev_attr_vel.dev_attr.attr,
 	&iio_dev_attr_los_thrd.dev_attr.attr,
 	&iio_dev_attr_dos_ovr_thrd.dev_attr.attr,
 	&iio_dev_attr_dos_mis_thrd.dev_attr.attr,
@@ -681,6 +690,7 @@ error_ret:
 }
 
 static const struct iio_info ad2s1210_info = {
+	.read_raw = &ad2s1210_read_raw,
 	.attrs = &ad2s1210_attribute_group,
 	.driver_module = THIS_MODULE,
 };
@@ -760,6 +770,8 @@ static int __devinit ad2s1210_probe(struct spi_device *spi)
 	indio_dev->dev.parent = &spi->dev;
 	indio_dev->info = &ad2s1210_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->channels = ad2s1210_channels;
+	indio_dev->num_channels = ARRAY_SIZE(ad2s1210_channels);
 	indio_dev->name = spi_get_device_id(spi)->name;
 
 	ret = iio_device_register(indio_dev);
-- 
1.7.3.4


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

* [PATCH 10/11] staging:iio:resolver:ad2s1210 drop raw config register access
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (8 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 09/11] staging:iio:resolver:ad2s1210 minimal chan spec conversion Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-09-30 10:14 ` [PATCH 11/11] staging:iio:resolver:ad2s1210 cleanup gpio handling Jonathan Cameron
  2011-10-05  6:58 ` [PATCH 00/11] IIO: resolvers - first round of cleanups Hennerich, Michael
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

This should never have been exposed to userspace

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

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 697db80..4f248de 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -195,47 +195,6 @@ static inline int ad2s1210_soft_reset(struct ad2s1210_state *st)
 	return ad2s1210_config_write(st, 0x0);
 }
 
-
-/* return the OLD DATA since last spi bus write */
-static ssize_t ad2s1210_show_raw(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
-{
-	struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
-	int ret = 0;
-
-	mutex_lock(&st->lock);
-	if (st->old_data) {
-		ret = sprintf(buf, "0x%x\n", st->rx[0]);
-		st->old_data = false;
-	}
-	mutex_unlock(&st->lock);
-
-	return ret;
-}
-
-static ssize_t ad2s1210_store_raw(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf,
-				  size_t len)
-{
-	struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
-	unsigned long udata;
-	unsigned char data;
-	int ret;
-
-	ret = strict_strtoul(buf, 16, &udata);
-	if (ret)
-		return -EINVAL;
-
-	data = udata & 0xff;
-	mutex_lock(&st->lock);
-	ret = ad2s1210_config_write(st, data);
-	mutex_unlock(&st->lock);
-
-	return ret < 0 ? ret : len;
-}
-
 static ssize_t ad2s1210_store_softreset(struct device *dev,
 					struct device_attribute *attr,
 					const char *buf,
@@ -580,8 +539,6 @@ error_ret:
 	return ret;
 }
 
-static IIO_DEVICE_ATTR(raw_io, S_IRUGO | S_IWUSR,
-		       ad2s1210_show_raw, ad2s1210_store_raw, 0);
 static IIO_DEVICE_ATTR(reset, S_IWUSR,
 		       NULL, ad2s1210_store_softreset, 0);
 static IIO_DEVICE_ATTR(fclkin, S_IRUGO | S_IWUSR,
@@ -631,7 +588,6 @@ static struct iio_chan_spec ad2s1210_channels[] = {
 };
 
 static struct attribute *ad2s1210_attributes[] = {
-	&iio_dev_attr_raw_io.dev_attr.attr,
 	&iio_dev_attr_reset.dev_attr.attr,
 	&iio_dev_attr_fclkin.dev_attr.attr,
 	&iio_dev_attr_fexcit.dev_attr.attr,
-- 
1.7.3.4


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

* [PATCH 11/11] staging:iio:resolver:ad2s1210 cleanup gpio handling.
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (9 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 10/11] staging:iio:resolver:ad2s1210 drop raw config register access Jonathan Cameron
@ 2011-09-30 10:14 ` Jonathan Cameron
  2011-10-05  6:58 ` [PATCH 00/11] IIO: resolvers - first round of cleanups Hennerich, Michael
  11 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-09-30 10:14 UTC (permalink / raw)
  To: linux-iio; +Cc: Device-drivers-devel, manuel.stahl, Jonathan Cameron

Basically make use of the gpio array functions.
Technically the free doesn't need as much info
as given here, but this keeps it clean and easy
to follow.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/resolver/ad2s1210.c |   51 +++++++++++--------------------
 1 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 4f248de..8a6fcb6 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -653,45 +653,30 @@ static const struct iio_info ad2s1210_info = {
 
 static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
 {
-	int ret;
 	unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
+	struct gpio ad2s1210_gpios[] = {
+		{ st->pdata->sample, GPIOF_DIR_IN, "sample" },
+		{ st->pdata->a[0], flags, "a0" },
+		{ st->pdata->a[1], flags, "a1" },
+		{ st->pdata->res[0], flags, "res0" },
+		{ st->pdata->res[0], flags, "res1" },
+	};
 
-	ret = gpio_request_one(st->pdata->sample, GPIOF_DIR_IN, "sample");
-	if (ret < 0)
-		goto error_ret;
-	ret = gpio_request_one(st->pdata->a[0], flags, "a0");
-	if (ret < 0)
-		goto error_free_sample;
-	ret = gpio_request_one(st->pdata->a[1], flags, "a1");
-	if (ret < 0)
-		goto error_free_a0;
-	ret = gpio_request_one(st->pdata->res[1], flags, "res0");
-	if (ret < 0)
-		goto error_free_a1;
-	ret = gpio_request_one(st->pdata->res[1], flags, "res1");
-	if (ret < 0)
-		goto error_free_res0;
-
-	return 0;
-error_free_res0:
-	gpio_free(st->pdata->res[0]);
-error_free_a1:
-	gpio_free(st->pdata->a[1]);
-error_free_a0:
-	gpio_free(st->pdata->a[0]);
-error_free_sample:
-	gpio_free(st->pdata->sample);
-error_ret:
-	return ret;
+	return gpio_request_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios));
 }
 
 static void ad2s1210_free_gpios(struct ad2s1210_state *st)
 {
-	gpio_free(st->pdata->res[1]);
-	gpio_free(st->pdata->res[0]);
-	gpio_free(st->pdata->a[1]);
-	gpio_free(st->pdata->a[0]);
-	gpio_free(st->pdata->sample);
+	unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
+	struct gpio ad2s1210_gpios[] = {
+		{ st->pdata->sample, GPIOF_DIR_IN, "sample" },
+		{ st->pdata->a[0], flags, "a0" },
+		{ st->pdata->a[1], flags, "a1" },
+		{ st->pdata->res[0], flags, "res0" },
+		{ st->pdata->res[0], flags, "res1" },
+	};
+
+	gpio_free_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios));
 }
 
 static int __devinit ad2s1210_probe(struct spi_device *spi)
-- 
1.7.3.4

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

* RE: [PATCH 00/11] IIO: resolvers - first round of cleanups.
  2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
                   ` (10 preceding siblings ...)
  2011-09-30 10:14 ` [PATCH 11/11] staging:iio:resolver:ad2s1210 cleanup gpio handling Jonathan Cameron
@ 2011-10-05  6:58 ` Hennerich, Michael
  2011-10-05 14:34   ` Jonathan Cameron
  11 siblings, 1 reply; 14+ messages in thread
From: Hennerich, Michael @ 2011-10-05  6:58 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio@vger.kernel.org
  Cc: Device-drivers-devel@blackfin.uclinux.org,
	manuel.stahl@iis.fraunhofer.de

Jonathan Cameron wrote on 2011-09-30:
> Hi All,
>
> Mostly straight forward, but that change I suggested yesterday
> IIO_GYRO -> IIO_ANGL_VEL and in_gyro_x_* -> in_anglvel_x_*
> is in here.  I'm interested to hear peoples opinions on that
> in particular.
>
> Note the ad2s1210 is still definitely a work in progress.
> There are numerous weird and wonderful corners of its abi
> a the moment that need sorting out.
>
> Thanks,
>
> Jonathan

Hi Jonathan,

Looks good to me. Thanks!

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


> Jonathan Cameron (11):
>   staging:iio:resolver:ad2s90 fix registration of null pointer
>   staging:iio:resolver:ad2s90 ensure name is passed to iio_core.
>   stagiong:iio:resolver:ad2s90 chan spec conversion
>   staging:iio: rename gyro channels to anglvel
>   staging:iio:Documentation gyro -> anglvel updates in attribute names
>   staging:iio:resolver:ad2s120x chan spec conversion
>   staging:iio:resolver rename ad2s120x ->ad2s1200
>   staging:iio:resolver:ad2s1210 ensure iio_dev->name is set
>   staging:iio:resolver:ad2s1210 minimal chan spec conversion.
>   staging:iio:resolver:ad2s1210 drop raw config register access
>   staging:iio:resolver:ad2s1210 cleanup gpio handling.
>  drivers/staging/iio/Documentation/sysfs-bus-iio |  108 ++++++------
>  drivers/staging/iio/gyro/adis16060_core.c       |    2 +-
>  drivers/staging/iio/gyro/adis16080_core.c       |    2 +-
>  drivers/staging/iio/gyro/adis16130_core.c       |    2 +-
>  drivers/staging/iio/gyro/adis16260_core.c       |    8 +-
>  drivers/staging/iio/gyro/adxrs450_core.c        |    4 +-
>  drivers/staging/iio/iio.h                       |    2 +-
>  drivers/staging/iio/imu/adis16400_core.c        |   22 ++--
>  drivers/staging/iio/industrialio-core.c         |    2 +-
>  drivers/staging/iio/resolver/Kconfig            |    4 +-
>  drivers/staging/iio/resolver/Makefile           |    2 +-
>  drivers/staging/iio/resolver/ad2s1200.c         |  187
>  ++++++++++++++++++++ drivers/staging/iio/resolver/ad2s120x.c         |
>  178 --------------- ---- drivers/staging/iio/resolver/ad2s1210.c
>   |  216 +++++++++------ ------- drivers/staging/iio/resolver/ad2s90.c
>          |   57 +++--- 15 files changed, 382 insertions(+), 414
>  deletions(-) create mode 100644 drivers/staging/iio/resolver/ad2s1200.c
>  delete mode 100644 drivers/staging/iio/resolver/ad2s120x.c

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] 14+ messages in thread

* Re: [PATCH 00/11] IIO: resolvers - first round of cleanups.
  2011-10-05  6:58 ` [PATCH 00/11] IIO: resolvers - first round of cleanups Hennerich, Michael
@ 2011-10-05 14:34   ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2011-10-05 14:34 UTC (permalink / raw)
  To: Hennerich, Michael
  Cc: linux-iio@vger.kernel.org,
	Device-drivers-devel@blackfin.uclinux.org,
	manuel.stahl@iis.fraunhofer.de

On 10/05/11 07:58, Hennerich, Michael wrote:
> Jonathan Cameron wrote on 2011-09-30:
>> Hi All,
>>
>> Mostly straight forward, but that change I suggested yesterday
>> IIO_GYRO -> IIO_ANGL_VEL and in_gyro_x_* -> in_anglvel_x_*
>> is in here.  I'm interested to hear peoples opinions on that
>> in particular.
>>
>> Note the ad2s1210 is still definitely a work in progress.
>> There are numerous weird and wonderful corners of its abi
>> a the moment that need sorting out.
>>
>> Thanks,
>>
>> Jonathan
> 
> Hi Jonathan,
> 
> Looks good to me. Thanks!
Gone to Greg along with the ad7314 removal patch.

Jonathan


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

end of thread, other threads:[~2011-10-05 14:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30 10:14 [PATCH 00/11] IIO: resolvers - first round of cleanups Jonathan Cameron
2011-09-30 10:14 ` [PATCH 01/11] staging:iio:resolver:ad2s90 fix registration of null pointer Jonathan Cameron
2011-09-30 10:14 ` [PATCH 02/11] staging:iio:resolver:ad2s90 ensure name is passed to iio_core Jonathan Cameron
2011-09-30 10:14 ` [PATCH 03/11] stagiong:iio:resolver:ad2s90 chan spec conversion Jonathan Cameron
2011-09-30 10:14 ` [PATCH 04/11] staging:iio: rename gyro channels to anglvel Jonathan Cameron
2011-09-30 10:14 ` [PATCH 05/11] staging:iio:Documentation gyro -> anglvel updates in attribute names Jonathan Cameron
2011-09-30 10:14 ` [PATCH 06/11] staging:iio:resolver:ad2s120x chan spec conversion Jonathan Cameron
2011-09-30 10:14 ` [PATCH 07/11] staging:iio:resolver rename ad2s120x ->ad2s1200 Jonathan Cameron
2011-09-30 10:14 ` [PATCH 08/11] staging:iio:resolver:ad2s1210 ensure iio_dev->name is set Jonathan Cameron
2011-09-30 10:14 ` [PATCH 09/11] staging:iio:resolver:ad2s1210 minimal chan spec conversion Jonathan Cameron
2011-09-30 10:14 ` [PATCH 10/11] staging:iio:resolver:ad2s1210 drop raw config register access Jonathan Cameron
2011-09-30 10:14 ` [PATCH 11/11] staging:iio:resolver:ad2s1210 cleanup gpio handling Jonathan Cameron
2011-10-05  6:58 ` [PATCH 00/11] IIO: resolvers - first round of cleanups Hennerich, Michael
2011-10-05 14:34   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).