From: Cristina Opriceana <cristina.opriceana@gmail.com>
To: outreachy-kernel@googlegroups.com
Cc: outreachy-kernel@googlegroups.com
Subject: [PATCH] Staging: iio: Add error check on iio_register_device()
Date: Sun, 29 Mar 2015 16:14:39 +0300 [thread overview]
Message-ID: <20150329131439.GA32324@Inspiron> (raw)
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
reply other threads:[~2015-03-29 13:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150329131439.GA32324@Inspiron \
--to=cristina.opriceana@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.