Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
From: Alexandru Tachici <alexandru.tachici@analog.com>
To: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <jic23@kernel.org>, Alexandru Tachici <alexandru.tachici@analog.com>
Subject: [PATCH v3 1/5] staging: iio: adc: ad7192: fail probe on get_voltage
Date: Wed, 12 Feb 2020 18:17:17 +0200
Message-ID: <20200212161721.16200-2-alexandru.tachici@analog.com> (raw)
In-Reply-To: <20200212161721.16200-1-alexandru.tachici@analog.com>

This patch makes the ad7192_probe fail in case
regulator_get_voltage will return an error or voltage
is set to 0.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
---
 drivers/staging/iio/adc/ad7192.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index bf3e2a9cc07f..41da8b4cdc48 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -899,10 +899,13 @@ static int ad7192_probe(struct spi_device *spi)
 
 	voltage_uv = regulator_get_voltage(st->avdd);
 
-	if (voltage_uv)
+	if (voltage_uv > 0) {
 		st->int_vref_mv = voltage_uv / 1000;
-	else
+	} else {
+		ret = voltage_uv;
 		dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
+		goto error_disable_avdd;
+	}
 
 	spi_set_drvdata(spi, indio_dev);
 	st->devid = spi_get_device_id(spi)->driver_data;
-- 
2.20.1


  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 16:17 [PATCH v3 0/5] iio: adc: ad7192: move out of staging Alexandru Tachici
2020-02-12 16:17 ` Alexandru Tachici [this message]
2020-02-14 15:40   ` [PATCH v3 1/5] staging: iio: adc: ad7192: fail probe on get_voltage Jonathan Cameron
2020-02-12 16:17 ` [PATCH v3 2/5] staging: iio: adc: ad7192: modify iio_chan_spec array Alexandru Tachici
2020-02-14 15:47   ` Jonathan Cameron
2020-02-12 16:17 ` [PATCH 3/5] staging: iio: adc: ad7192: removed spi_device_id Alexandru Tachici
2020-02-14 15:48   ` Jonathan Cameron
2020-02-12 16:17 ` [PATCH v3 4/5] Documentation: ABI: testing: ad7192: update sysfs docs Alexandru Tachici
2020-02-14 15:49   ` Jonathan Cameron
2020-02-12 16:17 ` [PATCH v3 5/5] staging: iio: adc: ad7192: move out of staging Alexandru Tachici
2020-02-14 15:50   ` Jonathan Cameron

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=20200212161721.16200-2-alexandru.tachici@analog.com \
    --to=alexandru.tachici@analog.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git