staging:iio: fix removal path to allow correct freeing.
[deliverable/linux.git] / drivers / staging / iio / gyro / adis16060_core.c
index 0cbe677359bf9b1694dff0d5a132e815317aed0d..38cf3f4bf726c582900af9f4940fadf524c51ffc 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
+#include <linux/module.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
@@ -116,17 +117,17 @@ static const struct iio_info adis16060_info = {
 
 static const struct iio_chan_spec adis16060_channels[] = {
        {
-               .type = IIO_GYRO,
+               .type = IIO_ANGL_VEL,
                .modified = 1,
                .channel2 = IIO_MOD_Z,
                .address = ADIS16060_GYRO,
        }, {
-               .type = IIO_IN,
+               .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 0,
                .address = ADIS16060_AIN1,
        }, {
-               .type = IIO_IN,
+               .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 1,
                .address = ADIS16060_AIN2,
@@ -142,7 +143,7 @@ static const struct iio_chan_spec adis16060_channels[] = {
 
 static int __devinit adis16060_r_probe(struct spi_device *spi)
 {
-       int ret, regdone = 0;
+       int ret;
        struct adis16060_state *st;
        struct iio_dev *indio_dev;
 
@@ -168,16 +169,12 @@ static int __devinit adis16060_r_probe(struct spi_device *spi)
        ret = iio_device_register(indio_dev);
        if (ret)
                goto error_free_dev;
-       regdone = 1;
 
        adis16060_iio_dev = indio_dev;
        return 0;
 
 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;
 }
@@ -186,6 +183,7 @@ error_ret:
 static int adis16060_r_remove(struct spi_device *spi)
 {
        iio_device_unregister(spi_get_drvdata(spi));
+       iio_free_device(spi_get_drvdata(spi));
 
        return 0;
 }
This page took 0.025445 seconds and 5 git commands to generate.