diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-10-14 13:46:58 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-10-17 22:34:53 (GMT) |
commit | d2fffd6c2fd60fe9ab63ef30758d9d43a5057549 (patch) | |
tree | 7c0178872f67c15707cd3c89f82352ba90da1d09 /drivers/staging/iio/adc/ad7280a.c | |
parent | cdea0bec8d37f2943ae500512b0c178bc76de6e3 (diff) | |
download | linux-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/adc/ad7280a.c')
-rw-r--r-- | drivers/staging/iio/adc/ad7280a.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 386834a..372d059 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; } |