Staging: iio: Add error check on iio_register_device()
authorCristina Opriceana <cristina.opriceana@gmail.com>
Sun, 29 Mar 2015 13:14:39 +0000 (16:14 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2015 15:23:20 +0000 (17:23 +0200)
This patch checks if an error occurred on probe and stops the
device in order to avoid wasting power.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/meter/ade7754.c

index 6335b5815acda3dc7ce47be53a38587a085594ee..f12b2e50329b6a209af4e95cebaa10a8722ad74b 100644 (file)
@@ -550,8 +550,15 @@ static int ade7754_probe(struct spi_device *spi)
        /* Get the device into a sane initial state */
        ret = ade7754_initial_setup(indio_dev);
        if (ret)
-               return ret;
-       return iio_device_register(indio_dev);
+               goto powerdown_on_error;
+       ret = iio_device_register(indio_dev);
+       if (ret)
+               goto powerdown_on_error;
+       return ret;
+
+powerdown_on_error:
+       ade7754_stop_device(&indio_dev->dev);
+       return ret;
 }
 
 /* fixme, confirm ordering in this function */