From b72eb70209a0aac7651166d3f610ffb57b4c6e5f Mon Sep 17 00:00:00 2001 From: Cristina Opriceana Date: Sun, 29 Mar 2015 16:14:39 +0300 Subject: [PATCH] Staging: iio: Add error check on iio_register_device() This patch checks if an error occurred on probe and stops the device in order to avoid wasting power. Signed-off-by: Cristina Opriceana Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/meter/ade7754.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 6335b5815acd..f12b2e50329b 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -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 */ -- 2.20.1