staging:iio: implement an iio_info structure to take some of the constant 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>
This commit is contained in:
Jonathan Cameron
2011-05-18 14:42:37 +01:00
committed by Greg Kroah-Hartman
parent a3f02370c9
commit 6fe8135fcc
61 changed files with 969 additions and 674 deletions
+9 -4
View File
@@ -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;
@@ -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);
+8 -4
View File
@@ -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;
@@ -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);
+8 -4
View File
@@ -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;
@@ -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);
+8 -4
View File
@@ -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;
@@ -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);
+5 -2
View File
@@ -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;
@@ -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);
+8 -4
View File
@@ -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;
@@ -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);
+6 -6
View File
@@ -301,6 +301,11 @@ error_ret:
};
static const struct iio_info kxsd9_info = {
.attrs = &kxsd9_attribute_group,
.driver_module = THIS_MODULE,
};
static int __devinit kxsd9_probe(struct spi_device *spi)
{
@@ -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);
+14 -9
View File
@@ -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;
@@ -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);
+24 -9
View File
@@ -1100,6 +1100,28 @@ error_ret:
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;
@@ -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;
+10 -5
View File
@@ -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
*/
@@ -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);
+5 -2
View File
@@ -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
*/
@@ -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);
+7 -4
View File
@@ -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
*/
@@ -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);
+6 -2
View File
@@ -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;
@@ -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 */
+5 -2
View File
@@ -191,6 +191,10 @@ static const struct attribute_group ad7314_attribute_group = {
.attrs = ad7314_attributes,
};
static const struct iio_info ad7314_info = {
.attrs = &ad7314_attribute_group,
.driver_module = THIS_MODULE,
};
/*
* device probe and remove
*/
@@ -218,9 +222,8 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
chip->indio_dev->name = spi_get_device_id(spi_dev)->name;
chip->indio_dev->dev.parent = &spi_dev->dev;
chip->indio_dev->attrs = &ad7314_attribute_group;
chip->indio_dev->info = &ad7314_info;
chip->indio_dev->dev_data = (void *)chip;
chip->indio_dev->driver_module = THIS_MODULE;
ret = iio_device_register(chip->indio_dev);
if (ret)
+6 -2
View File
@@ -118,6 +118,11 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
},
};
static const struct iio_info ad7476_info = {
.driver_module = THIS_MODULE,
.read_raw = &ad7476_read_raw,
};
static int __devinit ad7476_probe(struct spi_device *spi)
{
struct ad7476_platform_data *pdata = spi->dev.platform_data;
@@ -165,11 +170,10 @@ static int __devinit ad7476_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->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;
st->indio_dev->channels = st->chip_info->channel;
st->indio_dev->num_channels = 2;
st->indio_dev->read_raw = &ad7476_read_raw;
st->indio_dev->info = &ad7476_info;
/* Setup default message */
st->xfer.rx_buf = &st->data;
+7 -3
View File
@@ -426,6 +426,12 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
};
static const struct iio_info ad7606_info = {
.driver_module = THIS_MODULE,
.read_raw = &ad7606_read_raw,
.attrs = &ad7606_attribute_group,
};
struct iio_dev *ad7606_probe(struct device *dev, int irq,
void __iomem *base_address,
unsigned id,
@@ -470,13 +476,11 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
st->chip_info = &ad7606_chip_info_tbl[id];
indio_dev->dev.parent = dev;
indio_dev->attrs = &ad7606_attribute_group;
indio_dev->driver_module = THIS_MODULE;
indio_dev->info = &ad7606_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->name = st->chip_info->name;
indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels;
indio_dev->read_raw = &ad7606_read_raw;
init_waitqueue_head(&st->wq_data_avail);
+7 -4
View File
@@ -565,6 +565,12 @@ static struct attribute_group ad774x_event_attribute_group = {
.attrs = ad774x_event_attributes,
};
static const struct iio_info ad774x_info = {
.attrs = &ad774x_event_attribute_group,
.event_attrs = &ad774x_event_attribute_group,
.num_interrupt_lines = 1,
.driver_module = THIS_MODULE,
};
/*
* device probe and remove
*/
@@ -593,11 +599,8 @@ static int __devinit ad774x_probe(struct i2c_client *client,
/* 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 = &ad774x_attribute_group;
chip->indio_dev->event_attrs = &ad774x_event_attribute_group;
chip->indio_dev->info = &ad774x_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);
+6 -2
View File
@@ -151,6 +151,11 @@ static irqreturn_t ad7780_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
};
static const struct iio_info ad7780_info = {
.read_raw = &ad7780_read_raw,
.driver_module = THIS_MODULE,
};
static int __devinit ad7780_probe(struct spi_device *spi)
{
struct ad7780_platform_data *pdata = spi->dev.platform_data;
@@ -195,11 +200,10 @@ static int __devinit ad7780_probe(struct spi_device *spi)
indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->driver_module = THIS_MODULE;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = &st->chip_info->channel;
indio_dev->num_channels = 1;
indio_dev->read_raw = &ad7780_read_raw;
indio_dev->info = &ad7780_info;
init_waitqueue_head(&st->wq_data_avail);
+8 -4
View File
@@ -331,6 +331,13 @@ static struct attribute_group ad7816_event_attribute_group = {
.attrs = ad7816_event_attributes,
};
static const struct iio_info ad7816_info = {
.attrs = &ad7816_attribute_group,
.num_interrupt_lines = 1,
.event_attrs = &ad7816_event_attribute_group,
.driver_module = THIS_MODULE,
};
/*
* device probe and remove
*/
@@ -391,11 +398,8 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
}
chip->indio_dev->name = spi_get_device_id(spi_dev)->name;
chip->indio_dev->dev.parent = &spi_dev->dev;
chip->indio_dev->attrs = &ad7816_attribute_group;
chip->indio_dev->event_attrs = &ad7816_event_attribute_group;
chip->indio_dev->info = &ad7816_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);
+6 -2
View File
@@ -83,6 +83,11 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
},
};
static const struct iio_info ad7887_info = {
.read_raw = &ad7887_read_raw,
.driver_module = THIS_MODULE,
};
static int __devinit ad7887_probe(struct spi_device *spi)
{
struct ad7887_platform_data *pdata = spi->dev.platform_data;
@@ -114,8 +119,7 @@ static int __devinit ad7887_probe(struct spi_device *spi)
indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->dev_data = (void *)(st);
indio_dev->read_raw = &ad7887_read_raw;
indio_dev->driver_module = THIS_MODULE;
indio_dev->info = &ad7887_info;
indio_dev->modes = INDIO_DIRECT_MODE;
/* Setup default message */

Some files were not shown because too many files have changed in this diff Show More