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/ad7192.c | |
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/ad7192.c')
-rw-r--r-- | drivers/staging/iio/adc/ad7192.c | 26 |
1 files changed, 10 insertions, 16 deletions
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; } |