From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit()
Date: Mon, 31 Aug 2020 12:08:06 +0300 [thread overview]
Message-ID: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> (raw)
Potentially bma220_init() and bma220_deinit() may return positive codes.
Fix the logic to return proper error codes instead.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/accel/bma220_spi.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index da8b36cc8628..3247b9c8abcb 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -198,10 +198,12 @@ static int bma220_init(struct spi_device *spi)
/* Make sure the chip is powered on */
ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
+ if (ret == BMA220_SUSPEND_WAKE)
+ ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
if (ret < 0)
return ret;
- else if (ret == BMA220_SUSPEND_WAKE)
- return bma220_read_reg(spi, BMA220_REG_SUSPEND);
+ if (ret == BMA220_SUSPEND_WAKE)
+ return -EBUSY;
return 0;
}
@@ -212,10 +214,12 @@ static int bma220_deinit(struct spi_device *spi)
/* Make sure the chip is powered off */
ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
+ if (ret == BMA220_SUSPEND_SLEEP)
+ ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
if (ret < 0)
return ret;
- else if (ret == BMA220_SUSPEND_SLEEP)
- return bma220_read_reg(spi, BMA220_REG_SUSPEND);
+ if (ret == BMA220_SUSPEND_SLEEP)
+ return -EBUSY;
return 0;
}
@@ -245,7 +249,7 @@ static int bma220_probe(struct spi_device *spi)
indio_dev->available_scan_masks = bma220_accel_scan_masks;
ret = bma220_init(data->spi_device);
- if (ret < 0)
+ if (ret)
return ret;
ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
--
2.28.0
next reply other threads:[~2020-08-31 9:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 9:08 Andy Shevchenko [this message]
2020-08-31 9:08 ` [PATCH v1 2/8] iio: accel: bma220: Convert to use ->read_avail() Andy Shevchenko
2020-09-03 18:35 ` Jonathan Cameron
2020-09-03 19:33 ` Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 3/8] iio: accel: bma220: Use dev_get_drvdata() directly Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 4/8] iio: accel: bma220: Mark PM functions as __maybe_unused Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 5/8] iio: accel: bma220: Drop ACPI_PTR() and accompanying ifdeffery Andy Shevchenko
2020-08-31 9:19 ` Jonathan Cameron
2020-08-31 9:39 ` Andy Shevchenko
2020-08-31 9:55 ` Jonathan Cameron
2020-08-31 10:17 ` Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 6/8] iio: accel: bma220: Group IIO headers together Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 7/8] iio: accel: bma220: Use BIT() and GENMASK() macros Andy Shevchenko
2020-08-31 9:08 ` [PATCH v1 8/8] iio: accel: bma220: Remove unneeded blank lines Andy Shevchenko
2020-08-31 9:21 ` [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit() Jonathan Cameron
2020-08-31 11:49 ` Andy Shevchenko
2020-08-31 14:12 ` Jonathan Cameron
2020-09-03 8:21 ` Jonathan Cameron
2020-09-03 9:06 ` Andy Shevchenko
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=20200831090813.78841-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).