Skip to content

Commit

Permalink
staging: iio: push the main buffer chrdev down to the top level.
Browse files Browse the repository at this point in the history
Sorry all, this one is very invasive, though the driver changes are
just trivial interface fixes. Not all done yet.

V2 - bring the sca3000 with us.
V3 - fix ade7758 bugs in conversion.
V4 - add ad5933

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 Sep 6, 2011
1 parent 6356463 commit 1aa0427
Show file tree
Hide file tree
Showing 31 changed files with 254 additions and 317 deletions.
12 changes: 6 additions & 6 deletions drivers/staging/iio/Documentation/generic_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ int main(int argc, char **argv)
return -1;

/* Find the device requested */
dev_num = find_type_by_name(device_name, "device");
dev_num = find_type_by_name(device_name, "iio:device");
if (dev_num < 0) {
printf("Failed to find the %s\n", device_name);
ret = -ENODEV;
goto error_ret;
}
printf("iio device number being used is %d\n", dev_num);

asprintf(&dev_dir_name, "%sdevice%d", iio_dir, dev_num);
asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
if (trigger_name == NULL) {
/*
* Build the trigger name. If it is device associated it's
Expand Down Expand Up @@ -212,6 +212,7 @@ int main(int argc, char **argv)
ret = build_channel_array(dev_dir_name, &infoarray, &num_channels);
if (ret) {
printf("Problem reading scan element information\n");
printf("diag %s\n", dev_dir_name);
goto error_free_triggername;
}

Expand All @@ -220,7 +221,8 @@ int main(int argc, char **argv)
* As we know that the lis3l02dq has only one buffer this may
* be built rather than found.
*/
ret = asprintf(&buf_dir_name, "%sdevice%d:buffer0", iio_dir, dev_num);
ret = asprintf(&buf_dir_name,
"%siio:device%d/buffer", iio_dir, dev_num);
if (ret < 0) {
ret = -ENOMEM;
goto error_free_triggername;
Expand Down Expand Up @@ -251,9 +253,7 @@ int main(int argc, char **argv)
goto error_free_buf_dir_name;
}

ret = asprintf(&buffer_access,
"/dev/device%d:buffer0",
dev_num);
ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num);
if (ret < 0) {
ret = -ENOMEM;
goto error_free_data;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/iio/Documentation/iio_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define IIO_MAX_NAME_LENGTH 30

#define FORMAT_SCAN_ELEMENTS_DIR "%s:buffer0/scan_elements"
#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
#define FORMAT_TYPE_FILE "%s_type"

const char *iio_dir = "/sys/bus/iio/devices/";
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/adis16201_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static int __devinit adis16201_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
adis16201_channels,
ARRAY_SIZE(adis16201_channels));
if (ret) {
Expand All @@ -520,7 +520,7 @@ static int __devinit adis16201_probe(struct spi_device *spi)
error_remove_trigger:
adis16201_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16201_unconfigure_ring(indio_dev);
error_free_dev:
Expand All @@ -537,7 +537,7 @@ static int adis16201_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);

adis16201_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
iio_device_unregister(indio_dev);
adis16201_unconfigure_ring(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/adis16203_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ static int __devinit adis16203_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
adis16203_channels,
ARRAY_SIZE(adis16203_channels));
if (ret) {
Expand All @@ -474,7 +474,7 @@ static int __devinit adis16203_probe(struct spi_device *spi)
error_remove_trigger:
adis16203_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16203_unconfigure_ring(indio_dev);
error_free_dev:
Expand All @@ -491,7 +491,7 @@ static int adis16203_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);

adis16203_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
iio_device_unregister(indio_dev);
adis16203_unconfigure_ring(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/adis16204_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
adis16204_channels,
ARRAY_SIZE(adis16204_channels));
if (ret) {
Expand All @@ -549,7 +549,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
error_remove_trigger:
adis16204_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16204_unconfigure_ring(indio_dev);
error_free_dev:
Expand All @@ -566,7 +566,7 @@ static int adis16204_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);

adis16204_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
iio_device_unregister(indio_dev);
adis16204_unconfigure_ring(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/adis16209_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static int __devinit adis16209_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
adis16209_channels,
ARRAY_SIZE(adis16209_channels));
if (ret) {
Expand All @@ -522,7 +522,7 @@ static int __devinit adis16209_probe(struct spi_device *spi)
error_remove_trigger:
adis16209_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16209_unconfigure_ring(indio_dev);
error_free_dev:
Expand All @@ -541,7 +541,7 @@ static int adis16209_remove(struct spi_device *spi)
flush_scheduled_work();

adis16209_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
iio_device_unregister(indio_dev);
adis16209_unconfigure_ring(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/adis16240_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static int __devinit adis16240_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
adis16240_channels,
ARRAY_SIZE(adis16240_channels));
if (ret) {
Expand All @@ -575,7 +575,7 @@ static int __devinit adis16240_probe(struct spi_device *spi)
error_remove_trigger:
adis16240_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16240_unconfigure_ring(indio_dev);
error_free_dev:
Expand All @@ -595,7 +595,7 @@ static int adis16240_remove(struct spi_device *spi)
flush_scheduled_work();

adis16240_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
iio_device_unregister(indio_dev);
adis16240_unconfigure_ring(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
lis3l02dq_channels,
ARRAY_SIZE(lis3l02dq_channels));
if (ret) {
Expand Down Expand Up @@ -732,7 +732,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
free_irq(st->us->irq, indio_dev);
error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
lis3l02dq_unconfigure_ring(indio_dev);
error_free_dev:
Expand Down Expand Up @@ -789,7 +789,7 @@ static int lis3l02dq_remove(struct spi_device *spi)
free_irq(st->us->irq, indio_dev);

lis3l02dq_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
if (ret < 0)
goto error_free_dev;
regdone = 1;
ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
sca3000_channels,
ARRAY_SIZE(sca3000_channels));
if (ret < 0)
Expand All @@ -1182,7 +1182,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
free_irq(spi->irq, indio_dev);
error_unregister_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_unregister_dev:
error_free_dev:
if (regdone)
Expand Down Expand Up @@ -1223,7 +1223,7 @@ static int sca3000_remove(struct spi_device *spi)
return ret;
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
free_irq(spi->irq, indio_dev);
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
sca3000_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);

Expand Down
23 changes: 3 additions & 20 deletions drivers/staging/iio/accel/sca3000_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ static int sca3000_ring_get_bytes_per_datum(struct iio_ring_buffer *r)
{
return 6;
}
static void sca3000_ring_release(struct device *dev)
{
struct iio_ring_buffer *r = to_iio_ring_buffer(dev);
kfree(iio_to_hw_ring_buf(r));
}

static IIO_RING_ENABLE_ATTR;
static IIO_RING_BYTES_PER_DATUM_ATTR;
Expand Down Expand Up @@ -258,16 +253,7 @@ static struct attribute *sca3000_ring_attributes[] = {

static struct attribute_group sca3000_ring_attr = {
.attrs = sca3000_ring_attributes,
};

static const struct attribute_group *sca3000_ring_attr_groups[] = {
&sca3000_ring_attr,
NULL
};

static struct device_type sca3000_ring_type = {
.release = sca3000_ring_release,
.groups = sca3000_ring_attr_groups,
.name = "buffer",
};

static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
Expand All @@ -282,18 +268,15 @@ static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
ring->private = indio_dev;
buf = &ring->buf;
buf->stufftoread = 0;
buf->attrs = &sca3000_ring_attr;
iio_ring_buffer_init(buf, indio_dev);
buf->dev.type = &sca3000_ring_type;
buf->dev.parent = &indio_dev->dev;
dev_set_drvdata(&buf->dev, (void *)buf);

return buf;
}

static inline void sca3000_rb_free(struct iio_ring_buffer *r)
{
if (r)
iio_put_ring_buffer(r);
kfree(iio_to_hw_ring_buf(r));
}

static const struct iio_ring_access_funcs sca3000_ring_access_funcs = {
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ static int __devinit ad7192_probe(struct spi_device *spi)
if (ret)
goto error_unreg_ring;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
indio_dev->channels,
indio_dev->num_channels);
if (ret)
Expand All @@ -1111,7 +1111,7 @@ static int __devinit ad7192_probe(struct spi_device *spi)
return 0;

error_uninitialize_ring:
iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
error_remove_trigger:
ad7192_remove_trigger(indio_dev);
error_unreg_ring:
Expand All @@ -1136,7 +1136,7 @@ static int ad7192_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7192_state *st = iio_priv(indio_dev);

iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
ad7192_remove_trigger(indio_dev);
ad7192_ring_cleanup(indio_dev);

Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/iio/adc/ad7298_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static int __devinit ad7298_probe(struct spi_device *spi)
goto error_disable_reg;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
&ad7298_channels[1], /* skip temp0 */
ARRAY_SIZE(ad7298_channels) - 1);
if (ret)
Expand Down Expand Up @@ -253,7 +253,7 @@ static int __devexit ad7298_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct ad7298_state *st = iio_priv(indio_dev);

iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
ad7298_ring_cleanup(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(st->reg)) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/iio/adc/ad7476_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int __devinit ad7476_probe(struct spi_device *spi)
if (ret)
goto error_disable_reg;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
st->chip_info->channel,
ARRAY_SIZE(st->chip_info->channel));
if (ret)
Expand Down Expand Up @@ -215,7 +215,7 @@ static int ad7476_remove(struct spi_device *spi)
/* copy needed as st will have been freed */
struct regulator *reg = st->reg;

iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
ad7476_ring_cleanup(indio_dev);
iio_device_unregister(indio_dev);
if (!IS_ERR(reg)) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/iio/adc/ad7606_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
goto error_free_irq;
regdone = 1;

ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
ret = iio_ring_buffer_register_ex(indio_dev, 0,
indio_dev->channels,
indio_dev->num_channels);
if (ret)
Expand Down Expand Up @@ -541,7 +541,7 @@ int ad7606_remove(struct iio_dev *indio_dev)
{
struct ad7606_state *st = iio_priv(indio_dev);

iio_ring_buffer_unregister(indio_dev->ring);
iio_ring_buffer_unregister(indio_dev);
ad7606_ring_cleanup(indio_dev);

free_irq(st->irq, indio_dev);
Expand Down
Loading

0 comments on commit 1aa0427

Please sign in to comment.