diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-10-14 17:46:58 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-10-18 02:34:53 +0400 |
commit | d2fffd6c2fd60fe9ab63ef30758d9d43a5057549 (patch) | |
tree | 7c0178872f67c15707cd3c89f82352ba90da1d09 /drivers/staging/iio/adc | |
parent | cdea0bec8d37f2943ae500512b0c178bc76de6e3 (diff) | |
download | linux-d2fffd6c2fd60fe9ab63ef30758d9d43a5057549.tar.xz |
staging:iio: fix removal path to allow correct freeing.
Fix a dumb lack of consideration of the effect of combining
the iio_device_unregister and iio_free_device calls into
one. There is no valid place to free some of the sysfs
array elements.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
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 | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7152.c | 1 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7192.c | 26 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7280a.c | 19 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7291.c | 4 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7298_core.c | 4 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7476_core.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7606_core.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7746.c | 1 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7780.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7793.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7816.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7887_core.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad799x_core.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/adt7310.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/adt7410.c | 3 | ||||
-rw-r--r-- | drivers/staging/iio/adc/max1363_core.c | 3 |
17 files changed, 48 insertions, 40 deletions
diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index 7d0509682fb2..e185f0e052a3 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c @@ -628,13 +628,14 @@ static int __devexit ad7150_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + iio_device_unregister(indio_dev); if (client->irq) free_irq(client->irq, indio_dev); if (client->dev.platform_data) free_irq(*(unsigned int *)client->dev.platform_data, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index f980a093882a..662584d72a74 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c @@ -519,6 +519,7 @@ static int __devexit ad7152_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 29258f4a0955..31c376b9d5eb 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -1032,7 +1032,7 @@ static int __devinit ad7192_probe(struct spi_device *spi) struct ad7192_platform_data *pdata = spi->dev.platform_data; struct ad7192_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"); @@ -1090,14 +1090,9 @@ static int __devinit ad7192_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 = ad7192_probe_trigger(indio_dev); if (ret) - goto error_unreg_ring; + goto error_ring_cleanup; ret = iio_buffer_register(indio_dev, indio_dev->channels, @@ -1107,15 +1102,18 @@ static int __devinit ad7192_probe(struct spi_device *spi) ret = ad7192_setup(st); if (ret) - goto error_uninitialize_ring; + goto error_unreg_ring; + ret = iio_device_register(indio_dev); + if (ret < 0) + goto error_unreg_ring; return 0; -error_uninitialize_ring: +error_unreg_ring: iio_buffer_unregister(indio_dev); error_remove_trigger: ad7192_remove_trigger(indio_dev); -error_unreg_ring: +error_ring_cleanup: ad7192_ring_cleanup(indio_dev); error_disable_reg: if (!IS_ERR(st->reg)) @@ -1124,10 +1122,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; } @@ -1137,6 +1132,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_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7192_remove_trigger(indio_dev); ad7192_ring_cleanup(indio_dev); @@ -1146,8 +1142,6 @@ static int ad7192_remove(struct spi_device *spi) regulator_put(st->reg); } - iio_device_unregister(indio_dev); - return 0; } diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 386834a9b69d..372d059042f9 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -831,7 +831,7 @@ static int __devinit ad7280_probe(struct spi_device *spi) { const struct ad7280_platform_data *pdata = spi->dev.platform_data; struct ad7280_state *st; - int ret, regdone = 0; + int ret; const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890}; const unsigned short nAVG[4] = {1, 2, 4, 8}; struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); @@ -903,21 +903,20 @@ static int __devinit ad7280_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) goto error_free_attr; - regdone = 1; if (spi->irq > 0) { ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_ALERT, 1, AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN); if (ret) - goto error_free_attr; + goto error_unregister; ret = ad7280_write(st, AD7280A_DEVADDR(st->slave_num), AD7280A_ALERT, 0, AD7280A_ALERT_GEN_STATIC_HIGH | (pdata->chain_last_alert_ignore & 0xF)); if (ret) - goto error_free_attr; + goto error_unregister; ret = request_threaded_irq(spi->irq, NULL, @@ -927,10 +926,12 @@ static int __devinit ad7280_probe(struct spi_device *spi) indio_dev->name, indio_dev); if (ret) - goto error_free_attr; + goto error_unregister; } return 0; +error_unregister: + iio_device_unregister(indio_dev); error_free_attr: kfree(st->iio_attr); @@ -939,10 +940,7 @@ error_free_channels: kfree(st->channels); error_free_device: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); return ret; } @@ -954,13 +952,14 @@ static int __devexit ad7280_remove(struct spi_device *spi) if (spi->irq > 0) free_irq(spi->irq, indio_dev); + iio_device_unregister(indio_dev); ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); kfree(st->channels); kfree(st->iio_attr); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index acdce8c5092f..10e79e8ee64d 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -670,6 +670,8 @@ static int __devexit ad7291_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad7291_chip_info *chip = iio_priv(indio_dev); + iio_device_unregister(indio_dev); + if (client->irq) free_irq(client->irq, indio_dev); @@ -678,7 +680,7 @@ static int __devexit ad7291_remove(struct i2c_client *client) regulator_put(chip->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index b77272722f50..c1de73a1ca91 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -249,14 +249,14 @@ 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_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7298_ring_cleanup(indio_dev); - iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 1953dbf2cbd3..fd79facc6cae 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -211,13 +211,14 @@ static int ad7476_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7476_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7476_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 3c0fb729891a..54423ab196fe 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -545,6 +545,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq) { struct ad7606_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7606_ring_cleanup(indio_dev); @@ -555,7 +556,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq) } ad7606_free_gpios(st); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7746.c b/drivers/staging/iio/adc/ad7746.c index 3fe0c1715dce..2867943309cc 100644 --- a/drivers/staging/iio/adc/ad7746.c +++ b/drivers/staging/iio/adc/ad7746.c @@ -766,6 +766,7 @@ static int __devexit ad7746_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index a8103c06e749..7a579a1fd696 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -255,13 +255,14 @@ static int ad7780_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7780_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); free_irq(spi->irq, st); gpio_free(st->pdata->gpio_pdrst); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 0a536c5ff36b..a831b92cd082 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -1013,6 +1013,7 @@ static int ad7793_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7793_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7793_remove_trigger(indio_dev); ad7793_ring_cleanup(indio_dev); @@ -1022,7 +1023,7 @@ static int ad7793_remove(struct spi_device *spi) regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 1440619d74e0..bdb90492b8a5 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -435,13 +435,14 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev) struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); + iio_device_unregister(indio_dev); dev_set_drvdata(&spi_dev->dev, NULL); if (spi_dev->irq) free_irq(spi_dev->irq, indio_dev); gpio_free(chip->busy_pin); gpio_free(chip->convert_pin); gpio_free(chip->rdwr_pin); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 9456c032c053..609dcd5f2ddc 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -230,13 +230,14 @@ static int ad7887_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct ad7887_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); ad7887_ring_cleanup(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 2d60539b4e4c..ee6cd792bec8 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -892,6 +892,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad799x_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); if (client->irq > 0) free_irq(client->irq, indio_dev); @@ -901,7 +902,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) regulator_disable(st->reg); regulator_put(st->reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index cbbd34922d40..c9e0be3b1cf3 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -856,12 +856,13 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev) struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); unsigned long *adt7310_platform_data = spi_dev->dev.platform_data; + iio_device_unregister(indio_dev); dev_set_drvdata(&spi_dev->dev, NULL); if (adt7310_platform_data[0]) free_irq(adt7310_platform_data[0], indio_dev); if (spi_dev->irq) free_irq(spi_dev->irq, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index cc913bc35108..a289e429dc41 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -819,11 +819,12 @@ static int __devexit adt7410_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); unsigned long *adt7410_platform_data = client->dev.platform_data; + iio_device_unregister(indio_dev); if (adt7410_platform_data[0]) free_irq(adt7410_platform_data[0], indio_dev); if (client->irq) free_irq(client->irq, indio_dev); - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index e962f8412d37..12db93efaf84 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1347,6 +1347,7 @@ static int max1363_remove(struct i2c_client *client) struct max1363_state *st = iio_priv(indio_dev); struct regulator *reg = st->reg; + iio_device_unregister(indio_dev); if (client->irq) free_irq(st->client->irq, indio_dev); iio_buffer_unregister(indio_dev); @@ -1356,7 +1357,7 @@ static int max1363_remove(struct i2c_client *client) regulator_disable(reg); regulator_put(reg); } - iio_device_unregister(indio_dev); + iio_free_device(indio_dev); return 0; } |