Skip to content

Commit

Permalink
staging:iio: implement an iio_info structure to take some of the cons…
Browse files Browse the repository at this point in the history
…tant elements out of iio_dev.

This was suggested by Arnd Bergmann,  Other elements may well
move in here in future, but it definitely makes sense for these.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent a3f0237 commit 6fe8135
Show file tree
Hide file tree
Showing 61 changed files with 970 additions and 675 deletions.
13 changes: 9 additions & 4 deletions drivers/staging/iio/accel/adis16201_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,13 @@ static const struct attribute_group adis16201_attribute_group = {
.attrs = adis16201_attributes,
};

static const struct iio_info adis16201_info = {
.attrs = &adis16201_attribute_group,
.read_raw = &adis16201_read_raw,
.write_raw = &adis16201_write_raw,
.driver_module = THIS_MODULE,
};

static int __devinit adis16201_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -490,13 +497,11 @@ static int __devinit adis16201_probe(struct spi_device *spi)

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16201_attribute_group;
st->indio_dev->info = &adis16201_info;

st->indio_dev->channels = adis16201_channels;
st->indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
st->indio_dev->read_raw = &adis16201_read_raw;
st->indio_dev->write_raw = &adis16201_write_raw;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = adis16201_configure_ring(st->indio_dev);
Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/iio/accel/adis16203_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ static const struct attribute_group adis16203_attribute_group = {
.attrs = adis16203_attributes,
};

static const struct iio_info adis16203_info = {
.attrs = &adis16203_attribute_group,
.read_raw = &adis16203_read_raw,
.write_raw = &adis16203_write_raw,
.driver_module = THIS_MODULE,
};

static int __devinit adis16203_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -440,13 +447,10 @@ static int __devinit adis16203_probe(struct spi_device *spi)
}
st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16203_attribute_group;
st->indio_dev->channels = adis16203_channels;
st->indio_dev->num_channels = ARRAY_SIZE(adis16203_channels);
st->indio_dev->read_raw = &adis16203_read_raw;
st->indio_dev->write_raw = &adis16203_write_raw;
st->indio_dev->info = &adis16203_info;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = adis16203_configure_ring(st->indio_dev);
Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/iio/accel/adis16204_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ static const struct attribute_group adis16204_attribute_group = {
.attrs = adis16204_attributes,
};

static const struct iio_info adis16204_info = {
.attrs = &adis16204_attribute_group,
.read_raw = &adis16204_read_raw,
.write_raw = &adis16204_write_raw,
.driver_module = THIS_MODULE,
};

static int __devinit adis16204_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -506,13 +513,10 @@ static int __devinit adis16204_probe(struct spi_device *spi)

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16204_attribute_group;
st->indio_dev->info = &adis16204_info;
st->indio_dev->channels = adis16204_channels;
st->indio_dev->num_channels = ARRAY_SIZE(adis16204_channels);
st->indio_dev->read_raw = &adis16204_read_raw;
st->indio_dev->write_raw = &adis16204_write_raw;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = adis16204_configure_ring(st->indio_dev);
Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/iio/accel/adis16209_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ static const struct attribute_group adis16209_attribute_group = {
.attrs = adis16209_attributes,
};

static const struct iio_info adis16209_info = {
.attrs = &adis16209_attribute_group,
.read_raw = &adis16209_read_raw,
.write_raw = &adis16209_write_raw,
.driver_module = THIS_MODULE,
};

static int __devinit adis16209_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -489,13 +496,10 @@ static int __devinit adis16209_probe(struct spi_device *spi)

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16209_attribute_group;
st->indio_dev->info = &adis16209_info;
st->indio_dev->channels = adis16209_channels;
st->indio_dev->num_channels = ARRAY_SIZE(adis16209_channels);
st->indio_dev->read_raw = &adis16209_read_raw;
st->indio_dev->write_raw = &adis16209_write_raw;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = adis16209_configure_ring(st->indio_dev);
Expand Down
7 changes: 5 additions & 2 deletions drivers/staging/iio/accel/adis16220_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ static const struct attribute_group adis16220_attribute_group = {
.attrs = adis16220_attributes,
};

static const struct iio_info adis16220_info = {
.attrs = &adis16220_attribute_group,
.driver_module = THIS_MODULE,
};
static int __devinit adis16220_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -577,9 +581,8 @@ static int __devinit adis16220_probe(struct spi_device *spi)

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16220_attribute_group;
st->indio_dev->info = &adis16220_info;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(st->indio_dev);
Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/iio/accel/adis16240_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ static const struct attribute_group adis16240_attribute_group = {
.attrs = adis16240_attributes,
};

static const struct iio_info adis16240_info = {
.attrs = &adis16240_attribute_group,
.read_raw = &adis16240_read_raw,
.write_raw = &adis16240_write_raw,
.driver_module = THIS_MODULE,
};

static int __devinit adis16240_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand Down Expand Up @@ -540,13 +547,10 @@ static int __devinit adis16240_probe(struct spi_device *spi)

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->attrs = &adis16240_attribute_group;
st->indio_dev->info = &adis16240_info;
st->indio_dev->channels = adis16240_channels;
st->indio_dev->num_channels = ARRAY_SIZE(adis16240_channels);
st->indio_dev->read_raw = &adis16240_read_raw;
st->indio_dev->write_raw = &adis16240_write_raw;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = adis16240_configure_ring(st->indio_dev);
Expand Down
12 changes: 6 additions & 6 deletions drivers/staging/iio/accel/kxsd9.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ static int __devinit kxsd9_power_up(struct spi_device *spi)

};

static const struct iio_info kxsd9_info = {
.attrs = &kxsd9_attribute_group,
.driver_module = THIS_MODULE,
};

static int __devinit kxsd9_probe(struct spi_device *spi)
{

Expand Down Expand Up @@ -335,13 +340,8 @@ static int __devinit kxsd9_probe(struct spi_device *spi)
goto error_free_tx;
}
st->indio_dev->dev.parent = &spi->dev;
/* for now */
st->indio_dev->num_interrupt_lines = 0;
st->indio_dev->event_attrs = NULL;

st->indio_dev->attrs = &kxsd9_attribute_group;
st->indio_dev->info = &kxsd9_info;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(st->indio_dev);
Expand Down
23 changes: 14 additions & 9 deletions drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,18 @@ static const struct attribute_group lis3l02dq_attribute_group = {
.attrs = lis3l02dq_attributes,
};

static const struct iio_info lis3l02dq_info = {
.num_interrupt_lines = 1,
.read_raw = &lis3l02dq_read_raw,
.write_raw = &lis3l02dq_write_raw,
.read_event_value = &lis3l02dq_read_thresh,
.write_event_value = &lis3l02dq_write_thresh,
.write_event_config = &lis3l02dq_write_event_config,
.read_event_config = &lis3l02dq_read_event_config,
.driver_module = THIS_MODULE,
.attrs = &lis3l02dq_attribute_group,
};

static int __devinit lis3l02dq_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand All @@ -670,17 +682,10 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
mutex_init(&st->buf_lock);
indio_dev->name = spi->dev.driver->name;
indio_dev->dev.parent = &spi->dev;
indio_dev->num_interrupt_lines = 1;
indio_dev->info = &lis3l02dq_info;
indio_dev->channels = lis3l02dq_channels;
indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels);
indio_dev->read_raw = &lis3l02dq_read_raw;
indio_dev->write_raw = &lis3l02dq_write_raw;
indio_dev->read_event_value = &lis3l02dq_read_thresh;
indio_dev->write_event_value = &lis3l02dq_write_thresh;
indio_dev->write_event_config = &lis3l02dq_write_event_config;
indio_dev->read_event_config = &lis3l02dq_read_event_config;
indio_dev->attrs = &lis3l02dq_attribute_group;
indio_dev->driver_module = THIS_MODULE;

indio_dev->modes = INDIO_DIRECT_MODE;

ret = lis3l02dq_configure_ring(indio_dev);
Expand Down
33 changes: 24 additions & 9 deletions drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,28 @@ static int sca3000_clean_setup(struct sca3000_state *st)
return ret;
}

static const struct iio_info sca3000_info = {
.attrs = &sca3000_attribute_group,
.read_raw = &sca3000_read_raw,
.num_interrupt_lines = 1,
.event_attrs = &sca3000_event_attribute_group,
.read_event_value = &sca3000_read_thresh,
.write_event_value = &sca3000_write_thresh,
.read_event_config = &sca3000_read_event_config,
.write_event_config = &sca3000_write_event_config,
.driver_module = THIS_MODULE,
};

static const struct iio_info sca3000_info_with_temp = {
.attrs = &sca3000_attribute_group_with_temp,
.read_raw = &sca3000_read_raw,
.read_event_value = &sca3000_read_thresh,
.write_event_value = &sca3000_write_thresh,
.read_event_config = &sca3000_read_event_config,
.write_event_config = &sca3000_write_event_config,
.driver_module = THIS_MODULE,
};

static int __devinit sca3000_probe(struct spi_device *spi)
{
int ret, regdone = 0;
Expand All @@ -1124,20 +1146,13 @@ static int __devinit sca3000_probe(struct spi_device *spi)
}
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->name = spi_get_device_id(spi)->name;
st->indio_dev->num_interrupt_lines = 1;
st->indio_dev->event_attrs = &sca3000_event_attribute_group;
if (st->info->temp_output)
st->indio_dev->attrs = &sca3000_attribute_group_with_temp;
st->indio_dev->info = &sca3000_info_with_temp;
else {
st->indio_dev->attrs = &sca3000_attribute_group;
st->indio_dev->info = &sca3000_info;
st->indio_dev->channels = sca3000_channels;
st->indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
}
st->indio_dev->read_raw = &sca3000_read_raw;
st->indio_dev->read_event_value = &sca3000_read_thresh;
st->indio_dev->write_event_value = &sca3000_write_thresh;
st->indio_dev->read_event_config = &sca3000_read_event_config;
st->indio_dev->write_event_config = &sca3000_write_event_config;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->modes = INDIO_DIRECT_MODE;

Expand Down
15 changes: 10 additions & 5 deletions drivers/staging/iio/adc/ad7150.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ static struct attribute_group ad7150_event_attribute_group = {
.attrs = ad7150_event_attributes,
};

static const struct iio_info ad7150_info = {
.attrs = &ad7150_attribute_group,
.num_interrupt_lines = 1,
.event_attrs = &ad7150_event_attribute_group,
.driver_module = THIS_MODULE,
};
/*
* device probe and remove
*/
Expand All @@ -725,14 +731,13 @@ static int __devinit ad7150_probe(struct i2c_client *client,
goto error_free_chip;
}

/* Echipabilish that the iio_dev is a child of the i2c device */
/* Establish that the iio_dev is a child of the i2c device */
chip->indio_dev->name = id->name;
chip->indio_dev->dev.parent = &client->dev;
chip->indio_dev->attrs = &ad7150_attribute_group;
chip->indio_dev->event_attrs = &ad7150_event_attribute_group;

chip->indio_dev->info = &ad7150_info;
chip->indio_dev->dev_data = (void *)(chip);
chip->indio_dev->driver_module = THIS_MODULE;
chip->indio_dev->num_interrupt_lines = 1;

chip->indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(chip->indio_dev);
Expand Down
7 changes: 5 additions & 2 deletions drivers/staging/iio/adc/ad7152.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ static const struct attribute_group ad7152_attribute_group = {
.attrs = ad7152_attributes,
};

static const struct iio_info ad7152_info = {
.attrs = &ad7152_attribute_group,
.driver_module = THIS_MODULE,
};
/*
* device probe and remove
*/
Expand Down Expand Up @@ -525,9 +529,8 @@ static int __devinit ad7152_probe(struct i2c_client *client,
/* Echipabilish that the iio_dev is a child of the i2c device */
chip->indio_dev->name = id->name;
chip->indio_dev->dev.parent = &client->dev;
chip->indio_dev->attrs = &ad7152_attribute_group;
chip->indio_dev->info = &ad7152_info;
chip->indio_dev->dev_data = (void *)(chip);
chip->indio_dev->driver_module = THIS_MODULE;
chip->indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(chip->indio_dev);
Expand Down
11 changes: 7 additions & 4 deletions drivers/staging/iio/adc/ad7291.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,12 @@ static struct attribute_group ad7291_event_attribute_group = {
.attrs = ad7291_event_attributes,
};

static const struct iio_info ad7291_info = {
.attrs = &ad7291_attribute_group,
.num_interrupt_lines = 1,
.event_attrs = &ad7291_event_attribute_group,
};

/*
* device probe and remove
*/
Expand Down Expand Up @@ -807,11 +813,8 @@ static int __devinit ad7291_probe(struct i2c_client *client,

chip->indio_dev->name = id->name;
chip->indio_dev->dev.parent = &client->dev;
chip->indio_dev->attrs = &ad7291_attribute_group;
chip->indio_dev->event_attrs = &ad7291_event_attribute_group;
chip->indio_dev->info = &ad7291_info;
chip->indio_dev->dev_data = (void *)chip;
chip->indio_dev->driver_module = THIS_MODULE;
chip->indio_dev->num_interrupt_lines = 1;
chip->indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(chip->indio_dev);
Expand Down
8 changes: 6 additions & 2 deletions drivers/staging/iio/adc/ad7298_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ static int ad7298_read_raw(struct iio_dev *dev_info,
return -EINVAL;
}

static const struct iio_info ad7298_info = {
.read_raw = &ad7298_read_raw,
.driver_module = THIS_MODULE,
};

static int __devinit ad7298_probe(struct spi_device *spi)
{
struct ad7298_platform_data *pdata = spi->dev.platform_data;
Expand All @@ -181,11 +186,10 @@ static int __devinit ad7298_probe(struct spi_device *spi)

indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->dev.parent = &spi->dev;
indio_dev->driver_module = THIS_MODULE;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ad7298_channels;
indio_dev->num_channels = ARRAY_SIZE(ad7298_channels);
indio_dev->read_raw = &ad7298_read_raw;
indio_dev->info = &ad7298_info;

/* Setup default message */

Expand Down
Loading

0 comments on commit 6fe8135

Please sign in to comment.