All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: iio: Add error check on iio_register_device()
@ 2015-03-29 13:14 Cristina Opriceana
  0 siblings, 0 replies; only message in thread
From: Cristina Opriceana @ 2015-03-29 13:14 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: outreachy-kernel

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>
---
 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 6335b58..f12b2e5 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 */
-- 
1.9.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-29 13:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 13:14 [PATCH] Staging: iio: Add error check on iio_register_device() Cristina Opriceana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.