diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-09-02 20:14:40 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-07 03:02:01 +0400 |
commit | 26d25ae3f0d8ffe350aacc75b71198d6b35bd1f4 (patch) | |
tree | 8b7867c7cfb8202e5313c462256ebf7e9932a1f1 /drivers/staging/iio/adc | |
parent | 330c6c57e6284a755d7e8a031b3c917571ee6dc3 (diff) | |
download | linux-26d25ae3f0d8ffe350aacc75b71198d6b35bd1f4.tar.xz |
staging:iio: rework of attribute registration.
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>
Diffstat (limited to 'drivers/staging/iio/adc')
-rw-r--r-- | drivers/staging/iio/adc/ad7150.c | 20 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7291.c | 12 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7298_core.c | 18 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7476_core.c | 16 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7606_core.c | 17 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7745.c | 18 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7793.c | 16 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7816.c | 15 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7887_core.c | 20 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad799x_core.c | 17 | ||||
-rw-r--r-- | drivers/staging/iio/adc/adt7310.c | 12 | ||||
-rw-r--r-- | drivers/staging/iio/adc/adt7410.c | 11 | ||||
-rw-r--r-- | drivers/staging/iio/adc/adt75.c | 12 | ||||
-rw-r--r-- | drivers/staging/iio/adc/max1363_core.c | 18 |
14 files changed, 96 insertions, 126 deletions
diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index d70623c10489..3d154b87f55f 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -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; @@ -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, @@ -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; } diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 16ddbdec912d..46a891d4d2ef 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -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, @@ -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; @@ -835,6 +831,10 @@ 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); @@ -842,8 +842,6 @@ static int __devinit ad7291_probe(struct i2c_client *client, 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: diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 6487359dc4c8..a627bfe208af 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -165,7 +165,7 @@ static int __devinit ad7298_probe(struct spi_device *spi) { struct ad7298_platform_data *pdata = spi->dev.platform_data; struct ad7298_state *st; - int ret, regdone = 0; + int ret; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) @@ -218,19 +218,19 @@ static int __devinit ad7298_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, &ad7298_channels[1], /* skip temp0 */ ARRAY_SIZE(ad7298_channels) - 1); if (ret) goto error_cleanup_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; return 0; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7298_ring_cleanup(indio_dev); error_disable_reg: @@ -239,11 +239,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 7329b009a71a..edf25ce89707 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -129,7 +129,6 @@ static int __devinit ad7476_probe(struct spi_device *spi) struct ad7476_state *st; struct iio_dev *indio_dev; int ret, voltage_uv = 0; - bool reg_done = false; indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -180,28 +179,29 @@ static int __devinit ad7476_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - ret = iio_ring_buffer_register(indio_dev, st->chip_info->channel, ARRAY_SIZE(st->chip_info->channel)); if (ret) goto error_cleanup_ring; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_ring_unregister; return 0; +error_ring_unregister: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7476_ring_cleanup(indio_dev); - iio_device_unregister(indio_dev); error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (!reg_done) - iio_free_device(indio_dev); + iio_free_device(indio_dev); + error_ret: return ret; } diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 7b43da93d779..bea663dc25d2 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -439,7 +439,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, { struct ad7606_platform_data *pdata = dev->platform_data; struct ad7606_state *st; - int ret, regdone = 0; + int ret; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { @@ -501,18 +501,18 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, if (ret) goto error_free_irq; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_irq; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_cleanup_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; return indio_dev; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7606_ring_cleanup(indio_dev); @@ -529,10 +529,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ERR_PTR(ret); } diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 41150c60c209..eea77f1603d8 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c @@ -578,7 +578,7 @@ static const struct iio_info ad774x_info = { static int __devinit ad774x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret = 0, regdone = 0; + int ret; struct ad774x_chip_info *chip; struct iio_dev *indio_dev; @@ -599,11 +599,6 @@ static int __devinit ad774x_probe(struct i2c_client *client, indio_dev->info = &ad774x_info; 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, @@ -615,15 +610,18 @@ static int __devinit ad774x_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: + free_irq(client->irq, indio_dev); error_free_dev: - if (regdone) - free_irq(client->irq, indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index b42a7ace426d..17d18fc7b461 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -827,7 +827,7 @@ static int __devinit ad7793_probe(struct spi_device *spi) struct ad7793_platform_data *pdata = spi->dev.platform_data; struct ad7793_state *st; struct iio_dev *indio_dev; - int ret, i, voltage_uv = 0, regdone = 0; + int ret, i, voltage_uv = 0; if (!pdata) { dev_err(&spi->dev, "no platform data?\n"); @@ -890,11 +890,6 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring; - regdone = 1; - ret = ad7793_probe_trigger(indio_dev); if (ret) goto error_unreg_ring; @@ -909,6 +904,10 @@ static int __devinit ad7793_probe(struct spi_device *spi) if (ret) goto error_uninitialize_ring; + ret = iio_device_register(indio_dev); + if (ret) + goto error_uninitialize_ring; + return 0; error_uninitialize_ring: @@ -924,10 +923,7 @@ error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 5a4586fbe146..deec8f245f90 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -396,10 +396,6 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev) indio_dev->info = &ad7816_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_gpio; - if (spi_dev->irq) { /* Only low trigger is supported in ad7816/7/8 */ ret = request_threaded_irq(spi_dev->irq, @@ -409,16 +405,19 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev) indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_gpio; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; + dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n", indio_dev->name); return 0; - -error_unreg_dev: - iio_device_unregister(indio_dev); +error_free_irq: + free_irq(spi_dev->irq, indio_dev); error_free_gpio: gpio_free(chip->busy_pin); error_free_gpio_convert: diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index e71d08849010..cdd7c130aa16 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -93,7 +93,7 @@ static int __devinit ad7887_probe(struct spi_device *spi) { struct ad7887_platform_data *pdata = spi->dev.platform_data; struct ad7887_state *st; - int ret, voltage_uv = 0, regdone = 0; + int ret, voltage_uv = 0; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) @@ -189,18 +189,19 @@ static int __devinit ad7887_probe(struct spi_device *spi) if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_cleanup_ring; - return 0; + ret = iio_device_register(indio_dev); + if (ret) + goto error_unregister_ring; + + return 0; +error_unregister_ring: + iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: ad7887_ring_cleanup(indio_dev); error_disable_reg: @@ -209,10 +210,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index cfe4b2caea8c..75b8c37ca1e8 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -657,7 +657,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { static int __devinit ad799x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, regdone = 0; + int ret; struct ad799x_platform_data *pdata = client->dev.platform_data; struct ad799x_state *st; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -701,11 +701,6 @@ static int __devinit ad799x_probe(struct i2c_client *client, if (ret) goto error_disable_reg; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); @@ -723,9 +718,14 @@ static int __devinit ad799x_probe(struct i2c_client *client, if (ret) goto error_cleanup_ring; } + ret = iio_device_register(indio_dev); + if (ret) + goto error_free_irq; return 0; +error_free_irq: + free_irq(client->irq, indio_dev); error_cleanup_ring: ad799x_ring_cleanup(indio_dev); error_disable_reg: @@ -734,10 +734,7 @@ error_disable_reg: error_put_reg: if (!IS_ERR(st->reg)) regulator_put(st->reg); - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index edc65c517f61..cbbd34922d40 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -782,10 +782,6 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) indio_dev->info = &adt7310_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - /* CT critcal temperature event. line 0 */ if (spi_dev->irq) { if (adt7310_platform_data[2]) @@ -799,7 +795,7 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; } /* INT bound temperature alarm event. line 1 */ @@ -836,6 +832,10 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_int_irq; + dev_info(&spi_dev->dev, "%s temperature sensor registered.\n", indio_dev->name); @@ -845,8 +845,6 @@ error_unreg_int_irq: free_irq(adt7310_platform_data[0], indio_dev); error_unreg_ct_irq: free_irq(spi_dev->irq, indio_dev); -error_unreg_dev: - iio_device_unregister(indio_dev); error_free_dev: iio_free_device(indio_dev); error_ret: diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index e7e9e25d1e93..cc913bc35108 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -749,10 +749,6 @@ static int __devinit adt7410_probe(struct i2c_client *client, indio_dev->info = &adt7410_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - /* CT critcal temperature event. line 0 */ if (client->irq) { ret = request_threaded_irq(client->irq, @@ -762,7 +758,7 @@ static int __devinit adt7410_probe(struct i2c_client *client, id->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; } /* INT bound temperature alarm event. line 1 */ @@ -799,6 +795,9 @@ static int __devinit adt7410_probe(struct i2c_client *client, goto error_unreg_int_irq; } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_int_irq; dev_info(&client->dev, "%s temperature sensor registered.\n", id->name); @@ -809,8 +808,6 @@ error_unreg_int_irq: free_irq(adt7410_platform_data[0], indio_dev); error_unreg_ct_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: diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index b56bfcdb3375..08215e9edc82 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c @@ -567,10 +567,6 @@ static int __devinit adt75_probe(struct i2c_client *client, indio_dev->info = &adt75_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, @@ -579,7 +575,7 @@ static int __devinit adt75_probe(struct i2c_client *client, indio_dev->name, indio_dev); if (ret) - goto error_unreg_dev; + goto error_free_dev; ret = adt75_i2c_read(indio_dev, ADT75_CONFIG, &chip->config); if (ret) { @@ -597,14 +593,16 @@ static int __devinit adt75_probe(struct i2c_client *client, } } + ret = iio_device_register(indio_dev); + if (ret) + goto error_unreg_irq; + dev_info(&client->dev, "%s temperature sensor registered.\n", indio_dev->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: diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index adbd89b9a574..9962f594d3a6 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1254,7 +1254,7 @@ static int max1363_initial_setup(struct max1363_state *st) static int __devinit max1363_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, i, regdone = 0; + int ret, i; struct max1363_state *st; struct iio_dev *indio_dev; struct regulator *reg; @@ -1312,10 +1312,6 @@ static int __devinit max1363_probe(struct i2c_client *client, if (ret) goto error_free_available_scan_masks; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - regdone = 1; ret = iio_ring_buffer_register(indio_dev, st->chip_info->channels, st->chip_info->num_channels); @@ -1334,8 +1330,13 @@ static int __devinit max1363_probe(struct i2c_client *client, goto error_uninit_ring; } - return 0; + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_free_irq; + return 0; +error_free_irq: + free_irq(st->client->irq, indio_dev); error_uninit_ring: iio_ring_buffer_unregister(indio_dev); error_cleanup_ring: @@ -1343,10 +1344,7 @@ error_cleanup_ring: error_free_available_scan_masks: kfree(indio_dev->available_scan_masks); error_free_device: - if (!regdone) - iio_free_device(indio_dev); - else - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); error_disable_reg: regulator_disable(reg); error_put_reg: |