Skip to content

Commit

Permalink
staging:iio:gyro:adis16130 move to iio_chan_spec registration.
Browse files Browse the repository at this point in the history
Simple conversion now we've dropped the type attributes.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Aug 23, 2011
1 parent 494c6b1 commit ae0b4bd
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions drivers/staging/iio/gyro/adis16130_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#include "../iio.h"
#include "../sysfs.h"
#include "gyro.h"
#include "../adc/adc.h"

#define ADIS16130_CON 0x0
#define ADIS16130_CON_RD (1 << 6)
Expand Down Expand Up @@ -50,11 +48,9 @@ struct adis16130_state {
u8 buf[4] ____cacheline_aligned;
};

static int adis16130_spi_read(struct device *dev, u8 reg_addr,
u32 *val)
static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
{
int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16130_state *st = iio_priv(indio_dev);
struct spi_message msg;
struct spi_transfer xfer = {
Expand All @@ -80,43 +76,40 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr,
return ret;
}

static ssize_t adis16130_val_read(struct device *dev,
struct device_attribute *attr,
char *buf)
static int adis16130_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2,
long mask)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct iio_dev *indio_dev = dev_get_drvdata(dev);
u32 val;
ssize_t ret;
int ret;
u32 temp;

/* Take the iio_dev status lock */
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);

if (ret == 0)
return sprintf(buf, "%d\n", val);
else
if (ret)
return ret;
*val = temp;
return IIO_VAL_INT;
}

static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16130_val_read, NULL,
ADIS16130_TEMPDATA);

static IIO_DEV_ATTR_GYRO_Z(adis16130_val_read, ADIS16130_RATEDATA);

static struct attribute *adis16130_attributes[] = {
&iio_dev_attr_temp_raw.dev_attr.attr,
&iio_dev_attr_gyro_z_raw.dev_attr.attr,
NULL
};

static const struct attribute_group adis16130_attribute_group = {
.attrs = adis16130_attributes,
static const struct iio_chan_spec adis16130_channels[] = {
{
.type = IIO_GYRO,
.modified = 1,
.channel2 = IIO_MOD_Z,
.address = ADIS16130_RATEDATA,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
.address = ADIS16130_TEMPDATA,
}
};

static const struct iio_info adis16130_info = {
.attrs = &adis16130_attribute_group,
.read_raw = &adis16130_read_raw,
.driver_module = THIS_MODULE,
};

Expand All @@ -138,6 +131,8 @@ static int __devinit adis16130_probe(struct spi_device *spi)
st->us = spi;
mutex_init(&st->buf_lock);
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->info = &adis16130_info;
indio_dev->modes = INDIO_DIRECT_MODE;
Expand Down

0 comments on commit ae0b4bd

Please sign in to comment.