Commit ae0b4bdd authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:gyro:adis16130 move to iio_chan_spec registration.

Simple conversion now we've dropped the type attributes.
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Acked-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 494c6b15
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include "../iio.h" #include "../iio.h"
#include "../sysfs.h" #include "../sysfs.h"
#include "gyro.h"
#include "../adc/adc.h"
#define ADIS16130_CON 0x0 #define ADIS16130_CON 0x0
#define ADIS16130_CON_RD (1 << 6) #define ADIS16130_CON_RD (1 << 6)
...@@ -50,11 +48,9 @@ struct adis16130_state { ...@@ -50,11 +48,9 @@ struct adis16130_state {
u8 buf[4] ____cacheline_aligned; u8 buf[4] ____cacheline_aligned;
}; };
static int adis16130_spi_read(struct device *dev, u8 reg_addr, static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
u32 *val)
{ {
int ret; int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16130_state *st = iio_priv(indio_dev); struct adis16130_state *st = iio_priv(indio_dev);
struct spi_message msg; struct spi_message msg;
struct spi_transfer xfer = { struct spi_transfer xfer = {
...@@ -80,43 +76,40 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr, ...@@ -80,43 +76,40 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr,
return ret; return ret;
} }
static ssize_t adis16130_val_read(struct device *dev, static int adis16130_read_raw(struct iio_dev *indio_dev,
struct device_attribute *attr, struct iio_chan_spec const *chan,
char *buf) int *val, int *val2,
long mask)
{ {
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev); u32 temp;
u32 val;
ssize_t ret;
/* Take the iio_dev status lock */ /* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
ret = adis16130_spi_read(dev, this_attr->address, &val); ret = adis16130_spi_read(indio_dev, chan->address, &temp);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
if (ret)
if (ret == 0)
return sprintf(buf, "%d\n", val);
else
return ret; return ret;
*val = temp;
return IIO_VAL_INT;
} }
static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16130_val_read, NULL, static const struct iio_chan_spec adis16130_channels[] = {
ADIS16130_TEMPDATA); {
.type = IIO_GYRO,
static IIO_DEV_ATTR_GYRO_Z(adis16130_val_read, ADIS16130_RATEDATA); .modified = 1,
.channel2 = IIO_MOD_Z,
static struct attribute *adis16130_attributes[] = { .address = ADIS16130_RATEDATA,
&iio_dev_attr_temp_raw.dev_attr.attr, }, {
&iio_dev_attr_gyro_z_raw.dev_attr.attr, .type = IIO_TEMP,
NULL .indexed = 1,
}; .channel = 0,
.address = ADIS16130_TEMPDATA,
static const struct attribute_group adis16130_attribute_group = { }
.attrs = adis16130_attributes,
}; };
static const struct iio_info adis16130_info = { static const struct iio_info adis16130_info = {
.attrs = &adis16130_attribute_group, .read_raw = &adis16130_read_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
}; };
...@@ -138,6 +131,8 @@ static int __devinit adis16130_probe(struct spi_device *spi) ...@@ -138,6 +131,8 @@ static int __devinit adis16130_probe(struct spi_device *spi)
st->us = spi; st->us = spi;
mutex_init(&st->buf_lock); mutex_init(&st->buf_lock);
indio_dev->name = spi->dev.driver->name; indio_dev->name = spi->dev.driver->name;
indio_dev->channels = adis16130_channels;
indio_dev->num_channels = ARRAY_SIZE(adis16130_channels);
indio_dev->dev.parent = &spi->dev; indio_dev->dev.parent = &spi->dev;
indio_dev->info = &adis16130_info; indio_dev->info = &adis16130_info;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment