Skip to content

Commit

Permalink
staging:iio: rework of attribute registration.
Browse files Browse the repository at this point in the history
This set also includes quite a number of bug fixes of particularly
remove functions.

Necessary due to issue pointed out in Bart Van Assche's patch:
docs/driver-model: Document device.groups

V2: Rebase due to patch reordering.
V3: Pull various error fixes and cleanups out into their own patches.

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 330c6c5 commit 26d25ae
Show file tree
Hide file tree
Showing 42 changed files with 388 additions and 488 deletions.
16 changes: 6 additions & 10 deletions drivers/staging/iio/accel/adis16201_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static const struct iio_info adis16201_info = {

static int __devinit adis16201_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adis16201_state *st;
struct iio_dev *indio_dev;

Expand Down Expand Up @@ -492,11 +492,6 @@ static int __devinit adis16201_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
adis16201_channels,
ARRAY_SIZE(adis16201_channels));
Expand All @@ -515,6 +510,10 @@ static int __devinit adis16201_probe(struct spi_device *spi)
ret = adis16201_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;

ret = iio_device_register(indio_dev);
if (ret < 0)
goto error_remove_trigger;
return 0;

error_remove_trigger:
Expand All @@ -524,10 +523,7 @@ static int __devinit adis16201_probe(struct spi_device *spi)
error_unreg_ring_funcs:
adis16201_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
17 changes: 7 additions & 10 deletions drivers/staging/iio/accel/adis16203_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static const struct iio_info adis16203_info = {

static int __devinit adis16203_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct iio_dev *indio_dev;
struct adis16203_state *st;

Expand All @@ -446,11 +446,6 @@ static int __devinit adis16203_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
adis16203_channels,
ARRAY_SIZE(adis16203_channels));
Expand All @@ -469,6 +464,11 @@ static int __devinit adis16203_probe(struct spi_device *spi)
ret = adis16203_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;

ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;

return 0;

error_remove_trigger:
Expand All @@ -478,10 +478,7 @@ static int __devinit adis16203_probe(struct spi_device *spi)
error_unreg_ring_funcs:
adis16203_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
16 changes: 6 additions & 10 deletions drivers/staging/iio/accel/adis16204_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static const struct iio_info adis16204_info = {

static int __devinit adis16204_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adis16204_state *st;
struct iio_dev *indio_dev;

Expand All @@ -521,11 +521,6 @@ static int __devinit adis16204_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
adis16204_channels,
ARRAY_SIZE(adis16204_channels));
Expand All @@ -544,6 +539,10 @@ static int __devinit adis16204_probe(struct spi_device *spi)
ret = adis16204_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;
ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;

return 0;

error_remove_trigger:
Expand All @@ -553,10 +552,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
error_unreg_ring_funcs:
adis16204_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
16 changes: 6 additions & 10 deletions drivers/staging/iio/accel/adis16209_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static const struct iio_info adis16209_info = {

static int __devinit adis16209_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adis16209_state *st;
struct iio_dev *indio_dev;

Expand All @@ -494,11 +494,6 @@ static int __devinit adis16209_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
adis16209_channels,
ARRAY_SIZE(adis16209_channels));
Expand All @@ -517,6 +512,10 @@ static int __devinit adis16209_probe(struct spi_device *spi)
ret = adis16209_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;
ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;

return 0;

error_remove_trigger:
Expand All @@ -526,10 +525,7 @@ static int __devinit adis16209_probe(struct spi_device *spi)
error_unreg_ring_funcs:
adis16209_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
15 changes: 5 additions & 10 deletions drivers/staging/iio/accel/adis16240_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static const struct iio_info adis16240_info = {

static int __devinit adis16240_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct adis16240_state *st;
struct iio_dev *indio_dev;

Expand Down Expand Up @@ -547,11 +547,6 @@ static int __devinit adis16240_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
adis16240_channels,
ARRAY_SIZE(adis16240_channels));
Expand All @@ -568,6 +563,9 @@ static int __devinit adis16240_probe(struct spi_device *spi)

/* Get the device into a sane initial state */
ret = adis16240_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;
ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;
return 0;
Expand All @@ -579,10 +577,7 @@ static int __devinit adis16240_probe(struct spi_device *spi)
error_unreg_ring_funcs:
adis16240_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
18 changes: 7 additions & 11 deletions drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static const struct iio_info lis3l02dq_info = {

static int __devinit lis3l02dq_probe(struct spi_device *spi)
{
int ret, regdone = 0;
int ret;
struct lis3l02dq_state *st;
struct iio_dev *indio_dev;

Expand All @@ -690,11 +690,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_ring_funcs;
regdone = 1;

ret = iio_ring_buffer_register(indio_dev,
lis3l02dq_channels,
ARRAY_SIZE(lis3l02dq_channels));
Expand Down Expand Up @@ -722,6 +717,11 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
ret = lis3l02dq_initial_setup(indio_dev);
if (ret)
goto error_remove_trigger;

ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;

return 0;

error_remove_trigger:
Expand All @@ -735,9 +735,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
error_unreg_ring_funcs:
lis3l02dq_unconfigure_ring(indio_dev);
error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
error_ret:
return ret;
Expand Down Expand Up @@ -790,9 +787,8 @@ static int lis3l02dq_remove(struct spi_device *spi)
lis3l02dq_remove_trigger(indio_dev);
iio_ring_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_ring(indio_dev);
iio_device_unregister(indio_dev);

return 0;
iio_device_unregister(indio_dev);

err_ret:
return ret;
Expand Down
20 changes: 10 additions & 10 deletions drivers/staging/iio/adc/ad7150.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ static const struct iio_info ad7150_info = {
static int __devinit ad7150_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret = 0, regdone = 0;
int ret;
struct ad7150_chip_info *chip;
struct iio_dev *indio_dev;

Expand All @@ -742,11 +742,6 @@ static int __devinit ad7150_probe(struct i2c_client *client,

indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;
regdone = 1;

if (client->irq) {
ret = request_threaded_irq(client->irq,
NULL,
Expand All @@ -759,15 +754,20 @@ static int __devinit ad7150_probe(struct i2c_client *client,
goto error_free_dev;
}

ret = iio_device_register(indio_dev);
if (ret)
goto error_free_irq;


dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq);

return 0;
error_free_irq:
if (client->irq)
free_irq(client->irq, indio_dev);

error_free_dev:
if (regdone)
iio_device_unregister(indio_dev);
else
iio_free_device(indio_dev);
iio_free_device(indio_dev);
error_ret:
return ret;
}
Expand Down
12 changes: 5 additions & 7 deletions drivers/staging/iio/adc/ad7291.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,6 @@ static int __devinit ad7291_probe(struct i2c_client *client,
indio_dev->info = &ad7291_info;
indio_dev->modes = INDIO_DIRECT_MODE;

ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;

if (client->irq > 0) {
ret = request_threaded_irq(client->irq,
NULL,
Expand All @@ -823,7 +819,7 @@ static int __devinit ad7291_probe(struct i2c_client *client,
id->name,
indio_dev);
if (ret)
goto error_unreg_dev;
goto error_free_dev;

/* set irq polarity low level */
chip->command |= AD7291_ALART_POLARITY;
Expand All @@ -835,15 +831,17 @@ static int __devinit ad7291_probe(struct i2c_client *client,
goto error_unreg_irq;
}

ret = iio_device_register(indio_dev);
if (ret)
goto error_unreg_irq;

dev_info(&client->dev, "%s temperature sensor registered.\n",
id->name);

return 0;

error_unreg_irq:
free_irq(client->irq, indio_dev);
error_unreg_dev:
iio_device_unregister(indio_dev);
error_free_dev:
iio_free_device(indio_dev);
error_ret:
Expand Down
Loading

0 comments on commit 26d25ae

Please sign in to comment.