summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/accel/adis16220_core.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-10-14 13:46:58 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-17 22:34:53 (GMT)
commitd2fffd6c2fd60fe9ab63ef30758d9d43a5057549 (patch)
tree7c0178872f67c15707cd3c89f82352ba90da1d09 /drivers/staging/iio/accel/adis16220_core.c
parentcdea0bec8d37f2943ae500512b0c178bc76de6e3 (diff)
downloadlinux-fsl-qoriq-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/accel/adis16220_core.c')
-rw-r--r--drivers/staging/iio/accel/adis16220_core.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c
index 15f5f30..6d4503d 100644
--- a/drivers/staging/iio/accel/adis16220_core.c
+++ b/drivers/staging/iio/accel/adis16220_core.c
@@ -624,7 +624,7 @@ static const struct iio_info adis16220_info = {
static int __devinit adis16220_probe(struct spi_device *spi)
{
- int ret, regdone = 0;
+ int ret;
struct adis16220_state *st;
struct iio_dev *indio_dev;
@@ -652,11 +652,10 @@ static int __devinit adis16220_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;
- regdone = 1;
ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin);
if (ret)
- goto error_free_dev;
+ goto error_unregister_dev;
ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin);
if (ret)
@@ -678,11 +677,10 @@ error_rm_adc1_bin:
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
error_rm_accel_bin:
sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
+error_unregister_dev:
+ iio_device_unregister(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;
}
@@ -697,6 +695,7 @@ static int adis16220_remove(struct spi_device *spi)
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
iio_device_unregister(indio_dev);
+ iio_free_device(indio_dev);
return 0;
}